Class AggregatorBase

All Implemented Interfaces:, java.lang.AutoCloseable,, Releasable
Direct Known Subclasses:
BucketsAggregator, MetricsAggregator, NonCollectingAggregator

public abstract class AggregatorBase
extends Aggregator
Base implementation for concrete aggregators.
  • Field Details

  • Constructor Details

    • AggregatorBase

      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
      Constructs a new Aggregator.
      name - The name of the aggregation
      factories - The factories for all the sub-aggregators under this aggregator
      context - The aggregation context
      parent - The parent aggregator (may be null for top level aggregators)
      metaData - The metaData associated with this aggregator
  • Method Details

    • addRequestCircuitBreakerBytes

      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. 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 bytes
      the cumulative size in bytes allocated by this aggregator to service this request
    • scoreMode

      public scoreMode()
      Most aggregators don't need scores, make sure to extend this method if your aggregator needs them.
    • metaData

      public java.util.Map<java.lang.String,​java.lang.Object> metaData()
    • pipelineAggregators

      public java.util.List<PipelineAggregator> pipelineAggregators()
    • getLeafCollector

      protected abstract LeafBucketCollector getLeafCollector​(org.apache.lucene.index.LeafReaderContext ctx, LeafBucketCollector sub) throws
      Get a LeafBucketCollector for the given ctx, which should delegate to the given collector.
    • getLeafCollector

      public final LeafBucketCollector getLeafCollector​(org.apache.lucene.index.LeafReaderContext ctx) throws
      Specified by:
      getLeafCollector in interface
      Specified by:
      getLeafCollector in class BucketCollector
    • preGetSubLeafCollectors

      protected void preGetSubLeafCollectors() throws
      Can be overridden by aggregator implementations that like the perform an operation before the leaf collectors of children aggregators are instantiated for the next segment.
    • doPreCollection

      protected void doPreCollection() throws
      Can be overridden by aggregator implementation to be called back when the collection phase starts.
    • preCollection

      public final void preCollection() throws
      Description copied from class: BucketCollector
      Pre collection callback.
      Specified by:
      preCollection in class BucketCollector
    • name

      public java.lang.String name()
      Description copied from class: Aggregator
      Return the name of this aggregator.
      Specified by:
      name in class Aggregator
      The name of the aggregation.
    • parent

      public Aggregator parent()
      Description copied from class: Aggregator
      Return the parent aggregator.
      Specified by:
      parent in class Aggregator
      The parent aggregator of this aggregator. The addAggregation are hierarchical in the sense that some can be composed out of others (more specifically, bucket addAggregation can define other addAggregation that will be aggregated per bucket). This method returns the direct parent aggregator that contains this aggregator, or null if there is none (meaning, this aggregator is a top level one)
    • subAggregators

      public Aggregator[] subAggregators()
    • subAggregator

      public Aggregator subAggregator​(java.lang.String aggName)
      Description copied from class: Aggregator
      Return the sub aggregator with the provided name.
      Specified by:
      subAggregator in class Aggregator
    • context

      public SearchContext context()
      Description copied from class: Aggregator
      Return the SearchContext attached with this Aggregator.
      Specified by:
      context in class Aggregator
      The current aggregation context.
    • postCollection

      public final void postCollection() throws
      Called after collection of all document is done.
      Specified by:
      postCollection in class BucketCollector
    • close

      public void close()
      Called upon release of the aggregator.
    • doClose

      protected void doClose()
      Release instance-specific data.
    • doPostCollection

      protected void doPostCollection() throws
      Can be overridden by aggregator implementation to be called back when the collection phase ends.
    • buildEmptySubAggregations

      protected final InternalAggregations buildEmptySubAggregations()
    • toString

      public java.lang.String toString()
      toString in class java.lang.Object