@Override public void collect(int doc) throws IOException { super.collect(doc); if (++numCollected >= numDocsToCollect) { terminatedEarly.set(true); throw new CollectionTerminatedException(); } }
@Override public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException { final List<LeafCollector> leafCollectors = new ArrayList<>(); for (Collector collector : collectors) { final LeafCollector leafCollector; try { leafCollector = collector.getLeafCollector(context); } catch (CollectionTerminatedException e) { // this leaf collector does not need this segment continue; } leafCollectors.add(leafCollector); } switch (leafCollectors.size()) { case 0: throw new CollectionTerminatedException(); case 1: return leafCollectors.get(0); default: return new MultiLeafCollector(leafCollectors, cacheScores); } }
@Override public void collect(int doc) throws IOException { final LeafCollector[] collectors = this.collectors; int numCollectors = this.numCollectors; for (int i = 0; i < numCollectors; ) { final LeafCollector collector = collectors[i]; try { collector.collect(doc); ++i; } catch (CollectionTerminatedException e) { removeCollector(i); numCollectors = this.numCollectors; if (numCollectors == 0) { throw new CollectionTerminatedException(); } } } }
@Override public void visit(int docID, byte[] packedValue) { if (liveDocs.get(docID)) { result[0] = converter.apply(packedValue); // this is the first leaf with a live doc so the value is the minimum for this segment. throw new CollectionTerminatedException(); } }
throw new CollectionTerminatedException(); } else { collectedAllCompetitiveHits = true;
throw new CollectionTerminatedException(); } else { collectedAllCompetitiveHits = true;
@Override public void collect(int doc) throws IOException { if (++numCollected > maxCountHits) { if (forceTermination) { throw new EarlyTerminationException("early termination [CountBased]"); } else { throw new CollectionTerminatedException(); } } super.collect(doc); }; };
@Override public void collect(int docID, CharSequence key, CharSequence context, float score) throws IOException { int globalDoc = docID + docBase; boolean isDuplicate = docContexts.containsKey(globalDoc); List<CharSequence> contexts = docContexts.computeIfAbsent(globalDoc, k -> new ArrayList<>()); if (context != null) { contexts.add(context); } if (isDuplicate) { return; } TopSuggestDocs.SuggestScoreDoc current = new TopSuggestDocs.SuggestScoreDoc(globalDoc, key, context, score); if (current == priorityQueue.insertWithOverflow(current)) { // if the current SuggestScoreDoc has overflown from pq, // we can assume all of the successive collections from // this leaf will be overflown as well // TODO: reuse the overflow instance? throw new CollectionTerminatedException(); } }
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext context) throws IOException { final List<LeafBucketCollector> leafCollectors = new ArrayList<>(); for (BucketCollector collector : collectors) { final LeafBucketCollector leafCollector; try { leafCollector = collector.getLeafCollector(context); } catch (CollectionTerminatedException e) { // this leaf collector does not need this segment continue; } leafCollectors.add(leafCollector); } switch (leafCollectors.size()) { case 0: throw new CollectionTerminatedException(); case 1: return leafCollectors.get(0); default: return new MultiLeafBucketCollector(leafCollectors, cacheScores); } }
@Override public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException { if (numCollected >= maxCountHits) { if (forceTermination) { throw new EarlyTerminationException("early termination [CountBased]"); } else { throw new CollectionTerminatedException(); } } return new FilterLeafCollector(super.getLeafCollector(context)) { @Override public void collect(int doc) throws IOException { if (++numCollected > maxCountHits) { if (forceTermination) { throw new EarlyTerminationException("early termination [CountBased]"); } else { throw new CollectionTerminatedException(); } } super.collect(doc); }; }; } }
@Override public void collect(int doc, long bucket) throws IOException { final LeafBucketCollector[] collectors = this.collectors; int numCollectors = this.numCollectors; for (int i = 0; i < numCollectors; ) { final LeafBucketCollector collector = collectors[i]; try { collector.collect(doc, bucket); ++i; } catch (CollectionTerminatedException e) { removeCollector(i); numCollectors = this.numCollectors; if (numCollectors == 0) { throw new CollectionTerminatedException(); } } } } }
} else { throw new CollectionTerminatedException(); mins.set(0, min); throw new CollectionTerminatedException();
} else { throw new CollectionTerminatedException(); maxes.set(0, max); throw new CollectionTerminatedException();
throw new CollectionTerminatedException(); } else { if (fillDocIdSet) {
@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 collect(int doc) throws IOException { super.collect(doc); if (++numCollected >= numDocsToCollect) { terminatedEarly.set(true); throw new CollectionTerminatedException(); } }
@Override public void collect(int doc) throws IOException { super.collect(doc); if (++numCollected >= numDocsToCollect) { terminatedEarly.set(true); throw new CollectionTerminatedException(); } }
@Override public void collect(int doc) throws IOException { super.collect(doc); if (++numCollected >= numDocsToCollect) { terminatedEarly.set(true); throw new CollectionTerminatedException(); } }
@Override public void collect(int doc) throws IOException { if (++numCollected > maxCountHits) { if (forceTermination) { throw new EarlyTerminationException("early termination [CountBased]"); } else { throw new CollectionTerminatedException(); } } super.collect(doc); }; };
@Override public void collect(int doc) throws IOException { if (++numCollected > maxCountHits) { if (forceTermination) { throw new EarlyTerminationException("early termination [CountBased]"); } else { throw new CollectionTerminatedException(); } } super.collect(doc); }; };