public int intersectionSize(DocSet other) { return docSet.intersectionSize(other); }
@Override public int intersectionSize(DocSet other) { if (other instanceof BitDocSet) { return (int)OpenBitSet.intersectionCount(this.bits, ((BitDocSet)other).bits); } else { // they had better not call us back! return other.intersectionSize(this); } }
public int intersectionSize(DocSet other) { // intersection is overloaded in the smaller DocSets to be more // efficient, so dispatch off of it instead. if (!(other instanceof BitDocSet)) { return other.intersectionSize(this); } // less efficient way: do the intersection then get it's size return intersection(other).size(); }
@Override public int intersectionSize(DocSet other) { if (other instanceof SortedIntDocSet || other instanceof HashDocSet) { return other.intersectionSize(this); } HashDocSet h = new HashDocSet(docs,offset,len); return h.intersectionSize(other); } }
/** * Returns the number of documents that match both <code>a</code> and <code>b</code>. * <p> * This method is cache-aware and may check as well as modify the cache. * * @param a * @param b * @return the numer of documents in the intersection between <code>a</code> and <code>b</code>. * @throws IOException */ public int numDocs(Query a, DocSet b) throws IOException { // Negative query if absolute value different from original Query absQ = QueryUtils.getAbs(a); DocSet positiveA = getPositiveDocSet(absQ); return a==absQ ? b.intersectionSize(positiveA) : b.andNotSize(positiveA); }
/** * Returns the number of documents that match both <code>a</code> and <code>b</code>. * <p> * This method is cache-aware and may check as well as modify the cache. * * @param a * @param b * @return the numer of documents in the intersection between <code>a</code> and <code>b</code>. * @throws IOException */ public int numDocs(Query a, Query b) throws IOException { Query absA = QueryUtils.getAbs(a); Query absB = QueryUtils.getAbs(b); DocSet positiveA = getPositiveDocSet(absA); DocSet positiveB = getPositiveDocSet(absB); // Negative query if absolute value different from original if (a==absA) { if (b==absB) return positiveA.intersectionSize(positiveB); return positiveA.andNotSize(positiveB); } if (b==absB) return positiveB.andNotSize(positiveA); // if both negative, we need to create a temp DocSet since we // don't have a counting method that takes three. DocSet all = getPositiveDocSet(matchAllDocsQuery); // -a -b == *:*.andNot(a).andNotSize(b) == *.*.andNotSize(a.union(b)) // we use the last form since the intermediate DocSet should normally be smaller. return all.andNotSize(positiveA.union(positiveB)); }
test( res.intersection(filter).equals(both.docSet)); test( res.intersectionSize(filter) == both.docSet.size() ); if (filterQuery != null) { test( searcher.numDocs(filterQuery,res) == both.docSet.size() );