Class BlockSet

java.lang.Object
io.trino.operator.scalar.BlockSet

public class BlockSet extends Object
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 Details

    • MAX_FUNCTION_MEMORY

      public static final io.airlift.units.DataSize MAX_FUNCTION_MEMORY
  • Constructor Details

  • Method Details

    • contains

      public boolean contains(Block block, int position)
      Does this set contain the value?
    • add

      public boolean add(Block block, int position)
      Add the value to this set.
      Returns:
      true if the value was added, or false if 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

      public int positionOf(Block block, int position)
      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.