public interface Block extends UncheckedBlock
| Modifier and Type | Method and Description |
|---|---|
Block |
appendNull()
Returns a block that has an appended null at the end, no matter if the original block has null or not.
|
default int |
bytesCompare(int position,
int offset,
int length,
io.airlift.slice.Slice otherSlice,
int otherOffset,
int otherLength)
Compares the byte sequences at
offset in the value at position
to the byte sequence at otherOffset in otherSlice. |
default boolean |
bytesEqual(int position,
int offset,
io.airlift.slice.Slice otherSlice,
int otherOffset,
int length)
Is the byte sequences at
offset in the value at position equal
to the byte sequence at otherOffset in otherSlice. |
default int |
compareTo(int leftPosition,
int leftOffset,
int leftLength,
Block rightBlock,
int rightPosition,
int rightOffset,
int rightLength)
Compares the byte sequences at
offset in the value at position
to the byte sequence at otherOffset in the value at otherPosition
in otherBlock. |
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.
|
default boolean |
equals(int position,
int offset,
Block otherBlock,
int otherPosition,
int otherOffset,
int length)
Is the byte sequences at
offset in the value at position equal
to the byte sequence at otherOffset in the value at otherPosition
in otherBlock. |
OptionalInt |
fixedSizeInBytesPerPosition()
Returns the number of bytes (in terms of
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. |
default long |
getApproximateRegionLogicalSizeInBytes(int position,
int length)
Returns the approximate logical size of
block.getRegion(position, length). |
default Block |
getBlock(int position)
Gets a block in the value at
position. |
default byte |
getByte(int position)
Gets a byte in the value at
position. |
String |
getEncodingName()
Get the encoding for this block.
|
long |
getEstimatedDataSizeForStats(int position)
Returns the estimated in memory data size for stats of position.
|
default int |
getInt(int position)
Gets a little endian int in the value at
position. |
default Block |
getLoadedBlock()
Returns a block that assures all data is in memory.
|
default long |
getLogicalSizeInBytes()
Returns the size of the block contents, regardless of internal representation.
|
default long |
getLong(int position)
Gets a little endian long in the value at
position. |
default long |
getLong(int position,
int offset)
Gets a little endian long at
offset in the value at position. |
int |
getPositionCount()
Returns the number of positions in this block.
|
default Block |
getPositions(int[] positions,
int offset,
int length)
Create a new block from the current block by keeping the same elements
only with respect to
positions that starts at offset and has length of length. |
long |
getPositionsSizeInBytes(boolean[] positions,
int usedPositionCount)
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.
|
default long |
getRegionLogicalSizeInBytes(int position,
int length)
Returns the size of
block.getRegion(position, length). |
long |
getRegionSizeInBytes(int position,
int length)
Returns the size of
block.getRegion(position, length). |
long |
getRetainedSizeInBytes()
Returns the retained size of this block in memory, including over-allocations.
|
default short |
getShort(int position)
Gets a little endian short at in the value at
position. |
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.
|
default io.airlift.slice.Slice |
getSlice(int position,
int offset,
int length)
Gets a slice at
offset in the value at position. |
default int |
getSliceLength(int position)
Gets the length of the value at the
position. |
default long |
hash(int position,
int offset,
int length)
Calculates the hash code the byte sequences at
offset in the
value at position. |
boolean |
isNull(int position)
Is the specified position null?
|
default boolean |
mayHaveNull()
Is it possible the block may have a null value? If false, the block can not contain
a null, but if true, the block may or may not have a null.
|
void |
retainedBytesForEachPart(ObjLongConsumer<Object> consumer)
consumer visits each of the internal data container and accepts the size for it. |
default void |
writeBytesTo(int position,
int offset,
int length,
BlockBuilder blockBuilder)
Appends the byte sequences at
offset in the value at position
to blockBuilder. |
default void |
writeBytesTo(int position,
int offset,
int length,
io.airlift.slice.SliceOutput sliceOutput)
Appends the byte sequences at
offset in the value at position
to sliceOutput. |
void |
writePositionTo(int position,
BlockBuilder blockBuilder)
Appends the value at
position to blockBuilder and close the entry. |
void |
writePositionTo(int position,
io.airlift.slice.SliceOutput output)
Appends the value at
position to output. |
getBlockUnchecked, getByteUnchecked, getIntUnchecked, getLongUnchecked, getLongUnchecked, getOffsetBase, getShortUnchecked, getSliceLengthUnchecked, getSliceUnchecked, isNullUncheckeddefault int getSliceLength(int position)
position.
This method must be implemented if @{code getSlice} is implemented.default byte getByte(int position)
position.default short getShort(int position)
position.default int getInt(int position)
position.default long getLong(int position)
position.default long getLong(int position,
int offset)
offset in the value at position.default io.airlift.slice.Slice getSlice(int position,
int offset,
int length)
offset in the value at position.default Block getBlock(int position)
position.default boolean bytesEqual(int position,
int offset,
io.airlift.slice.Slice otherSlice,
int otherOffset,
int length)
offset in the value at position equal
to the byte sequence at otherOffset in otherSlice.
This method must be implemented if @{code getSlice} is implemented.default int bytesCompare(int position,
int offset,
int length,
io.airlift.slice.Slice otherSlice,
int otherOffset,
int otherLength)
offset in the value at position
to the byte sequence at otherOffset in otherSlice.
This method must be implemented if @{code getSlice} is implemented.default void writeBytesTo(int position,
int offset,
int length,
BlockBuilder blockBuilder)
offset in the value at position
to blockBuilder.
This method must be implemented if @{code getSlice} is implemented.default void writeBytesTo(int position,
int offset,
int length,
io.airlift.slice.SliceOutput sliceOutput)
offset in the value at position
to sliceOutput.
This method must be implemented if @{code getSlice} is implemented.void writePositionTo(int position,
BlockBuilder blockBuilder)
position to blockBuilder and close the entry.void writePositionTo(int position,
io.airlift.slice.SliceOutput output)
position to output.default boolean equals(int position,
int offset,
Block otherBlock,
int otherPosition,
int otherOffset,
int length)
offset in the value at position equal
to the byte sequence at otherOffset in the value at otherPosition
in otherBlock.
This method must be implemented if @{code getSlice} is implemented.default long hash(int position,
int offset,
int length)
offset in the
value at position.
This method must be implemented if @{code getSlice} is implemented.default int compareTo(int leftPosition,
int leftOffset,
int leftLength,
Block rightBlock,
int rightPosition,
int rightOffset,
int rightLength)
offset in the value at position
to the byte sequence at otherOffset in the value at otherPosition
in otherBlock.
This method must be implemented if @{code getSlice} is implemented.Block getSingleValueBlock(int position)
This method is useful for operators that hold on to a single value without holding on to the entire block.
IllegalArgumentException - if this position is not validint getPositionCount()
long getSizeInBytes()
default long getLogicalSizeInBytes()
getSizeInBytes() for certain block
types. For RLE, it will be N times larger. For dictionary, it will be
larger based on how many times dictionary entries are reused.long getRegionSizeInBytes(int position,
int length)
block.getRegion(position, length).
The method can be expensive. Do not use it outside an implementation of Block.default long getRegionLogicalSizeInBytes(int position,
int length)
block.getRegion(position, length).
The method can be expensive. Do not use it outside an implementation of Block.default long getApproximateRegionLogicalSizeInBytes(int position,
int length)
block.getRegion(position, length).
This method is faster than getRegionLogicalSizeInBytes().
For dictionary blocks, this counts the amortized flattened size of the included positions.
For example, for a DictionaryBlock with 5 ids [1, 1, 1, 1, 1] and a dictionary of
VariableWidthBlock with 3 elements of sizes [9, 5, 7], the result of
getApproximateRegionLogicalSizeInBytes(0, 5) would be (9 + 5 + 7) / 3 * 5 = 35,
while getRegionLogicalSizeInBytes(0, 5) would be 5 * 5 = 25.OptionalInt fixedSizeInBytesPerPosition()
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 call getPositionsSizeInBytes(boolean[], int) which
would require computing the specific positions selectedlong getPositionsSizeInBytes(boolean[] positions,
int usedPositionCount)
block.getRegionSizeInBytes(position, length)
where you mark all positions for the regions first.long getRetainedSizeInBytes()
long getEstimatedDataSizeForStats(int position)
void retainedBytesForEachPart(ObjLongConsumer<Object> consumer)
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 blocks
consumer should be called at least once with the current block and
must include the instance size of the current blockString getEncodingName()
default Block getPositions(int[] positions, int offset, int length)
positions that starts at offset and has length of length.
May return a view over the data in this block or may return a copyBlock copyPositions(int[] positions, int offset, int length)
positions array
that starts at offset and has length of length.
All specified positions must be valid for this block.
The returned block must be a compact representation of the original block.
Block getRegion(int positionOffset, int length)
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.
Block copyRegion(int position, int length)
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.
default boolean mayHaveNull()
boolean isNull(int position)
IllegalArgumentException - if this position is not validdefault Block getLoadedBlock()
This allows streaming data sources to skip sections that are not accessed in a query.
Block appendNull()
Copyright © 2012–2022. All rights reserved.