Class RunLengthEncodedBlock
- All Implemented Interfaces:
Block
-
Method Summary
Modifier and TypeMethodDescriptioncopyPositions(int[] positions, int offset, int length) Returns a block containing the specified positions.copyRegion(int positionOffset, int length) Returns a block starting at the specified position and extends for the specified length.Returns a block that contains a copy of the contents of the current block, and an appended null at the end.static Blockstatic BlockReturns the number of bytes (in terms ofBlock.getSizeInBytes()) required per position that this block contains, assuming that the number of bytes required is a known static quantity and not dependent on any particular specific position.bytegetByte(int position, int offset) Gets a byte atoffsetin the value atposition.Gets the direct child blocks of this block.Get the encoding for this block.longgetEstimatedDataSizeForStats(int position) Returns the estimated in memory data size for stats of position.intgetInt(int position, int offset) Gets a little endian int atoffsetin the value atposition.longReturns the size of the block contents, regardless of internal representation.longgetLong(int position, int offset) Gets a little endian long atoffsetin the value atposition.<T> TGets an object in the value atposition.intPosition count will always be at least 2getPositions(int[] positions, int offset, int length) Create a new block from the current block by keeping the same elements only with respect topositionsthat starts atoffsetand has length oflength.longgetPositionsSizeInBytes(boolean[] positions, int selectedPositionCount) Returns the size of all positions marked true in the positions array.getRegion(int positionOffset, int length) Returns a block starting at the specified position and extends for the specified length.longgetRegionSizeInBytes(int position, int length) Returns the size ofblock.getRegion(position, length).longReturns the retained size of this block in memory, including over-allocations.shortgetShort(int position, int offset) Gets a little endian short atoffsetin the value atposition.getSingleValueBlock(int position) Gets the value at the specified position as a single element block.longReturns the size of this block as if it was compacted, ignoring any over-allocations and any unloaded nested blocks.io.airlift.slice.SlicegetSlice(int position, int offset, int length) Gets a slice atoffsetin the value atposition.intgetSliceLength(int position) Gets the length of the value at theposition.Returns the underlying value block underlying this block.intgetUnderlyingValuePosition(int position) Returns the position in the underlying value block corresponding to the specified position in this block.getValue()booleanisNull(int position) Is the specified position null?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.voidretainedBytesForEachPart(ObjLongConsumer<Object> consumer) consumervisits each of the internal data container and accepts the size for it.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.trino.spi.block.Block
getLoadedBlock, isLoaded
-
Method Details
-
create
-
create
-
getChildren
Description copied from interface:BlockGets the direct child blocks of this block.- Specified by:
getChildrenin interfaceBlock
-
getValue
-
getPositionCount
public int getPositionCount()Position count will always be at least 2- Specified by:
getPositionCountin interfaceBlock
-
fixedSizeInBytesPerPosition
Description copied from interface:BlockReturns the number of bytes (in terms ofBlock.getSizeInBytes()) required per position that this block contains, assuming that the number of bytes required is a known static quantity and not dependent on any particular specific position. This allows for some complex block wrappings to potentially avoid having to callBlock.getPositionsSizeInBytes(boolean[], int)which would require computing the specific positions selected- Specified by:
fixedSizeInBytesPerPositionin interfaceBlock- Returns:
- The size in bytes, per position, if this block type does not require specific position information to compute its size
-
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
-
getLogicalSizeInBytes
public long getLogicalSizeInBytes()Description copied from interface:BlockReturns the size of the block contents, regardless of internal representation. The same logical data values should always have the same size, no matter what block type is used or how they are represented within a specific block.This can differ substantially from
Block.getSizeInBytes()for certain block types. For RLE, it will beNtimes larger. For dictionary, it will be larger based on how many times dictionary entries are reused.- Specified by:
getLogicalSizeInBytesin 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
-
getEstimatedDataSizeForStats
public long getEstimatedDataSizeForStats(int position) Description copied from interface:BlockReturns the estimated in memory data size for stats of position. Do not use it for other purpose.- Specified by:
getEstimatedDataSizeForStatsin 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
-
getEncodingName
Description copied from interface:BlockGet the encoding for this block.- Specified by:
getEncodingNamein interfaceBlock
-
getPositions
Description copied from interface:BlockCreate a new block from the current block by keeping the same elements only with respect topositionsthat starts atoffsetand has length oflength. The implementation may return a view over the data in this block or may return a copy, and the implementation is allowed to retain the positions array for use in the view.- Specified by:
getPositionsin interfaceBlock
-
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
-
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.
-
getRegionSizeInBytes
public long getRegionSizeInBytes(int position, int length) Description copied from interface:BlockReturns the size ofblock.getRegion(position, length). The method can be expensive. Do not use it outside an implementation of Block.- Specified by:
getRegionSizeInBytesin interfaceBlock
-
getPositionsSizeInBytes
public long getPositionsSizeInBytes(@Nullable boolean[] positions, int selectedPositionCount) Description copied from interface:BlockReturns 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. The 'selectedPositionsCount' variable may be used to skip iterating through the positions array in case this is a fixed-width block- Specified by:
getPositionsSizeInBytesin interfaceBlock
-
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
-
getSliceLength
public int getSliceLength(int position) Description copied from interface:BlockGets the length of the value at theposition. This method must be implemented if @{code getSlice} is implemented.- Specified by:
getSliceLengthin interfaceBlock
-
getByte
public byte getByte(int position, int offset) Description copied from interface:BlockGets a byte atoffsetin the value atposition. -
getShort
public short getShort(int position, int offset) Description copied from interface:BlockGets a little endian short atoffsetin the value atposition. -
getInt
public int getInt(int position, int offset) Description copied from interface:BlockGets a little endian int atoffsetin the value atposition. -
getLong
public long getLong(int position, int offset) Description copied from interface:BlockGets a little endian long atoffsetin the value atposition. -
getSlice
public io.airlift.slice.Slice getSlice(int position, int offset, int length) Description copied from interface:BlockGets a slice atoffsetin the value atposition. -
getObject
Description copied from interface:BlockGets an object in the value atposition. -
getSingleValueBlock
Description copied from interface:BlockGets 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:
getSingleValueBlockin interfaceBlock
-
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
-
isNull
public boolean isNull(int position) Description copied from interface:BlockIs the specified position null? -
copyWithAppendedNull
Description copied from interface:BlockReturns a block that contains a copy of the contents of the current block, and an appended null at the end. The original block will not be modified. The purpose of this method is to leverage the contents of a block and the structure of the implementation to efficiently produce a copy of the block with a NULL element inserted - so that it can be used as a dictionary. This method is expected to be invoked on completely builtBlockinstances i.e. not on in-progress block builders.- Specified by:
copyWithAppendedNullin interfaceBlock
-
toString
-
getUnderlyingValueBlock
Description copied from interface:BlockReturns the underlying value block underlying this block.- Specified by:
getUnderlyingValueBlockin interfaceBlock
-
getUnderlyingValuePosition
public int getUnderlyingValuePosition(int position) Description copied from interface:BlockReturns the position in the underlying value block corresponding to the specified position in this block.- Specified by:
getUnderlyingValuePositionin interfaceBlock
-