/** Return the {@see DocIdSet} which contains all the recorded docs. */ public DocIdSet getDocIdSet() { return bits.build(); } }
/** Return the {@see DocIdSet} which contains all the recorded docs. */ public DocIdSet getDocIdSet() { return bits.build(); } }
} else { assert builder != null; return new WeightOrDocIdSet(builder.build());
} while (termsEnum.next() != null); return new WeightOrDocIdSet(builder.build());
return new ConstantScoreScorer(this, score(), result.build().iterator());
return new ConstantScoreScorer(this, score(), result.build().iterator());
public void flush() throws IOException { if (first == false) { final DocIdSet docIdSet = bucketDocsBuilder.build(); processBucket(queue, context, docIdSet.iterator(), lastBucket, builder); bucketDocsBuilder = null; } } }
visitor.flush(); } catch (CollectionTerminatedException exc) {} return fillDocIdSet ? builder.build() : DocIdSet.EMPTY;
/** * Build a {@link DocIdSet} from the accumulated doc IDs. */ public DocIdSet build() { return build(-1); }
/** * Build a {@link DocIdSet} from the accumulated doc IDs. */ public DocIdSet build() { return build(-1); }
@Override protected DocIdSet finish() { return results.build(); }
@Override public void visit(int docID, byte[] packedValue) throws IOException { if (compare(packedValue, packedValue) != PointValues.Relation.CELL_CROSSES_QUERY) { remaining --; return; } long bucket = bucketFunction.applyAsLong(packedValue); if (first == false && bucket != lastBucket) { final DocIdSet docIdSet = bucketDocsBuilder.build(); if (processBucket(queue, context, docIdSet.iterator(), lastBucket, builder) && // lower bucket is inclusive lowerBucket != lastBucket) { // this bucket does not have any competitive composite buckets, // we can early terminate the collection because the remaining buckets are guaranteed // to be greater than this bucket. throw new CollectionTerminatedException(); } bucketDocsBuilder = new DocIdSetBuilder(maxDoc); assert remaining > 0; adder = bucketDocsBuilder.grow(remaining); } lastBucket = bucket; first = false; adder.add(docID); remaining --; }
/** * Returns a DocIdSet per segments containing the matching docs for the specified slice. */ private DocIdSet build(LeafReader reader) throws IOException { final DocIdSetBuilder builder = new DocIdSetBuilder(reader.maxDoc()); final Terms terms = reader.terms(getField()); final TermsEnum te = terms.iterator(); PostingsEnum docsEnum = null; for (BytesRef term = te.next(); term != null; term = te.next()) { // use a fixed seed instead of term.hashCode() otherwise this query may return inconsistent results when // running on another replica (StringHelper sets its default seed at startup with current time) int hashCode = StringHelper.murmurhash3_x86_32(term, SEED); if (contains(hashCode)) { docsEnum = te.postings(docsEnum, PostingsEnum.NONE); builder.add(docsEnum); } } return builder.build(); } }
/** * Returns the documents matched by the query, one {@link MatchingDocs} per * visited segment. */ public List<MatchingDocs> getMatchingDocs() { if (docsBuilder != null) { matchingDocs.add(new MatchingDocs(this.context, docsBuilder.build(), totalHits, scores)); docsBuilder = null; scores = null; context = null; } return matchingDocs; }
/** returns a Scorer for INTERSECT queries that uses a sparse bitset */ protected Scorer getIntersectsScorer(XLatLonShapeQuery query, LeafReader reader, Weight weight, DocIdSetBuilder docIdSetBuilder, final float boost) throws IOException { if (values.getDocCount() == reader.maxDoc() && values.getDocCount() == values.size() && cost() > reader.maxDoc() / 2) { // If all docs have exactly one value and the cost is greater // than half the leaf size then maybe we can make things faster // by computing the set of documents that do NOT match the query final FixedBitSet result = new FixedBitSet(reader.maxDoc()); result.set(0, reader.maxDoc()); int[] cost = new int[]{reader.maxDoc()}; values.intersect(getInverseIntersectVisitor(query, result, cost)); final DocIdSetIterator iterator = new BitSetIterator(result, cost[0]); return new ConstantScoreScorer(weight, boost, iterator); } values.intersect(visitor); DocIdSetIterator iterator = docIdSetBuilder.build().iterator(); return new ConstantScoreScorer(weight, boost, iterator); }
return fillDocIdSet ? builder.build() : DocIdSet.EMPTY;
public void flush() throws IOException { if (first == false) { final DocIdSet docIdSet = bucketDocsBuilder.build(); processBucket(queue, context, docIdSet.iterator(), lastBucket, builder); bucketDocsBuilder = null; } } }
public void flush() throws IOException { if (first == false) { final DocIdSet docIdSet = bucketDocsBuilder.build(); processBucket(queue, context, docIdSet.iterator(), lastBucket, builder); bucketDocsBuilder = null; } } }
@Override protected void doSetNextReader(LeafReaderContext context) throws IOException { if (docsBuilder != null) { matchingDocs.add(new MatchingDocs(this.context, docsBuilder.build(), totalHits, scores)); } docsBuilder = new DocIdSetBuilder(context.reader().maxDoc()); totalHits = 0; if (keepScores) { scores = new float[64]; // some initial size } this.context = context; }
/** Optimized intersect which takes the 3D bbox for the query and uses that to avoid filter.compare calls * when cells are clearly outside the bbox. */ public DocIdSet intersect(int xMin, int xMax, int yMin, int yMax, int zMin, int zMax, ValueFilter filter) throws IOException { QueryState state = new QueryState(in.clone(), maxDoc, xMin, xMax, yMin, yMax, zMin, zMax, filter); int hitCount = intersect(state, 1, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE); // NOTE: hitCount is an over-estimate in the multi-valued case: return state.docs.build(hitCount); }