Class MapBlockBuilder

java.lang.Object
io.trino.spi.block.AbstractMapBlock
io.trino.spi.block.MapBlockBuilder
All Implemented Interfaces:
Block, BlockBuilder

public class MapBlockBuilder extends AbstractMapBlock implements BlockBuilder
  • Constructor Details

  • Method Details

    • strict

      public MapBlockBuilder strict()
    • getRawKeyBlock

      protected Block getRawKeyBlock()
      Specified by:
      getRawKeyBlock in class AbstractMapBlock
    • getRawValueBlock

      protected Block getRawValueBlock()
      Specified by:
      getRawValueBlock in class AbstractMapBlock
    • getHashTables

      protected MapHashTables getHashTables()
      Specified by:
      getHashTables in class AbstractMapBlock
    • getOffsets

      protected int[] getOffsets()
      Description copied from class: AbstractMapBlock
      offset is entry-based, not position-based. In other words, if offset[1] is 6, it means the first map has 6 key-value pairs, not 6 key/values (which would be 3 pairs).
      Specified by:
      getOffsets in class AbstractMapBlock
    • getOffsetBase

      protected int getOffsetBase()
      Description copied from class: AbstractMapBlock
      offset is entry-based, not position-based. (see getOffsets)
      Specified by:
      getOffsetBase in class AbstractMapBlock
    • getMapIsNull

      @Nullable protected boolean[] getMapIsNull()
      Specified by:
      getMapIsNull in class AbstractMapBlock
    • mayHaveNull

      public boolean mayHaveNull()
      Description copied from interface: Block
      Is it possible the block may have a null value? If false, the block cannot contain a null, but if true, the block may or may not have a null.
      Specified by:
      mayHaveNull in interface Block
    • getPositionCount

      public int getPositionCount()
      Description copied from interface: Block
      Returns the number of positions in this block.
      Specified by:
      getPositionCount in interface Block
    • getSizeInBytes

      public long getSizeInBytes()
      Description copied from interface: Block
      Returns the size of this block as if it was compacted, ignoring any over-allocations and any unloaded nested blocks. For example, in dictionary blocks, this only counts each dictionary entry once, rather than each time a value is referenced.
      Specified by:
      getSizeInBytes in interface Block
    • getRetainedSizeInBytes

      public long getRetainedSizeInBytes()
      Description copied from interface: Block
      Returns the retained size of this block in memory, including over-allocations. This method is called from the inner most execution loop and must be fast.
      Specified by:
      getRetainedSizeInBytes in interface Block
    • retainedBytesForEachPart

      public void retainedBytesForEachPart(ObjLongConsumer<Object> consumer)
      Description copied from interface: Block
      consumer visits each of the internal data container and accepts the size for it. This method can be helpful in cases such as memory counting for internal data structure. Also, the method should be non-recursive, only visit the elements at the top level, and specifically should not call retainedBytesForEachPart on nested blocks consumer should be called at least once with the current block and must include the instance size of the current block
      Specified by:
      retainedBytesForEachPart in interface Block
    • beginBlockEntry

      public SingleMapBlockWriter beginBlockEntry()
      Description copied from interface: BlockBuilder
      Return a writer to the current entry. The caller can operate on the returned caller to incrementally build the object. This is generally more efficient than building the object elsewhere and call writeObject afterwards because a large chunk of memory could potentially be unnecessarily copied in this process.
      Specified by:
      beginBlockEntry in interface BlockBuilder
    • closeEntry

      public BlockBuilder closeEntry()
      Description copied from interface: BlockBuilder
      Close the current entry.
      Specified by:
      closeEntry in interface BlockBuilder
    • closeEntryStrict

      @Deprecated public void closeEntryStrict() throws DuplicateMapKeyException
      Deprecated.
      use strict method instead
      This method will check duplicate keys and close entry.

      When duplicate keys are discovered, the block is guaranteed to be in a consistent state before DuplicateMapKeyException is thrown. In other words, one can continue to use this BlockBuilder.

      Throws:
      DuplicateMapKeyException
    • appendNull

      public BlockBuilder appendNull()
      Description copied from interface: BlockBuilder
      Appends a null value to the block.
      Specified by:
      appendNull in interface BlockBuilder
    • build

      public Block build()
      Description copied from interface: BlockBuilder
      Builds the block. This method can be called multiple times.
      Specified by:
      build in interface BlockBuilder
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • newBlockBuilderLike

      public BlockBuilder newBlockBuilderLike(int expectedEntries, BlockBuilderStatus blockBuilderStatus)
      Description copied from interface: BlockBuilder
      Creates a new block builder of the same type based on the current usage statistics of this block builder.
      Specified by:
      newBlockBuilderLike in interface BlockBuilder
    • ensureHashTableLoaded

      protected void ensureHashTableLoaded()
      Specified by:
      ensureHashTableLoaded in class AbstractMapBlock