Class GroupedTypedHistogram
- java.lang.Object
-
- io.trino.operator.aggregation.histogram.GroupedTypedHistogram
-
- All Implemented Interfaces:
TypedHistogram
public class GroupedTypedHistogram extends Object implements 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
Constructors Constructor Description GroupedTypedHistogram(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int position, Block block, long count)voidaddAll(TypedHistogram other)voidensureCapacity(long size)longgetEstimatedSize()intgetExpectedSize()TypegetType()booleanisEmpty()voidreadAllValues(HistogramValueReader reader)voidserialize(BlockBuilder out)TypedHistogramsetGroupId(long groupId)
-
-
-
Constructor Detail
-
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 Detail
-
ensureCapacity
public void ensureCapacity(long size)
- Specified by:
ensureCapacityin interfaceTypedHistogram
-
getEstimatedSize
public long getEstimatedSize()
- Specified by:
getEstimatedSizein interfaceTypedHistogram
-
serialize
public void serialize(BlockBuilder out)
- Specified by:
serializein interfaceTypedHistogram
-
addAll
public void addAll(TypedHistogram other)
- Specified by:
addAllin interfaceTypedHistogram
-
readAllValues
public void readAllValues(HistogramValueReader reader)
- Specified by:
readAllValuesin interfaceTypedHistogram
-
setGroupId
public TypedHistogram setGroupId(long groupId)
- Specified by:
setGroupIdin interfaceTypedHistogram
-
getType
public Type getType()
- Specified by:
getTypein interfaceTypedHistogram
-
getExpectedSize
public int getExpectedSize()
- Specified by:
getExpectedSizein interfaceTypedHistogram
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceTypedHistogram
-
add
public void add(int position, Block block, long count)- Specified by:
addin interfaceTypedHistogram
-
-