Class AggregationReduceContext

java.lang.Object
org.elasticsearch.search.aggregations.AggregationReduceContext
Direct Known Subclasses:
AggregationReduceContext.ForFinal, AggregationReduceContext.ForPartial

public abstract sealed class AggregationReduceContext extends Object permits AggregationReduceContext.ForPartial, AggregationReduceContext.ForFinal
Dependencies used to reduce aggs.
  • Field Details

  • Method Details

    • transferTopHitsForRelease

      public final void transferTopHitsForRelease(SearchHits searchHits)
      Transfer SearchHits from a top_hits aggregation into this context's release list so they are released when the reduce result is consumed (e.g. by SearchResponse). The caller (e.g. InternalTopHits during reduce) already holds a reference; this method does not incRef. The list owner will decRef when releasing.

      Use this in the aggregation reduce path. For the other path, where hits are registered on QuerySearchResult.registerTopHitsForRelease(org.elasticsearch.search.SearchHits) during the fetch phase, that method takes a new reference because release timings of SearchContext and SearchResponse are not correlated—both paths that touch the hits must keep a ref count.

    • addTopHitsFromAggregationTree

      public final void addTopHitsFromAggregationTree(InternalAggregations aggs, boolean takeRef)
      Append SearchHits from all top_hits aggregations in the given tree to this context's release list. Takes a reference for each so the list owner can decRef on release. Use when the tree was deserialized from stream (e.g. expanded from a MergeResult) so those hits are released.
    • isFinalReduce

      public abstract boolean isFinalReduce()
      Returns true iff the current reduce phase is the final reduce phase. This indicates if operations like pipeline aggregations should be applied or if specific features like minDocCount should be taken into account. Operations that are potentially losing information can only be applied during the final reduce phase.
    • bigArrays

      public final BigArrays bigArrays()
    • scriptService

      public final ScriptService scriptService()
    • isCanceled

      public final Supplier<Boolean> isCanceled()
    • builder

      public AggregationBuilder builder()
      Builder for the agg being processed or null if this context was built for the top level or a pipeline aggregation.
    • pipelineTreeRoot

      public abstract PipelineAggregator.PipelineTree pipelineTreeRoot()
      The root of the tree of pipeline aggregations for this request.
    • consumeBucketsAndMaybeBreak

      public final void consumeBucketsAndMaybeBreak(int size)
      Adds count buckets to the global count for the request and fails if this number is greater than the maximum number of buckets allowed in a response
    • consumeBucketCountAndMaybeBreak

      protected abstract void consumeBucketCountAndMaybeBreak(int size)
    • forAgg

      public final AggregationReduceContext forAgg(String name)
      Build a AggregationReduceContext for a sub-aggregation.
    • forSubAgg

      protected abstract AggregationReduceContext forSubAgg(AggregationBuilder sub)
    • hasBatchedResult

      public boolean hasBatchedResult()
    • setHasBatchedResult

      public void setHasBatchedResult(boolean hasBatchedResult)