Class AggregatorAdapters
- java.lang.Object
-
- org.apache.druid.query.aggregation.AggregatorAdapters
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class AggregatorAdapters extends Object implements Closeable
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 void
aggregateBuffered(ByteBuffer buf, int position)
CallBufferAggregator.aggregate(ByteBuffer, int)
on all of our aggregators.void
aggregateVector(ByteBuffer buf, int numRows, int[] positions, int[] rows)
CallVectorAggregator.aggregate(ByteBuffer, int, int[], int[], int)
on all of our aggregators.void
aggregateVector(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()
.void
close()
Close all of our aggregators.List<AggregatorFactory>
factories()
Return theAggregatorFactory
objects that were used to create this object.static AggregatorAdapters
factorizeBuffered(ColumnSelectorFactory columnSelectorFactory, List<AggregatorFactory> aggregatorFactories)
Create an adapters object based onBufferAggregator
.static AggregatorAdapters
factorizeVector(VectorColumnSelectorFactory columnSelectorFactory, List<AggregatorFactory> aggregatorFactories)
Create an adapters object based onVectorAggregator
.Object
get(ByteBuffer buf, int position, int aggregatorNumber)
Retrieve aggregation state from one of our aggregators.void
init(ByteBuffer buf, int position)
Initialize all aggregators.void
relocate(int oldPosition, int newPosition, ByteBuffer oldBuffer, ByteBuffer newBuffer)
Inform all of our aggregators that they are being relocated.int
size()
Return the number of aggregators in this object.int
spaceNeeded()
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 theAggregatorFactory
objects 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.
-
close
public void close()
Close all of our aggregators.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-