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
-
Nested Class Summary
Nested classes/interfaces inherited from class io.trino.spi.block.AbstractArrayBlock
AbstractArrayBlock.ArrayBlockFunction<T> -
Constructor Summary
ConstructorsConstructorDescriptionArrayBlockBuilder(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
Modifier and TypeMethodDescriptionAppends a null value to the block.Return a writer to the current entry.build()Builds the block.Close the current entry.copyPositions(int[] positions, int offset, int length) Returns a block containing the specified positions.copyRegion(int position, int length) Returns a block starting at the specified position and extends for the specified length.protected intprotected int[]intReturns the number of positions in this block.protected BlockgetRegion(int position, int length) Returns a block starting at the specified position and extends for the specified length.longReturns the retained size of this block in memory, including over-allocations.longReturns the size of this block as if it was compacted, ignoring any over-allocations and any unloaded nested blocks.protected boolean[]booleanIs 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.newBlockBuilderLike(int expectedEntries, BlockBuilderStatus blockBuilderStatus) Creates a new block builder of the same type based on the current usage statistics of this block builder.voidretainedBytesForEachPart(ObjLongConsumer<Object> consumer) consumervisits each of the internal data container and accepts the size for it.toString()Methods inherited from class io.trino.spi.block.AbstractArrayBlock
apply, fixedSizeInBytesPerPosition, getChildren, getEncodingName, getEstimatedDataSizeForStats, getObject, getPositionsSizeInBytes, getRegionSizeInBytes, getSingleValueBlock, isNullMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.trino.spi.block.Block
bytesCompare, bytesEqual, compareTo, equals, fixedSizeInBytesPerPosition, getByte, getChildren, getEncodingName, getEstimatedDataSizeForStats, getInt, getLoadedBlock, getLogicalSizeInBytes, getLong, getObject, getPositionsSizeInBytes, getRegionSizeInBytes, getShort, getSingleValueBlock, getSlice, getSliceLength, hash, isLoaded, isNull, writeBytesToMethods inherited from interface io.trino.spi.block.BlockBuilder
copyWithAppendedNull, getPositions, newBlockBuilderLike, writeByte, writeBytes, writeInt, writeLong, writeShort
-
Constructor Details
-
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 Details
-
getPositionCount
public int getPositionCount()Description copied from interface:BlockReturns the number of positions in this block.- Specified by:
getPositionCountin interfaceBlock
-
getSizeInBytes
public long getSizeInBytes()Description copied from interface:BlockReturns 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:
getSizeInBytesin interfaceBlock
-
getRetainedSizeInBytes
public long getRetainedSizeInBytes()Description copied from interface:BlockReturns 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:
getRetainedSizeInBytesin interfaceBlock
-
retainedBytesForEachPart
Description copied from interface:Blockconsumervisits 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 blocksconsumershould be called at least once with the current block and must include the instance size of the current block- Specified by:
retainedBytesForEachPartin interfaceBlock
-
getRawElementBlock
- Specified by:
getRawElementBlockin classAbstractArrayBlock
-
getOffsets
protected int[] getOffsets()- Specified by:
getOffsetsin classAbstractArrayBlock
-
getOffsetBase
protected int getOffsetBase()- Specified by:
getOffsetBasein classAbstractArrayBlock
-
getValueIsNull
@Nullable protected boolean[] getValueIsNull()- Specified by:
getValueIsNullin 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:BlockIs 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:
mayHaveNullin interfaceBlock
-
beginBlockEntry
Description copied from interface:BlockBuilderReturn 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:
beginBlockEntryin interfaceBlockBuilder
-
closeEntry
Description copied from interface:BlockBuilderClose the current entry.- Specified by:
closeEntryin interfaceBlockBuilder
-
appendNull
Description copied from interface:BlockBuilderAppends a null value to the block.- Specified by:
appendNullin interfaceBlockBuilder
-
build
Description copied from interface:BlockBuilderBuilds the block. This method can be called multiple times.- Specified by:
buildin interfaceBlockBuilder
-
newBlockBuilderLike
Description copied from interface:BlockBuilderCreates a new block builder of the same type based on the current usage statistics of this block builder.- Specified by:
newBlockBuilderLikein interfaceBlockBuilder
-
toString
-
copyPositions
Description copied from interface:BlockReturns a block containing the specified positions. Positions to copy are stored in a subarray withinpositionsarray that starts atoffsetand has length oflength. All specified positions must be valid for this block.The returned block must be a compact representation of the original block.
- Specified by:
copyPositionsin interfaceBlock- Overrides:
copyPositionsin classAbstractArrayBlock
-
getRegion
Description copied from interface:BlockReturns 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:
getRegionin interfaceBlock- Overrides:
getRegionin classAbstractArrayBlock
-
copyRegion
Description copied from interface:BlockReturns 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:
copyRegionin interfaceBlock- Overrides:
copyRegionin classAbstractArrayBlock
-