Package io.trino.spi.block
Class ArrayBlockBuilder
- java.lang.Object
-
- io.trino.spi.block.AbstractArrayBlock
-
- io.trino.spi.block.ArrayBlockBuilder
-
- All Implemented Interfaces:
Block
,BlockBuilder
public class ArrayBlockBuilder extends AbstractArrayBlock implements BlockBuilder
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.trino.spi.block.AbstractArrayBlock
AbstractArrayBlock.ArrayBlockFunction<T>
-
-
Constructor Summary
Constructors Constructor Description ArrayBlockBuilder(BlockBuilder valuesBlock, BlockBuilderStatus blockBuilderStatus, int expectedEntries)
Caller of this constructor is responsible for making sure `valuesBlock` is constructed with the same `blockBuilderStatus` as the one in the argumentArrayBlockBuilder(Type elementType, BlockBuilderStatus blockBuilderStatus, int expectedEntries)
ArrayBlockBuilder(Type elementType, BlockBuilderStatus blockBuilderStatus, int expectedEntries, int expectedBytesPerEntry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BlockBuilder
appendNull()
Appends a null value to the block.BlockBuilder
appendStructure(Block block)
Append a struct to the block and close the entry.BlockBuilder
appendStructureInternal(Block block, int position)
Do not use this interface outside block package.SingleArrayBlockWriter
beginBlockEntry()
Return a writer to the current entry.ArrayBlock
build()
Builds the block.BlockBuilder
closeEntry()
Write a byte to the current entry;protected int
getOffsetBase()
protected int[]
getOffsets()
int
getPositionCount()
Returns the number of positions in this block.protected Block
getRawElementBlock()
long
getRetainedSizeInBytes()
Returns the retained size of this block in memory, including over-allocations.long
getSizeInBytes()
Returns the size of this block as if it was compacted, ignoring any over-allocations and any unloaded nested blocks.protected boolean[]
getValueIsNull()
boolean
mayHaveNull()
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.BlockBuilder
newBlockBuilderLike(BlockBuilderStatus blockBuilderStatus)
Creates a new block builder of the same type based on the current usage statistics of this block builder.void
retainedBytesForEachPart(BiConsumer<Object,Long> consumer)
consumer
visits each of the internal data container and accepts the size for it.String
toString()
-
Methods inherited from class io.trino.spi.block.AbstractArrayBlock
apply, copyPositions, copyRegion, getChildren, getEncodingName, getEstimatedDataSizeForStats, getObject, getPositionsSizeInBytes, getRegion, getRegionSizeInBytes, getSingleValueBlock, isNull, writePositionTo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.trino.spi.block.Block
bytesCompare, bytesEqual, compareTo, copyPositions, copyRegion, equals, getByte, getChildren, getEncodingName, getEstimatedDataSizeForStats, getInt, getLoadedBlock, getLogicalSizeInBytes, getLong, getObject, getPositionsSizeInBytes, getPositionsSizeInBytes, getRegion, getRegionSizeInBytes, getShort, getSingleValueBlock, getSlice, getSliceLength, hash, isLoaded, isNull, writeBytesTo, writePositionTo
-
Methods inherited from interface io.trino.spi.block.BlockBuilder
getPositions, writeByte, writeBytes, writeInt, writeLong, writeShort
-
-
-
-
Constructor Detail
-
ArrayBlockBuilder
public ArrayBlockBuilder(BlockBuilder valuesBlock, BlockBuilderStatus blockBuilderStatus, int expectedEntries)
Caller of this constructor is responsible for making sure `valuesBlock` is constructed with the same `blockBuilderStatus` as the one in the argument
-
ArrayBlockBuilder
public ArrayBlockBuilder(Type elementType, BlockBuilderStatus blockBuilderStatus, int expectedEntries, int expectedBytesPerEntry)
-
ArrayBlockBuilder
public ArrayBlockBuilder(Type elementType, BlockBuilderStatus blockBuilderStatus, int expectedEntries)
-
-
Method Detail
-
getPositionCount
public int getPositionCount()
Description copied from interface:Block
Returns the number of positions in this block.- Specified by:
getPositionCount
in interfaceBlock
-
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 interfaceBlock
-
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 interfaceBlock
-
retainedBytesForEachPart
public void retainedBytesForEachPart(BiConsumer<Object,Long> 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 blocksconsumer
should be called at least once with the current block and must include the instance size of the current block- Specified by:
retainedBytesForEachPart
in interfaceBlock
-
getRawElementBlock
protected Block getRawElementBlock()
- Specified by:
getRawElementBlock
in classAbstractArrayBlock
-
getOffsets
protected int[] getOffsets()
- Specified by:
getOffsets
in classAbstractArrayBlock
-
getOffsetBase
protected int getOffsetBase()
- Specified by:
getOffsetBase
in classAbstractArrayBlock
-
getValueIsNull
@Nullable protected boolean[] getValueIsNull()
- Specified by:
getValueIsNull
in classAbstractArrayBlock
- Returns:
- the underlying valueIsNull array, or null when all values are guaranteed to be non-null
-
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 interfaceBlock
-
appendStructure
public BlockBuilder appendStructure(Block block)
Description copied from interface:BlockBuilder
Append a struct to the block and close the entry.- Specified by:
appendStructure
in interfaceBlockBuilder
-
appendStructureInternal
public BlockBuilder appendStructureInternal(Block block, int position)
Description copied from interface:BlockBuilder
Do not use this interface outside block package. Instead, use Block.writePositionTo(BlockBuilder, position)- Specified by:
appendStructureInternal
in interfaceBlockBuilder
-
beginBlockEntry
public SingleArrayBlockWriter 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 interfaceBlockBuilder
-
closeEntry
public BlockBuilder closeEntry()
Description copied from interface:BlockBuilder
Write a byte to the current entry;- Specified by:
closeEntry
in interfaceBlockBuilder
-
appendNull
public BlockBuilder appendNull()
Description copied from interface:BlockBuilder
Appends a null value to the block.- Specified by:
appendNull
in interfaceBlockBuilder
-
build
public ArrayBlock build()
Description copied from interface:BlockBuilder
Builds the block. This method can be called multiple times.- Specified by:
build
in interfaceBlockBuilder
-
newBlockBuilderLike
public BlockBuilder newBlockBuilderLike(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 interfaceBlockBuilder
-
-