Class TypedSet


  • public class TypedSet
    extends Object
    A set of unique SQL values stored in a Block.

    Depending on the factory method used, the values' equality may be determined using SQL equality or IS DISTINCT FROM semantics.

    • Field Detail

      • MAX_FUNCTION_MEMORY

        public static final io.airlift.units.DataSize MAX_FUNCTION_MEMORY
    • Method Detail

      • createUnboundedEqualityTypedSet

        public static TypedSet createUnboundedEqualityTypedSet​(Type elementType,
                                                               BlockTypeOperators.BlockPositionEqual elementEqualOperator,
                                                               BlockTypeOperators.BlockPositionHashCode elementHashCodeOperator,
                                                               BlockBuilder elementBlock,
                                                               int expectedSize,
                                                               String functionName)
        Create a TypedSet with no size limit that compares its elements using SQL equality comparison.

        The elements of the set will be written in the given BlockBuilder. If the BlockBuilder is 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 given position in the given block.
      • add

        public boolean add​(Block block,
                           int position)
        Add the value at the given position in the given block 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.
      • positionOf

        public int positionOf​(Block block,
                              int position)
        Return the position in this set's BlockBuilder of the value at the given position in the given block, or -1 if the value is not in this set.