Class AggregatorAdapters
- java.lang.Object
-
- org.apache.druid.query.aggregation.AggregatorAdapters
-
public class AggregatorAdapters extends Object
A class that helps query engines use Buffer- or VectorAggregators in a consistent way. The two main benefits this class provides are: (1) Query engines can treat BufferAggregators and VectorAggregators the same for operations that are equivalent across them, like "init", "get", "relocate", and "close". (2) Query engines are freed from the need to manage how much space each individual aggregator needs. They only need to allocate a block of size "spaceNeeded".
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaggregateBuffered(ByteBuffer buf, int position)CallBufferAggregator.aggregate(ByteBuffer, int)on all of our aggregators.voidaggregateVector(ByteBuffer buf, int numRows, int[] positions, int[] rows)CallVectorAggregator.aggregate(ByteBuffer, int, int[], int[], int)on all of our aggregators.voidaggregateVector(ByteBuffer buf, int position, int start, int end)CallVectorAggregator.aggregate(ByteBuffer, int, int, int)on all of our aggregators.int[]aggregatorPositions()Return the individual positions of each aggregator within a hypothetical buffer of sizespaceNeeded().List<AggregatorFactory>factories()Return theAggregatorFactoryobjects that were used to create this object.static AggregatorAdaptersfactorizeBuffered(ColumnSelectorFactory columnSelectorFactory, List<AggregatorFactory> aggregatorFactories)Create an adapters object based onBufferAggregator.static AggregatorAdaptersfactorizeVector(VectorColumnSelectorFactory columnSelectorFactory, List<AggregatorFactory> aggregatorFactories)Create an adapters object based onVectorAggregator.Objectget(ByteBuffer buf, int position, int aggregatorNumber)Retrieve aggregation state from one of our aggregators.voidinit(ByteBuffer buf, int position)Initialize all aggregators.voidrelocate(int oldPosition, int newPosition, ByteBuffer oldBuffer, ByteBuffer newBuffer)Inform all of our aggregators that they are being relocated.voidreset()Reset all of our aggregators, releasing resources held by them.intsize()Return the number of aggregators in this object.intspaceNeeded()Return the amount of buffer bytes needed by all aggregators wrapped up in this object.
-
-
-
Method Detail
-
factorizeVector
public static AggregatorAdapters factorizeVector(VectorColumnSelectorFactory columnSelectorFactory, List<AggregatorFactory> aggregatorFactories)
Create an adapters object based onVectorAggregator.
-
factorizeBuffered
public static AggregatorAdapters factorizeBuffered(ColumnSelectorFactory columnSelectorFactory, List<AggregatorFactory> aggregatorFactories)
Create an adapters object based onBufferAggregator.
-
spaceNeeded
public int spaceNeeded()
Return the amount of buffer bytes needed by all aggregators wrapped up in this object.
-
factories
public List<AggregatorFactory> factories()
Return theAggregatorFactoryobjects that were used to create this object.
-
aggregatorPositions
public int[] aggregatorPositions()
Return the individual positions of each aggregator within a hypothetical buffer of sizespaceNeeded().
-
size
public int size()
Return the number of aggregators in this object.
-
init
public void init(ByteBuffer buf, int position)
Initialize all aggregators.- Parameters:
buf- aggregation bufferposition- position in buffer where our block of sizespaceNeeded()starts
-
aggregateBuffered
public void aggregateBuffered(ByteBuffer buf, int position)
CallBufferAggregator.aggregate(ByteBuffer, int)on all of our aggregators. This method is only valid if the underlying aggregators areBufferAggregator.
-
aggregateVector
public void aggregateVector(ByteBuffer buf, int position, int start, int end)
CallVectorAggregator.aggregate(ByteBuffer, int, int, int)on all of our aggregators. This method is only valid if the underlying aggregators areVectorAggregator.
-
aggregateVector
public void aggregateVector(ByteBuffer buf, int numRows, int[] positions, @Nullable int[] rows)
CallVectorAggregator.aggregate(ByteBuffer, int, int[], int[], int)on all of our aggregators. This method is only valid if the underlying aggregators areVectorAggregator.
-
get
@Nullable public Object get(ByteBuffer buf, int position, int aggregatorNumber)
Retrieve aggregation state from one of our aggregators.- Parameters:
buf- aggregation bufferposition- position in buffer where our block of sizespaceNeeded()startsaggregatorNumber- which aggregator to retrieve state, from 0 tosize()- 1
-
relocate
public void relocate(int oldPosition, int newPosition, ByteBuffer oldBuffer, ByteBuffer newBuffer)Inform all of our aggregators that they are being relocated.
-
reset
public void reset()
Reset all of our aggregators, releasing resources held by them. After this, this instance may be reused or it may be discarded.
-
-