Package io.trino.operator.aggregation
Class TypedSet
- java.lang.Object
-
- io.trino.operator.aggregation.TypedSet
-
-
Field Summary
Fields Modifier and Type Field Description static io.airlift.units.DataSizeMAX_FUNCTION_MEMORY
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Block block, int position)Add the value at the givenpositionin the givenblockto this set.booleancontains(Block block, int position)Return whether this set contains the value at the givenpositionin the givenblock.static TypedSetcreateDistinctTypedSet(Type elementType, BlockTypeOperators.BlockPositionIsDistinctFrom elementDistinctFromOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, int expectedSize, String functionName)Create aTypedSetthat compares its elements using the semantics ofIS DISTINCT.static TypedSetcreateDistinctTypedSet(Type elementType, BlockTypeOperators.BlockPositionIsDistinctFrom elementDistinctFromOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, BlockBuilder elementBlock, int expectedSize, String functionName)Create aTypedSetthat compares its elements using the semantics ofIS DISTINCT.static TypedSetcreateEqualityTypedSet(Type elementType, BlockTypeOperators.BlockPositionEqual elementEqualOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, int expectedSize, String functionName)Create aTypedSetthat compares its elements using SQL equality comparison.static TypedSetcreateEqualityTypedSet(Type elementType, BlockTypeOperators.BlockPositionEqual elementEqualOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, BlockBuilder elementBlock, int expectedSize, String functionName)Create aTypedSetthat compares its elements using SQL equality comparison.static TypedSetcreateUnboundedEqualityTypedSet(Type elementType, BlockTypeOperators.BlockPositionEqual elementEqualOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, BlockBuilder elementBlock, int expectedSize, String functionName)Create aTypedSetwith no size limit that compares its elements using SQL equality comparison.longgetRetainedSizeInBytes()Returns the retained size of this block in memory, including over-allocations.intpositionOf(Block block, int position)Return the position in this set'sBlockBuilderof the value at the givenpositionin the givenblock, or -1 if the value is not in this set.intsize()Returns the number of elements in this set.
-
-
-
Method Detail
-
createEqualityTypedSet
public static TypedSet createEqualityTypedSet(Type elementType, BlockTypeOperators.BlockPositionEqual elementEqualOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, int expectedSize, String functionName)
Create aTypedSetthat compares its elements using SQL equality comparison.
-
createEqualityTypedSet
public static TypedSet createEqualityTypedSet(Type elementType, BlockTypeOperators.BlockPositionEqual elementEqualOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, BlockBuilder elementBlock, int expectedSize, String functionName)
Create aTypedSetthat compares its elements using SQL equality comparison.The elements of the set will be written in the given
BlockBuilder. If theBlockBuilderis modified by the caller, the set will stop functioning correctly.
-
createUnboundedEqualityTypedSet
public static TypedSet createUnboundedEqualityTypedSet(Type elementType, BlockTypeOperators.BlockPositionEqual elementEqualOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, BlockBuilder elementBlock, int expectedSize, String functionName)
Create aTypedSetwith no size limit that compares its elements using SQL equality comparison.The elements of the set will be written in the given
BlockBuilder. If theBlockBuilderis modified by the caller, the set will stop functioning correctly.
-
createDistinctTypedSet
public static TypedSet createDistinctTypedSet(Type elementType, BlockTypeOperators.BlockPositionIsDistinctFrom elementDistinctFromOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, int expectedSize, String functionName)
Create aTypedSetthat compares its elements using the semantics ofIS DISTINCT.
-
createDistinctTypedSet
public static TypedSet createDistinctTypedSet(Type elementType, BlockTypeOperators.BlockPositionIsDistinctFrom elementDistinctFromOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, BlockBuilder elementBlock, int expectedSize, String functionName)
Create aTypedSetthat compares its elements using the semantics ofIS DISTINCT.The elements of the set will be written in the given
BlockBuilder. If theBlockBuilderis modified by the caller, the set will stop functioning correctly.
-
getRetainedSizeInBytes
public long getRetainedSizeInBytes()
Returns the retained size of this block in memory, including over-allocations. This method is called from the innermost execution loop and must be fast.
-
contains
public boolean contains(Block block, int position)
Return whether this set contains the value at the givenpositionin the givenblock.
-
add
public boolean add(Block block, int position)
Add the value at the givenpositionin the givenblockto this set.- Returns:
trueif the value was added, orfalseif it was already in this set.
-
size
public int size()
Returns the number of elements in this set.
-
positionOf
public int positionOf(Block block, int position)
Return the position in this set'sBlockBuilderof the value at the givenpositionin the givenblock, or -1 if the value is not in this set.
-
-