Class LeafBucketCollector
java.lang.Object
org.elasticsearch.search.aggregations.LeafBucketCollector
- All Implemented Interfaces:
org.apache.lucene.search.LeafCollector
- Direct Known Subclasses:
LeafBucketCollectorBase
,ProfilingLeafBucketCollector
public abstract class LeafBucketCollector
extends java.lang.Object
implements org.apache.lucene.search.LeafCollector
Per-leaf bucket collector.
-
Field Summary
Fields Modifier and Type Field Description static LeafBucketCollector
NO_OP_COLLECTOR
-
Constructor Summary
Constructors Constructor Description LeafBucketCollector()
-
Method Summary
Modifier and Type Method Description void
collect(int doc)
abstract void
collect(int doc, long owningBucketOrd)
Collect the givendoc
in the bucket owned byowningBucketOrd
.void
setScorer(org.apache.lucene.search.Scorable scorer)
static LeafBucketCollector
wrap(java.lang.Iterable<LeafBucketCollector> collectors)
-
Field Details
-
Constructor Details
-
LeafBucketCollector
public LeafBucketCollector()
-
-
Method Details
-
wrap
-
collect
public abstract void collect(int doc, long owningBucketOrd) throws java.io.IOExceptionCollect the givendoc
in the bucket owned byowningBucketOrd
.The implementation of this method metric aggregations is generally something along the lines of
array[owningBucketOrd] += loadValueFromDoc(doc)
Bucket aggregations have more trouble because their job is to make new ordinals. So their implementation generally looks kind of like
long myBucketOrd = mapOwningBucketAndValueToMyOrd(owningBucketOrd, loadValueFromDoc(doc)); collectBucket(doc, myBucketOrd);
Some bucket aggregations "know" how many ordinals each owning ordinal needs so they can map "densely". The
range
aggregation, for example, can perform this mapping with something like:
Other aggregations don't know how many buckets will fall into any particular owning bucket. Thereturn rangeCount * owningBucketOrd + matchingRange(value);
terms
aggregation, for example, usesLongKeyedBucketOrds
which amounts to a hash lookup.- Throws:
java.io.IOException
-
collect
public final void collect(int doc) throws java.io.IOException- Specified by:
collect
in interfaceorg.apache.lucene.search.LeafCollector
- Throws:
java.io.IOException
-
setScorer
public void setScorer(org.apache.lucene.search.Scorable scorer) throws java.io.IOException- Specified by:
setScorer
in interfaceorg.apache.lucene.search.LeafCollector
- Throws:
java.io.IOException
-