public abstract class AggregatorBase extends Aggregator
Aggregator.Parser, Aggregator.SubAggCollectionMode
Modifier and Type | Field and Description |
---|---|
protected BucketCollector |
collectableSubAggregators |
protected SearchContext |
context |
static int |
DEFAULT_WEIGHT
The default "weight" that a bucket takes when performing an aggregation
|
protected java.lang.String |
name |
protected Aggregator |
parent |
protected Aggregator[] |
subAggregators |
NO_OP_COLLECTOR
Modifier | Constructor and Description |
---|---|
protected |
AggregatorBase(java.lang.String name,
AggregatorFactories factories,
SearchContext context,
Aggregator parent,
java.util.List<PipelineAggregator> pipelineAggregators,
java.util.Map<java.lang.String,java.lang.Object> metaData)
Constructs a new Aggregator.
|
Modifier and Type | Method and Description |
---|---|
protected InternalAggregations |
buildEmptySubAggregations() |
void |
close()
Called upon release of the aggregator.
|
SearchContext |
context()
Return the
SearchContext attached with this Aggregator . |
protected void |
doClose()
Release instance-specific data.
|
protected void |
doPostCollection()
Can be overridden by aggregator implementation to be called back when the collection phase ends.
|
protected void |
doPreCollection()
Can be overridden by aggregator implementation to be called back when the collection phase starts.
|
DeferringBucketCollector |
getDeferringCollector() |
LeafBucketCollector |
getLeafCollector(org.apache.lucene.index.LeafReaderContext ctx) |
protected abstract LeafBucketCollector |
getLeafCollector(org.apache.lucene.index.LeafReaderContext ctx,
LeafBucketCollector sub)
Get a
LeafBucketCollector for the given ctx, which should
delegate to the given collector. |
java.util.Map<java.lang.String,java.lang.Object> |
metaData() |
java.lang.String |
name()
Return the name of this aggregator.
|
boolean |
needsScores()
Most aggregators don't need scores, make sure to extend this method if
your aggregator needs them.
|
Aggregator |
parent()
Return the parent aggregator.
|
java.util.List<PipelineAggregator> |
pipelineAggregators() |
void |
postCollection()
Called after collection of all document is done.
|
void |
preCollection()
Pre collection callback.
|
protected void |
runDeferredCollections(long... bucketOrds) |
protected boolean |
shouldDefer(Aggregator aggregator)
This method should be overidden by subclasses that want to defer calculation
of a child aggregation until a first pass is complete and a set of buckets has
been pruned.
|
Aggregator |
subAggregator(java.lang.String aggName)
Return the sub aggregator with the provided name.
|
Aggregator[] |
subAggregators() |
java.lang.String |
toString() |
buildAggregation, buildEmptyAggregation, descendsFromBucketAggregator
wrap
public static final int DEFAULT_WEIGHT
protected final java.lang.String name
protected final Aggregator parent
protected final SearchContext context
protected final Aggregator[] subAggregators
protected BucketCollector collectableSubAggregators
protected AggregatorBase(java.lang.String name, AggregatorFactories factories, SearchContext context, Aggregator parent, java.util.List<PipelineAggregator> pipelineAggregators, java.util.Map<java.lang.String,java.lang.Object> metaData) throws java.io.IOException
name
- The name of the aggregationfactories
- The factories for all the sub-aggregators under this aggregatorcontext
- The aggregation contextparent
- The parent aggregator (may be null
for top level aggregators)metaData
- The metaData associated with this aggregatorjava.io.IOException
public boolean needsScores()
public java.util.Map<java.lang.String,java.lang.Object> metaData()
public java.util.List<PipelineAggregator> pipelineAggregators()
protected abstract LeafBucketCollector getLeafCollector(org.apache.lucene.index.LeafReaderContext ctx, LeafBucketCollector sub) throws java.io.IOException
LeafBucketCollector
for the given ctx, which should
delegate to the given collector.java.io.IOException
public final LeafBucketCollector getLeafCollector(org.apache.lucene.index.LeafReaderContext ctx) throws java.io.IOException
getLeafCollector
in interface org.apache.lucene.search.Collector
getLeafCollector
in class BucketCollector
java.io.IOException
protected void doPreCollection() throws java.io.IOException
java.io.IOException
public final void preCollection() throws java.io.IOException
BucketCollector
preCollection
in class BucketCollector
java.io.IOException
public DeferringBucketCollector getDeferringCollector()
protected boolean shouldDefer(Aggregator aggregator)
runDeferredCollections(long...)
for the selected set of buckets that survive the pruning.aggregator
- the child aggregatorprotected final void runDeferredCollections(long... bucketOrds) throws java.io.IOException
java.io.IOException
public java.lang.String name()
Aggregator
name
in class Aggregator
public Aggregator parent()
Aggregator
parent
in class Aggregator
null
if there is none (meaning, this aggregator is a top level one)public Aggregator[] subAggregators()
public Aggregator subAggregator(java.lang.String aggName)
Aggregator
subAggregator
in class Aggregator
public SearchContext context()
Aggregator
SearchContext
attached with this Aggregator
.context
in class Aggregator
public final void postCollection() throws java.io.IOException
postCollection
in class BucketCollector
java.io.IOException
public void close()
protected void doClose()
protected void doPostCollection() throws java.io.IOException
java.io.IOException
protected final InternalAggregations buildEmptySubAggregations()
public java.lang.String toString()
toString
in class java.lang.Object