Package io.trino.operator.scalar
Class BlockSet
java.lang.Object
io.trino.operator.scalar.BlockSet
A set of values stored in preexisting blocks. The data is not copied out of the
blocks, and instead a direct reference is kept. This means that all data in a block
is retained (including non-distinct values), so this works best when processing
preexisting blocks in a single code block. Care should be taken when using this
across multiple calls, as the memory will not be freed until the BlockSet is freed.
BlockSet does not support rehashing, so the maximum size must be known up front.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBlockSet(Type elementType, BlockTypeOperators.BlockPositionIsDistinctFrom elementDistinctFromOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, int maximumSize) -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd the value to this set.booleanDoes this set contain the value?booleanReturns whether this set contains a NULL elementvoidgetAllWithSizeLimit(BlockBuilder blockBuilder, String functionName, io.airlift.units.DataSize maxFunctionMemory) Writes all values to the block builder checking the memory limit after each element is added.intpositionOf(Block block, int position) Return the position of the value within this set, or -1 if the value is not in this set.intsize()Returns the number of elements in this set.
-
Field Details
-
MAX_FUNCTION_MEMORY
public static final io.airlift.units.DataSize MAX_FUNCTION_MEMORY
-
-
Constructor Details
-
BlockSet
public BlockSet(Type elementType, BlockTypeOperators.BlockPositionIsDistinctFrom elementDistinctFromOperator, BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator, int maximumSize)
-
-
Method Details
-
contains
Does this set contain the value? -
add
Add the value to 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. -
containsNullElement
public boolean containsNullElement()Returns whether this set contains a NULL element -
positionOf
Return the position of the value within this set, or -1 if the value is not in this set. This method can not get the position of a null value, and an exception will be thrown in that case.- Throws:
IllegalArgumentException- if the position is null
-
getAllWithSizeLimit
public void getAllWithSizeLimit(BlockBuilder blockBuilder, String functionName, io.airlift.units.DataSize maxFunctionMemory) Writes all values to the block builder checking the memory limit after each element is added.
-