Class AbstractArrayBlock

java.lang.Object
io.trino.spi.block.AbstractArrayBlock
All Implemented Interfaces:
Block
Direct Known Subclasses:
ArrayBlock, ArrayBlockBuilder

public abstract class AbstractArrayBlock extends Object implements Block
  • Constructor Details

    • AbstractArrayBlock

      public AbstractArrayBlock()
  • Method Details

    • getChildren

      public final List<Block> getChildren()
      Description copied from interface: Block
      Gets the direct child blocks of this block.
      Specified by:
      getChildren in interface Block
    • getRawElementBlock

      protected abstract Block getRawElementBlock()
    • getOffsets

      protected abstract int[] getOffsets()
    • getOffsetBase

      protected abstract int getOffsetBase()
    • getValueIsNull

      @Nullable protected abstract boolean[] getValueIsNull()
      Returns:
      the underlying valueIsNull array, or null when all values are guaranteed to be non-null
    • getEncodingName

      public String getEncodingName()
      Description copied from interface: Block
      Get the encoding for this block.
      Specified by:
      getEncodingName in interface Block
    • copyPositions

      public Block copyPositions(int[] positions, int offset, int length)
      Description copied from interface: Block
      Returns a block containing the specified positions. Positions to copy are stored in a subarray within positions array that starts at offset and has length of length. All specified positions must be valid for this block.

      The returned block must be a compact representation of the original block.

      Specified by:
      copyPositions in interface Block
    • getRegion

      public Block getRegion(int position, int length)
      Description copied from interface: Block
      Returns a block starting at the specified position and extends for the specified length. The specified region must be entirely contained within this block.

      The region can be a view over this block. If this block is released the region block may also be released. If the region block is released this block may also be released.

      Specified by:
      getRegion in interface Block
    • 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
    • getRegionSizeInBytes

      public long getRegionSizeInBytes(int position, int length)
      Description copied from interface: Block
      Returns the size of block.getRegion(position, length). The method can be expensive. Do not use it outside an implementation of Block.
      Specified by:
      getRegionSizeInBytes in interface Block
    • getPositionsSizeInBytes

      public final long getPositionsSizeInBytes(boolean[] positions, int selectedArrayPositions)
      Description copied from interface: Block
      Returns the size of all positions marked true in the positions array. This is equivalent to multiple calls of block.getRegionSizeInBytes(position, length) where you mark all positions for the regions first. The 'selectedPositionsCount' variable may be used to skip iterating through the positions array in case this is a fixed-width block
      Specified by:
      getPositionsSizeInBytes in interface Block
    • copyRegion

      public Block copyRegion(int position, int length)
      Description copied from interface: Block
      Returns a block starting at the specified position and extends for the specified length. The specified region must be entirely contained within this block.

      The region returned must be a compact representation of the original block, unless their internal representation will be exactly the same. This method is useful for operators that hold on to a range of values without holding on to the entire block.

      Specified by:
      copyRegion in interface Block
    • getObject

      public <T> T getObject(int position, Class<T> clazz)
      Description copied from interface: Block
      Gets an object in the value at position.
      Specified by:
      getObject in interface Block
    • getSingleValueBlock

      public Block getSingleValueBlock(int position)
      Description copied from interface: Block
      Gets the value at the specified position as a single element block. The method must copy the data into a new block.

      This method is useful for operators that hold on to a single value without holding on to the entire block.

      Specified by:
      getSingleValueBlock in interface Block
    • getEstimatedDataSizeForStats

      public long getEstimatedDataSizeForStats(int position)
      Description copied from interface: Block
      Returns the estimated in memory data size for stats of position. Do not use it for other purpose.
      Specified by:
      getEstimatedDataSizeForStats in interface Block
    • isNull

      public boolean isNull(int position)
      Description copied from interface: Block
      Is the specified position null?
      Specified by:
      isNull in interface Block
    • apply

      public <T> T apply(AbstractArrayBlock.ArrayBlockFunction<T> function, int position)