Class GroupedTypedHistogram
java.lang.Object
io.trino.operator.aggregation.histogram.GroupedTypedHistogram
- All Implemented Interfaces:
TypedHistogram
implementation that uses groupId in the hash key, so that we may store all groupId x value -> count in one giant map. The value, however,
is normalized into a single ValueBuilder. Further, we do not have per-group instances of objects. In order to construct a histogram for a group on
demand, a linked list for each group is stored that overlays all virtual nodes (a shared index, i, across parallel arrays).
eg, heads[100] -> 3 means the first piece of data is (values[valuePositions[3]], counts[3]) If next[3] is 10, then we look at (values[valuePositions[10]], counts[10]) and so on to construct the value, count pairs needed. An iterator-style function, readAllValues, exists and the caller may do whatever want with the values.
-
Constructor Summary
ConstructorsConstructorDescriptionGroupedTypedHistogram(long groupId, Block block, Type type, BlockTypeOperators.BlockPositionEqual equalOperator, BlockTypeOperators.BlockPositionHashCode hashCodeOperator, int bucketId) TODO: use RowBlock in the futureGroupedTypedHistogram(Type type, BlockTypeOperators.BlockPositionEqual equalOperator, BlockTypeOperators.BlockPositionHashCode hashCodeOperator, int expectedCount) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddAll(TypedHistogram other) voidensureCapacity(long size) longintgetType()booleanisEmpty()voidreadAllValues(HistogramValueReader reader) voidserialize(BlockBuilder out) setGroupId(long groupId)
-
Constructor Details
-
GroupedTypedHistogram
public GroupedTypedHistogram(Type type, BlockTypeOperators.BlockPositionEqual equalOperator, BlockTypeOperators.BlockPositionHashCode hashCodeOperator, int expectedCount) -
GroupedTypedHistogram
public GroupedTypedHistogram(long groupId, Block block, Type type, BlockTypeOperators.BlockPositionEqual equalOperator, BlockTypeOperators.BlockPositionHashCode hashCodeOperator, int bucketId) TODO: use RowBlock in the future- Parameters:
block- of the form [key1, count1, key2, count2, ...]
-
-
Method Details
-
ensureCapacity
public void ensureCapacity(long size) - Specified by:
ensureCapacityin interfaceTypedHistogram
-
getEstimatedSize
public long getEstimatedSize()- Specified by:
getEstimatedSizein interfaceTypedHistogram
-
serialize
- Specified by:
serializein interfaceTypedHistogram
-
addAll
- Specified by:
addAllin interfaceTypedHistogram
-
readAllValues
- Specified by:
readAllValuesin interfaceTypedHistogram
-
setGroupId
- Specified by:
setGroupIdin interfaceTypedHistogram
-
getType
- Specified by:
getTypein interfaceTypedHistogram
-
getExpectedSize
public int getExpectedSize()- Specified by:
getExpectedSizein interfaceTypedHistogram
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceTypedHistogram
-
add
- Specified by:
addin interfaceTypedHistogram
-