Java 类org.apache.lucene.search.LeafCollector 实例源码

项目:solrplugins    文件:SimpleFacets.java   
private Collector getInsanityWrapper(final String field, Collector collector) {
  SchemaField sf = searcher.getSchema().getFieldOrNull(field);
  if (sf != null && !sf.hasDocValues() && !sf.multiValued() && sf.getType().getNumberType() != null) {
    // it's a single-valued numeric field: we must currently create insanity :(
    // there isn't a GroupedFacetCollector that works on numerics right now...
    return new FilterCollector(collector) {
      @Override
      public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
        LeafReader insane = Insanity.wrapInsanity(context.reader(), field);
        return in.getLeafCollector(insane.getContext());
      }
    };
  } else {
    return collector;
  }
}
项目:lucene-search-plugin    文件:DistinctCollector.java   
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
    return new LeafCollector() {

        // ignore scorer
        public void setScorer(Scorer scorer) throws IOException {
        }

        public void collect(int doc) throws IOException {
            Document document = searcher.doc(doc, field);
            String fieldValue = document.get(fieldName);
            addData(fieldValue);
        }

    };
}
项目:elasticsearch_my    文件:CancellableCollector.java   
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
    if (cancelled.get()) {
        throw new TaskCancelledException("cancelled");
    }
    if (leafLevel) {
        return new CancellableLeafCollector(super.getLeafCollector(context));
    } else {
        return super.getLeafCollector(context);
    }
}
项目:elasticsearch_my    文件:FilteredCollector.java   
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
    final Scorer filterScorer = filter.scorer(context);
    final LeafCollector in = collector.getLeafCollector(context);
    final Bits bits = Lucene.asSequentialAccessBits(context.reader().maxDoc(), filterScorer);

    return new FilterLeafCollector(in) {
        @Override
        public void collect(int doc) throws IOException {
            if (bits.get(doc)) {
                in.collect(doc);
            }
        }
    };
}
项目:elasticsearch_my    文件:SearchCancellationTests.java   
public void testLowLevelCancellableCollector() throws IOException {
    TotalHitCountCollector collector = new TotalHitCountCollector();
    AtomicBoolean cancelled = new AtomicBoolean();
    CancellableCollector cancellableCollector = new CancellableCollector(cancelled::get, true, collector);
    final LeafCollector leafCollector = cancellableCollector.getLeafCollector(reader.leaves().get(0));
    leafCollector.collect(0);
    cancelled.set(true);
    expectThrows(TaskCancelledException.class, () -> leafCollector.collect(1));
}
项目:elasticsearch_my    文件:SearchCancellationTests.java   
public void testCancellableCollector() throws IOException {
    TotalHitCountCollector collector = new TotalHitCountCollector();
    AtomicBoolean cancelled = new AtomicBoolean();
    CancellableCollector cancellableCollector = new CancellableCollector(cancelled::get, false, collector);
    final LeafCollector leafCollector = cancellableCollector.getLeafCollector(reader.leaves().get(0));
    leafCollector.collect(0);
    cancelled.set(true);
    leafCollector.collect(1);
    expectThrows(TaskCancelledException.class, () -> cancellableCollector.getLeafCollector(reader.leaves().get(1)));
}
项目:elasticsearch_my    文件:QueryProfilerTests.java   
public void testCollector() throws IOException {
    TotalHitCountCollector collector = new TotalHitCountCollector();
    ProfileCollector profileCollector = new ProfileCollector(collector);
    assertEquals(0, profileCollector.getTime());
    final LeafCollector leafCollector = profileCollector.getLeafCollector(reader.leaves().get(0));
    assertThat(profileCollector.getTime(), greaterThan(0L));
    long time = profileCollector.getTime();
    leafCollector.setScorer(null);
    assertThat(profileCollector.getTime(), greaterThan(time));
    time = profileCollector.getTime();
    leafCollector.collect(0);
    assertThat(profileCollector.getTime(), greaterThan(time));
}
项目:Elasticsearch    文件:ParentQuery.java   
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
    final SortedDocValues values = globalIfd.load(context).getOrdinalsValues(parentType);
    if (values == null) {
        throw new CollectionTerminatedException();
    }
    return new LeafCollector() {
        Scorer scorer;
        @Override
        public void setScorer(Scorer scorer) throws IOException {
            this.scorer = scorer;
        }
        @Override
        public void collect(int doc) throws IOException {
            long globalOrdinal = values.getOrd(doc);
            if (globalOrdinal != SortedSetDocValues.NO_MORE_ORDS) {
                long parentIdx = parentIdxs.add(globalOrdinal);
                if (parentIdx >= 0) {
                    scores = bigArrays.grow(scores, parentIdx + 1);
                    scores.set(parentIdx, scorer.score());
                } else {
                    assert false : "parent id should only match once, since there can only be one parent doc";
                }
            }
        }
    };
}
项目:Elasticsearch    文件:FilteredCollector.java   
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
    final Scorer filterScorer = filter.scorer(context);
    final LeafCollector in = collector.getLeafCollector(context);
    final Bits bits = Lucene.asSequentialAccessBits(context.reader().maxDoc(), filterScorer);

    return new FilterLeafCollector(in) {
        @Override
        public void collect(int doc) throws IOException {
            if (bits.get(doc)) {
                in.collect(doc);
            }
        }
    };
}
项目:elasticsearch_my    文件:CancellableCollector.java   
private CancellableLeafCollector(LeafCollector in) {
    super(in);
}
项目:elasticsearch_my    文件:InternalProfileCollector.java   
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
    return collector.getLeafCollector(context);
}
项目:Elasticsearch    文件:InternalProfileCollector.java   
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
    return collector.getLeafCollector(context);
}
项目:LuceneDB    文件:ExactCollector.java   
@Override
public LeafCollector getLeafCollector(
        LeafReaderContext paramLeafReaderContext) throws IOException {
    return this;
}