Class NullableNumericVectorAggregator

java.lang.Object
org.apache.druid.query.aggregation.NullableNumericVectorAggregator
All Implemented Interfaces:
VectorAggregator

public class NullableNumericVectorAggregator extends Object implements VectorAggregator
A wrapper around a non-null-aware VectorAggregator that makes it null-aware. This removes the need for each aggregator class to handle nulls on its own. This class only makes sense as a wrapper for "primitive" aggregators, i.e., ones that take VectorValueSelector as input. The result of this aggregator will be null if all the values to be aggregated are null values or no values are aggregated at all. If any of the values are non-null, the result will be the aggregated value of the delegate aggregator. When wrapped by this class, the underlying aggregator's required storage space is increased by one byte. The extra byte is a boolean that stores whether or not any non-null values have been seen. The extra byte is placed before the underlying aggregator's normal state. (Buffer layout = [nullability byte] [delegate storage bytes]) The result of a NullableAggregator will be null if all the values to be aggregated are null values or no values are aggregated at all. If any of the value is non-null, the result would be the aggregated value of the delegate aggregator. Note that the delegate aggregator is not required to perform check for VectorValueSelector.getNullVector() on the selector as only non-null values will be passed to the delegate aggregator. This class is only used when SQL compatible null handling is enabled.
See Also:
  • Method Details

    • init

      public void init(ByteBuffer buf, int position)
      Description copied from interface: VectorAggregator
      Specified by:
      init in interface VectorAggregator
    • aggregate

      public void aggregate(ByteBuffer buf, int position, int startRow, int endRow)
      Description copied from interface: VectorAggregator
      Aggregate a range of rows into a single aggregation slot. Implementations must not change the position, limit or mark of the given buffer
      Specified by:
      aggregate in interface VectorAggregator
      Parameters:
      buf - byte buffer storing the byte array representation of the aggregate
      position - offset within the byte buffer at which the current aggregate value is stored
      startRow - first row of the range within the current batch to aggregate (inclusive)
      endRow - end row of the range (exclusive)
    • aggregate

      public void aggregate(ByteBuffer buf, int numRows, int[] positions, @Nullable int[] rows, int positionOffset)
      Description copied from interface: VectorAggregator
      Aggregate a list of rows ("rows") into a list of aggregation slots ("positions"). Implementations must not change the position, limit or mark of the given buffer
      Specified by:
      aggregate in interface VectorAggregator
      Parameters:
      buf - byte buffer storing the byte array representation of the aggregate
      numRows - number of rows to aggregate
      positions - array of aggregate value positions within the buffer; must be at least as long as "numRows"
      rows - array of row numbers within the current row batch; must be at least as long as "numRows". If null, the aggregator will aggregate rows from 0 (inclusive) to numRows (exclusive).
      positionOffset - an offset to apply to each value from "positions"
    • get

      @Nullable public Object get(ByteBuffer buf, int position)
      Description copied from interface: VectorAggregator
      Specified by:
      get in interface VectorAggregator
    • relocate

      public void relocate(int oldPosition, int newPosition, ByteBuffer oldBuffer, ByteBuffer newBuffer)
      Description copied from interface: VectorAggregator
      Specified by:
      relocate in interface VectorAggregator
    • close

      public void close()
      Description copied from interface: VectorAggregator
      Release any resources used by the aggregator. The aggregator may be reused after this call, by calling VectorAggregator.init(ByteBuffer, int) followed by other methods as normal. This call would be more properly named "reset", but we use the name "close" to improve compatibility with existing aggregator implementations in extensions.
      Specified by:
      close in interface VectorAggregator