Package io.trino.spi.block
Class IntArrayBlockBuilder
- java.lang.Object
-
- io.trino.spi.block.IntArrayBlockBuilder
-
- All Implemented Interfaces:
Block
,BlockBuilder
public class IntArrayBlockBuilder extends Object implements BlockBuilder
-
-
Constructor Summary
Constructors Constructor Description IntArrayBlockBuilder(BlockBuilderStatus blockBuilderStatus, int expectedEntries)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BlockBuilder
appendNull()
Appends a null value to the block.Block
build()
Builds the block.BlockBuilder
closeEntry()
Write a byte to the current entry;Block
copyPositions(int[] positions, int offset, int length)
Returns a block containing the specified positions.Block
copyRegion(int positionOffset, int length)
Returns a block starting at the specified position and extends for the specified length.String
getEncodingName()
Get the encoding for this block.long
getEstimatedDataSizeForStats(int position)
Returns the estimated in memory data size for stats of position.int
getInt(int position, int offset)
Gets a little endian int atoffset
in the value atposition
.int
getPositionCount()
Returns the number of positions in this block.long
getPositionsSizeInBytes(boolean[] positions)
Returns the size of all positions marked true in the positions array.Block
getRegion(int positionOffset, int length)
Returns a block starting at the specified position and extends for the specified length.long
getRegionSizeInBytes(int position, int length)
Returns the size ofblock.getRegion(position, length)
.long
getRetainedSizeInBytes()
Returns the retained size of this block in memory, including over-allocations.Block
getSingleValueBlock(int position)
Gets the value at the specified position as a single element block.long
getSizeInBytes()
Returns the size of this block as if it was compacted, ignoring any over-allocations and any unloaded nested blocks.boolean
isNull(int position)
Is the specified position null?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()
BlockBuilder
writeInt(int value)
Write a int to the current entry;void
writePositionTo(int position, BlockBuilder blockBuilder)
Appends the value atposition
toblockBuilder
and close the entry.-
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, equals, getByte, getChildren, getLoadedBlock, getLogicalSizeInBytes, getLong, getObject, getPositionsSizeInBytes, getShort, getSlice, getSliceLength, hash, isLoaded, writeBytesTo
-
Methods inherited from interface io.trino.spi.block.BlockBuilder
appendStructure, appendStructureInternal, beginBlockEntry, getPositions, writeByte, writeBytes, writeLong, writeShort
-
-
-
-
Constructor Detail
-
IntArrayBlockBuilder
public IntArrayBlockBuilder(@Nullable BlockBuilderStatus blockBuilderStatus, int expectedEntries)
-
-
Method Detail
-
writeInt
public BlockBuilder writeInt(int value)
Description copied from interface:BlockBuilder
Write a int to the current entry;- Specified by:
writeInt
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 Block 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
-
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
-
getRegionSizeInBytes
public long getRegionSizeInBytes(int position, int length)
Description copied from interface:Block
Returns the size ofblock.getRegion(position, length)
. The method can be expensive. Do not use it outside an implementation of Block.- Specified by:
getRegionSizeInBytes
in interfaceBlock
-
getPositionsSizeInBytes
public long getPositionsSizeInBytes(boolean[] positions)
Description copied from interface:Block
Returns the size of all positions marked true in the positions array. This is equivalent to multiple calls ofblock.getRegionSizeInBytes(position, length)
where you mark all positions for the regions first.- Specified by:
getPositionsSizeInBytes
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
-
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 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
-
getPositionCount
public int getPositionCount()
Description copied from interface:Block
Returns the number of positions in this block.- Specified by:
getPositionCount
in interfaceBlock
-
getInt
public int getInt(int position, int offset)
Description copied from interface:Block
Gets a little endian int atoffset
in the value atposition
.
-
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
-
isNull
public boolean isNull(int position)
Description copied from interface:Block
Is the specified position null?
-
writePositionTo
public void writePositionTo(int position, BlockBuilder blockBuilder)
Description copied from interface:Block
Appends the value atposition
toblockBuilder
and close the entry.- Specified by:
writePositionTo
in interfaceBlock
-
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 interfaceBlock
-
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 withinpositions
array that starts atoffset
and 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:
copyPositions
in interfaceBlock
-
getRegion
public Block getRegion(int positionOffset, 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.
-
copyRegion
public Block copyRegion(int positionOffset, 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 interfaceBlock
-
getEncodingName
public String getEncodingName()
Description copied from interface:Block
Get the encoding for this block.- Specified by:
getEncodingName
in interfaceBlock
-
-