Class LeafBucketCollector

All Implemented Interfaces:
Direct Known Subclasses:
LeafBucketCollectorBase, ProfilingLeafBucketCollector

public abstract class LeafBucketCollector
extends java.lang.Object
Per-leaf bucket collector.
  • Field Summary

    Modifier and Type Field Description
    static LeafBucketCollector NO_OP_COLLECTOR  
  • Constructor Summary

    Constructor Description
  • Method Summary

    Modifier and Type Method Description
    void collect​(int doc)  
    abstract void collect​(int doc, long owningBucketOrd)
    Collect the given doc in the bucket owned by owningBucketOrd.
    void setScorer​( scorer)  
    static LeafBucketCollector wrap​(java.lang.Iterable<LeafBucketCollector> collectors)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface

  • Field Details

  • Constructor Details

    • LeafBucketCollector

      public LeafBucketCollector()
  • Method Details

    • wrap

      public static LeafBucketCollector wrap​(java.lang.Iterable<LeafBucketCollector> collectors)
    • collect

      public abstract void collect​(int doc, long owningBucketOrd) throws
      Collect the given doc in the bucket owned by owningBucketOrd.

      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:

       return rangeCount * owningBucketOrd + matchingRange(value);
      Other aggregations don't know how many buckets will fall into any particular owning bucket. The terms aggregation, for example, uses LongKeyedBucketOrds which amounts to a hash lookup.
    • collect

      public final void collect​(int doc) throws
      Specified by:
      collect in interface
    • setScorer

      public void setScorer​( scorer) throws
      Specified by:
      setScorer in interface