Apache Lucene 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.javaindex 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 implementationspublic 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 sizereturn intersection(other).size();}