List of usage examples for org.apache.lucene.search CollectionTerminatedException CollectionTerminatedException
public CollectionTerminatedException()
From source file:com.b2international.index.lucene.AbstractDocsOutOfOrderCollector.java
License:Apache License
@Override public final void doSetNextReader(final LeafReaderContext context) throws IOException { initDocValues(context.reader());/*w w w . j a v a 2 s . c o m*/ if (!isLeafCollectible()) { throw new CollectionTerminatedException(); } }
From source file:io.crate.operation.collect.files.FileReadingCollector.java
License:Apache License
@Override public void doCollect() throws IOException, CollectionTerminatedException { FileInput fileInput = getFileInput(); if (fileInput == null) { if (downstream != null) { downstream.upstreamFinished(); }/*w w w . ja v a 2 s . c om*/ return; } Predicate<URI> uriPredicate = generateUriPredicate(fileInput); CollectorContext collectorContext = new CollectorContext(); for (LineCollectorExpression<?> collectorExpression : collectorExpressions) { collectorExpression.startCollect(collectorContext); } Object[] newRow; String line; List<URI> uris; uris = getUris(fileInput, uriPredicate); try { for (URI uri : uris) { InputStream inputStream = fileInput.getStream(uri); if (inputStream == null) { continue; } BufferedReader reader; reader = createReader(inputStream); try { while ((line = reader.readLine()) != null) { collectorContext.lineContext().rawSource(line.getBytes()); newRow = new Object[inputs.size()]; for (LineCollectorExpression expression : collectorExpressions) { expression.setNextLine(line); } int i = 0; for (Input<?> input : inputs) { newRow[i++] = input.value(); } if (!downstream.setNextRow(newRow)) { throw new CollectionTerminatedException(); } } } finally { reader.close(); } } } finally { downstream.upstreamFinished(); } }
From source file:io.crate.operation.collect.LuceneDocCollector.java
License:Apache License
@Override public void collect(int doc) throws IOException { Object[] newRow = new Object[topLevelInputs.size()]; if (visitorEnabled) { fieldsVisitor.reset();/*from www. jav a 2 s .c o m*/ currentReader.document(doc, fieldsVisitor); } for (LuceneCollectorExpression e : collectorExpressions) { e.setNextDocId(doc); } int i = 0; for (Input<?> input : topLevelInputs) { newRow[i++] = input.value(); } if (!downstream.setNextRow(newRow)) { // no more rows required, we can stop here throw new CollectionTerminatedException(); } }
From source file:org.apache.solr.search.EarlyTerminatingSortingCollector.java
License:Apache License
@Override public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException { Sort segmentSort = context.reader().getMetaData().getSort(); if (segmentSort != null && canEarlyTerminate(sort, segmentSort) == false) { throw new IllegalStateException("Cannot early terminate with sort order " + sort + " if segments are sorted with " + segmentSort); }// w w w.j av a 2 s . co m if (segmentSort != null) { // segment is sorted, can early-terminate return new FilterLeafCollector(super.getLeafCollector(context)) { private int numCollected; @Override public void collect(int doc) throws IOException { super.collect(doc); if (++numCollected >= numDocsToCollect) { terminatedEarly.set(true); throw new CollectionTerminatedException(); } } }; } else { return super.getLeafCollector(context); } }
From source file:org.elasticsearch.search.aggregations.bucket.composite.CompositeAggregator.java
License:Apache License
@Override protected LeafBucketCollector getLeafCollector(LeafReaderContext ctx, LeafBucketCollector sub) throws IOException { finishLeaf();/* w w w . j a v a2s . c om*/ boolean fillDocIdSet = deferredCollectors != NO_OP_COLLECTOR; if (sortedDocsProducer != null) { /** * The producer will visit documents sorted by the leading source of the composite definition * and terminates when the leading source value is guaranteed to be greater than the lowest * composite bucket in the queue. */ DocIdSet docIdSet = sortedDocsProducer.processLeaf(context.query(), queue, ctx, fillDocIdSet); if (fillDocIdSet) { entries.add(new Entry(ctx, docIdSet)); } /** * We can bypass search entirely for this segment, all the processing has been done in the previous call. * Throwing this exception will terminate the execution of the search for this root aggregation, * see {@link MultiCollector} for more details on how we handle early termination in aggregations. */ throw new CollectionTerminatedException(); } else { if (fillDocIdSet) { currentLeaf = ctx; docIdSetBuilder = new RoaringDocIdSet.Builder(ctx.reader().maxDoc()); } final LeafBucketCollector inner = queue.getLeafCollector(ctx, getFirstPassCollector(docIdSetBuilder)); return new LeafBucketCollector() { @Override public void collect(int doc, long zeroBucket) throws IOException { assert zeroBucket == 0L; inner.collect(doc); } }; } }
From source file:org.elasticsearch.search.query.EarlyTerminatingCollector.java
License:Apache License
@Override public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException { if (numCollected >= maxCountHits) { throw new CollectionTerminatedException(); }//from w w w . j a v a 2 s . c om return new FilterLeafCollector(super.getLeafCollector(context)) { @Override public void collect(int doc) throws IOException { super.collect(doc); if (++numCollected >= maxCountHits) { terminatedEarly = true; throw new CollectionTerminatedException(); } }; }; }
From source file:org.meresco.oai.OaiSortingCollector.java
License:Open Source License
@Override public void collect(int doc) throws IOException { long stamp = this.stamps.get(doc); if (stamp < this.start) return;/* ww w. j ava 2 s . c o m*/ if (stamp > this.stop) throw new CollectionTerminatedException(); this.hitCount++; if (this.hitCount > this.maxDocsToCollect) { this.moreRecordsAvailable = true; } if (delegateTerminated) { return; } try { this.earlyCollector.collect(doc); } catch (CollectionTerminatedException e) { delegateTerminated = true; if (!this.shouldCountHits) { throw e; } } }
From source file:org.meresco.oai.OaiSortingCollector.java
License:Open Source License
@Override public void setNextReader(AtomicReaderContext context) throws IOException { AtomicReader reader = context.reader(); this.stamps = reader.getNumericDocValues("numeric_stamp"); long lastStamp = this.stamps.get(reader.maxDoc() - 1); if (lastStamp < this.start || this.stop < this.stamps.get(0)) throw new CollectionTerminatedException(); this.delegateTerminated = false; this.earlyCollector.setNextReader(context); }
From source file:org.neo4j.kernel.api.impl.index.collector.FirstHitCollector.java
License:Open Source License
@Override public void collect(int doc) throws IOException { result = readerDocBase + doc;/*from ww w. j a v a 2 s . c o m*/ throw new CollectionTerminatedException(); }
From source file:org.neo4j.kernel.api.impl.index.FirstHitCollector.java
License:Open Source License
@Override public void collect(int doc) throws IOException { result = doc;//from w ww.j a v a 2 s . co m throw new CollectionTerminatedException(); }