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 long |
addRequestCircuitBreakerBytes(long bytes)
Increment or decrement the number of bytes that have been allocated to service
this request and potentially trigger a
CircuitBreakingException . |
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.
|
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.
|
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
protected long addRequestCircuitBreakerBytes(long bytes)
CircuitBreakingException
. The
number of bytes allocated is automatically decremented with the circuit breaker
service on closure of this aggregator.
If memory has been returned, decrement it without tripping the breaker.
For performance reasons subclasses should not call this millions of times
each with small increments and instead batch up into larger allocations.bytes
- the number of bytes to register or negative to deregister the bytespublic 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 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