Package io.prestosql.spi.block
Class VariableWidthBlock
- java.lang.Object
-
- io.prestosql.spi.block.AbstractVariableWidthBlock
-
- io.prestosql.spi.block.VariableWidthBlock
-
- All Implemented Interfaces:
Block
public class VariableWidthBlock extends AbstractVariableWidthBlock
-
-
Constructor Summary
Constructors Constructor Description VariableWidthBlock(int positionCount, io.airlift.slice.Slice slice, int[] offsets, Optional<boolean[]> valueIsNull)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.int
getPositionCount()
Returns the number of positions in this block.protected int
getPositionOffset(int position)
long
getPositionsSizeInBytes(boolean[] positions)
Returns the size of of all positions marked true in the positions array.protected io.airlift.slice.Slice
getRawSlice(int position)
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.long
getSizeInBytes()
Returns the size of this block as if it was compacted, ignoring any over-allocations and any unloaded nested blocks.int
getSliceLength(int position)
Gets the length of the value at theposition
.protected boolean
isEntryNull(int position)
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.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.prestosql.spi.block.AbstractVariableWidthBlock
bytesCompare, bytesEqual, checkReadablePosition, compareTo, equals, getByte, getEncodingName, getEstimatedDataSizeForStats, getInt, getLong, getShort, getSingleValueBlock, getSlice, hash, isNull, writeBytesTo, writePositionTo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.prestosql.spi.block.Block
getChildren, getLoadedBlock, getLogicalSizeInBytes, getObject, getPositions, isLoaded
-
-
-
-
Constructor Detail
-
VariableWidthBlock
public VariableWidthBlock(int positionCount, io.airlift.slice.Slice slice, int[] offsets, Optional<boolean[]> valueIsNull)
-
-
Method Detail
-
getPositionOffset
protected final int getPositionOffset(int position)
- Specified by:
getPositionOffset
in classAbstractVariableWidthBlock
-
getSliceLength
public int getSliceLength(int position)
Description copied from interface:Block
Gets the length of the value at theposition
. This method must be implemented if @{code getSlice} is implemented.
-
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.
-
isEntryNull
protected boolean isEntryNull(int position)
- Specified by:
isEntryNull
in classAbstractVariableWidthBlock
-
getPositionCount
public int getPositionCount()
Description copied from interface:Block
Returns the number of positions in this block.
-
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.
-
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.
-
getPositionsSizeInBytes
public long getPositionsSizeInBytes(boolean[] positions)
Description copied from interface:Block
Returns the size of 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.
-
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.
-
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
-
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.
-
getRawSlice
protected io.airlift.slice.Slice getRawSlice(int position)
- Specified by:
getRawSlice
in classAbstractVariableWidthBlock
-
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.
-
-