public int size() { return docSet.size(); }
/** * SolrIndexSearch.numDocs(Query,Query) freaks out if the filtering * query is null, so we use this workarround. */ public static int numDocs(SolrIndexSearcher s, Query q, Query f) throws IOException { return (null == f) ? s.getDocSet(q).size() : s.numDocs(q,f); }
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(); }
public int unionSize(DocSet other) { return this.size() + other.size() - this.intersectionSize(other); }
@Override public int intersectionSize(DocSet other) { if (other instanceof HashDocSet) { // set "a" to the smallest doc set for the most efficient // intersection. final HashDocSet a = size()<=other.size() ? this : (HashDocSet)other; final HashDocSet b = size()<=other.size() ? (HashDocSet)other : this; int resultCount=0; for (int i=0; i<a.table.length; i++) { int id=a.table[i]; if (id >= 0 && b.exists(id)) { resultCount++; } } return resultCount; } else { int resultCount=0; for (int i=0; i<table.length; i++) { int id=table[i]; if (id >= 0 && other.exists(id)) { resultCount++; } } return resultCount; } }
@Override public DocSet union(DocSet other) { if (other instanceof HashDocSet) { // set "a" to the smallest doc set final HashDocSet a = size()<=other.size() ? this : (HashDocSet)other; final HashDocSet b = size()<=other.size() ? (HashDocSet)other : this; int[] result = new int[a.size()+b.size()]; int resultCount=0; // iterate over the largest table first, adding w/o checking. for (int i=0; i<b.table.length; i++) { int id=b.table[i]; if (id>=0) result[resultCount++]=id; } // now iterate over smaller set, adding all not already in larger set. for (int i=0; i<a.table.length; i++) { int id=a.table[i]; if (id>=0 && !b.exists(id)) result[resultCount++]=id; } return new HashDocSet(result,0,resultCount); } else { return other.union(this); } }
int sz = sets[i].size(); if (sz<smallestCount) { smallestCount=sz;
@Override public DocSet andNot(DocSet other) { if (other.size()==0) return this; if (!(other instanceof SortedIntDocSet)) { int count = 0; int arr[] = new int[docs.length]; for (int i=0; i<docs.length; i++) { int doc = docs[i]; if (!other.exists(doc)) arr[count++] = doc; } return new SortedIntDocSet(arr,count); } int[] otherDocs = ((SortedIntDocSet)other).docs; int[] arr = new int[docs.length]; int sz = andNot(docs, docs.length, otherDocs, otherDocs.length, arr); return new SortedIntDocSet(arr,sz); }
@Override public DocSet intersection(DocSet other) { if (other instanceof HashDocSet) { // set "a" to the smallest doc set for the most efficient // intersection. final HashDocSet a = size()<=other.size() ? this : (HashDocSet)other; final HashDocSet b = size()<=other.size() ? (HashDocSet)other : this; int[] result = new int[a.size()]; int resultCount=0; for (int i=0; i<a.table.length; i++) { int id=a.table[i]; if (id >= 0 && b.exists(id)) { result[resultCount++]=id; } } return new HashDocSet(result,0,resultCount); } else { int[] result = new int[size()]; int resultCount=0; for (int i=0; i<table.length; i++) { int id=table[i]; if (id >= 0 && other.exists(id)) { result[resultCount++]=id; } } return new HashDocSet(result,0,resultCount); } }
maxTermCounts[termNum] = set.size();
if ( all.nTerms <= 0 || docs.size() <= 0 ) return allstats.getStatsValues();
if (nTerms>0 && docs.size() >= mincount) {
public boolean equals(Object obj) { if (!(obj instanceof DocSet)) return false; DocSet other = (DocSet)obj; if (this.size() != other.size()) return false; if (this instanceof DocList && other instanceof DocList) { // compare ordering DocIterator i1=this.iterator(); DocIterator i2=other.iterator(); while(i1.hasNext() && i2.hasNext()) { if (i1.nextDoc() != i2.nextDoc()) return false; } return true; // don't compare matches } // if (this.size() != other.size()) return false; return this.getBits().equals(other.getBits()); }
TermDocs td = r.termDocs(); if (docs.size() >= mincount) { do { Term t = te.term();
int baseSize = docs.size(); int maxDoc = searcher.maxDoc();
test( both.docList.matches() == both.docSet.size() ); test( (start==0 && both.docSet.size() <= limit) ? both.docSet.equals(both.docList) : true); test( both2.docList.size() == 0 ); test( both2.docList.matches() == 0 ); test( both2.docSet.size() == 0 ); test( res.size() >= results.size() ); 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() );
responseBuilder.setResults(results); response.add(Names.QUERY_RESULT, resultSet); response.add(Names.NUM_FOUND, results.docSet.size()); } else { response.add(Names.QUERY_RESULT, execution.execSelect());