Class SingleArrayBlockWriter

java.lang.Object
io.trino.spi.block.AbstractSingleArrayBlock
io.trino.spi.block.SingleArrayBlockWriter
All Implemented Interfaces:
Block, BlockBuilder

public class SingleArrayBlockWriter extends AbstractSingleArrayBlock implements BlockBuilder
  • Constructor Details

    • SingleArrayBlockWriter

      public SingleArrayBlockWriter(BlockBuilder blockBuilder, int start)
  • Method Details

    • getBlock

      protected Block getBlock()
      Specified by:
      getBlock in class AbstractSingleArrayBlock
    • fixedSizeInBytesPerPosition

      public OptionalInt fixedSizeInBytesPerPosition()
      Description copied from interface: Block
      Returns the number of bytes (in terms of Block.getSizeInBytes()) required per position that this block contains, assuming that the number of bytes required is a known static quantity and not dependent on any particular specific position. This allows for some complex block wrappings to potentially avoid having to call Block.getPositionsSizeInBytes(boolean[], int) which would require computing the specific positions selected
      Specified by:
      fixedSizeInBytesPerPosition in interface Block
      Returns:
      The size in bytes, per position, if this block type does not require specific position information to compute its size
    • 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
    • writeByte

      public BlockBuilder writeByte(int value)
      Description copied from interface: BlockBuilder
      Write a byte to the current entry;
      Specified by:
      writeByte in interface BlockBuilder
    • writeShort

      public BlockBuilder writeShort(int value)
      Description copied from interface: BlockBuilder
      Write a short to the current entry;
      Specified by:
      writeShort in interface BlockBuilder
    • writeInt

      public BlockBuilder writeInt(int value)
      Description copied from interface: BlockBuilder
      Write a int to the current entry;
      Specified by:
      writeInt in interface BlockBuilder
    • writeLong

      public BlockBuilder writeLong(long value)
      Description copied from interface: BlockBuilder
      Write a long to the current entry;
      Specified by:
      writeLong in interface BlockBuilder
    • writeBytes

      public BlockBuilder writeBytes(io.airlift.slice.Slice source, int sourceIndex, int length)
      Description copied from interface: BlockBuilder
      Write a byte sequences to the current entry;
      Specified by:
      writeBytes in interface BlockBuilder
    • beginBlockEntry

      public BlockBuilder 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
    • appendNull

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

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

      public int getPositionCount()
      Description copied from interface: Block
      Returns the number of positions in this block.
      Specified by:
      getPositionCount in interface Block
    • 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
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object