Package io.trino.spi.block
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AbstractArrayBlock.ArrayBlockFunction<T>
-
Constructor Summary
Constructors Constructor Description AbstractArrayBlock()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> T
apply(AbstractArrayBlock.ArrayBlockFunction<T> function, int position)
Block
copyPositions(int[] positions, int offset, int length)
Returns a block containing the specified positions.Block
copyRegion(int position, int length)
Returns a block starting at the specified position and extends for the specified length.List<Block>
getChildren()
Gets the direct child blocks of this block.String
getEncodingName()
Get the encoding for this block.long
getEstimatedDataSizeForStats(int position)
Returns the estimated in memory data size for stats of position.<T> T
getObject(int position, Class<T> clazz)
Gets an object in the value atposition
.protected abstract int
getOffsetBase()
protected abstract int[]
getOffsets()
long
getPositionsSizeInBytes(boolean[] positions)
Returns the size of all positions marked true in the positions array.protected abstract Block
getRawElementBlock()
Block
getRegion(int position, 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)
.Block
getSingleValueBlock(int position)
Gets the value at the specified position as a single element block.protected abstract boolean[]
getValueIsNull()
boolean
isNull(int position)
Is the specified position null?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, toString, wait, wait, wait
-
Methods inherited from interface io.trino.spi.block.Block
bytesCompare, bytesEqual, compareTo, equals, getByte, getInt, getLoadedBlock, getLogicalSizeInBytes, getLong, getPositionCount, getPositions, getPositionsSizeInBytes, getRetainedSizeInBytes, getShort, getSizeInBytes, getSlice, getSliceLength, hash, isLoaded, mayHaveNull, retainedBytesForEachPart, writeBytesTo
-
-
-
-
Method Detail
-
getChildren
public final List<Block> getChildren()
Description copied from interface:Block
Gets the direct child blocks of this block.- Specified by:
getChildren
in interfaceBlock
-
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 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 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.
-
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
-
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 interfaceBlock
-
getObject
public <T> T getObject(int position, Class<T> clazz)
Description copied from interface:Block
Gets an object in the value atposition
.
-
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
-
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
-
isNull
public boolean isNull(int position)
Description copied from interface:Block
Is the specified position null?
-
apply
public <T> T apply(AbstractArrayBlock.ArrayBlockFunction<T> function, int position)
-
-