Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

avoid taking intersection to get intersectionSize for BitDocSet.intersectionSize(HashDocSet)

Yonik Seeley38bd4288937a
diff --git a/src/java/org/apache/solr/search/DocSet.java b/src/java/org/apache/solr/search/DocSet.java
index b2a9b4fcd2e..4a021777fd7 100644
--- a/src/java/org/apache/solr/search/DocSet.java
+++ b/src/java/org/apache/solr/search/DocSet.java
@@ -164,8 +164,14 @@ abstract class DocSetBase implements DocSet {
return new BitDocSet(newbits);
}
- // TODO: more efficient implementations
public int intersectionSize(DocSet other) {
+ // intersectionSize is overloaded in HashDocSet to be more
+ // efficient, so if "other" is a HashDocSet, dispatch off
+ // of it instead.
+ if (other instanceof HashDocSet) {
+ return other.intersectionSize(this);
+ }
+ // less efficient way: do the intersection then get it's size
return intersection(other).size();
}