@Override public void grow(int count) { adder = result.grow(count); }
@Override public void grow(int count) { adder = result.grow(count); }
/** * Add the content of the provided {@link DocIdSetIterator} to this builder. * NOTE: if you need to build a {@link DocIdSet} out of a single * {@link DocIdSetIterator}, you should rather use {@link RoaringDocIdSet.Builder}. */ public void add(DocIdSetIterator iter) throws IOException { if (bitSet != null) { bitSet.or(iter); return; } int cost = (int) Math.min(Integer.MAX_VALUE, iter.cost()); BulkAdder adder = grow(cost); for (int i = 0; i < cost; ++i) { int doc = iter.nextDoc(); if (doc == DocIdSetIterator.NO_MORE_DOCS) { return; } adder.add(doc); } for (int doc = iter.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iter.nextDoc()) { grow(1).add(doc); } }
@Override public void grow(int count) { remaining = count; adder = bucketDocsBuilder.grow(count); }
@Override public void collect(int doc, long bucket) throws IOException { hasCollected[0] = true; int slot = queue.addIfCompetitive(); if (slot != -1) { topCompositeCollected[0]++; if (adder != null && doc != lastDoc) { if (remainingBits == 0) { // the cost approximation was lower than the real size, we need to grow the adder // by some numbers (128) to ensure that we can add the extra documents adder = builder.grow(128); remainingBits = 128; } adder.add(doc); remainingBits --; lastDoc = doc; } } } };
@Override public void grow(int count) { remaining = count; adder = bucketDocsBuilder.grow(count); }
@Override public void grow(int count) { remaining = count; adder = bucketDocsBuilder.grow(count); }
@Override public void grow(int count) { adder = result.grow(count); }
@Override public void grow(int count) { adder = hits.grow(count); }
@Override public void grow(int count) { adder = result.grow(count); }
@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 --; }
DocIdSetBuilder.BulkAdder adder = builder == null ? null : builder.grow(remainingBits);
@Override public final void collect(int doc) throws IOException { docsBuilder.grow(1).add(doc); if (keepScores) { if (totalHits >= scores.length) { float[] newScores = new float[ArrayUtil.oversize(totalHits + 1, 4)]; System.arraycopy(scores, 0, newScores, 0, totalHits); scores = newScores; } scores[totalHits] = scorer.score(); } totalHits++; }
@Override public void collect(int doc, long bucket) throws IOException { hasCollected[0] = true; int slot = queue.addIfCompetitive(); if (slot != -1) { topCompositeCollected[0]++; if (adder != null && doc != lastDoc) { if (remainingBits == 0) { // the cost approximation was lower than the real size, we need to grow the adder // by some numbers (128) to ensure that we can add the extra documents adder = builder.grow(128); remainingBits = 128; } adder.add(doc); remainingBits --; lastDoc = doc; } } } };
@Override public void collect(int doc, long bucket) throws IOException { hasCollected[0] = true; int slot = queue.addIfCompetitive(); if (slot != -1) { topCompositeCollected[0]++; if (adder != null && doc != lastDoc) { if (remainingBits == 0) { // the cost approximation was lower than the real size, we need to grow the adder // by some numbers (128) to ensure that we can add the extra documents adder = builder.grow(128); remainingBits = 128; } adder.add(doc); remainingBits --; lastDoc = doc; } } } };
/** Adds all docs from the current block. */ private int addAll(QueryState state) throws IOException { // How many values are stored in this leaf cell: int count = state.in.readVInt(); state.docs.grow(count); for(int i=0;i<count;i++) { int docID = state.in.readInt(); state.docs.add(docID); } return count; }
/** * Add the content of the provided {@link DocIdSetIterator} to this builder. * NOTE: if you need to build a {@link DocIdSet} out of a single * {@link DocIdSetIterator}, you should rather use {@link RoaringDocIdSet.Builder}. */ public void add(DocIdSetIterator iter) throws IOException { if (bitSet != null) { bitSet.or(iter); return; } int cost = (int) Math.min(Integer.MAX_VALUE, iter.cost()); BulkAdder adder = grow(cost); for (int i = 0; i < cost; ++i) { int doc = iter.nextDoc(); if (doc == DocIdSetIterator.NO_MORE_DOCS) { return; } adder.add(doc); } for (int doc = iter.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iter.nextDoc()) { grow(1).add(doc); } }
/** Adds docs from the current block, filtering each hit against the query min/max. This * is only needed on the boundary blocks. */ private int addSome(QueryState state) throws IOException { int hitCount = 0; // How many points are stored in this leaf cell: int count = state.in.readVInt(); state.docs.grow(count); for(int i=0;i<count;i++) { int docID = state.in.readInt(); state.sndv.setDocument(docID); // How many values this doc has: int docValueCount = state.sndv.count(); for(int j=0;j<docValueCount;j++) { long value = state.sndv.valueAt(j); if (value >= state.minValueIncl && value <= state.maxValueIncl) { state.docs.add(docID); hitCount++; // Stop processing values for this doc: break; } } } return hitCount; }
@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 --; }
@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 --; }