public abstract class AbstractArrayBlock extends Object implements Block
| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractArrayBlock.ArrayBlockFunction<T> |
| Constructor and Description |
|---|
AbstractArrayBlock() |
| 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.
|
<T> T |
apply(AbstractArrayBlock.ArrayBlockFunction<T> function,
int position) |
protected void |
checkReadablePosition(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.
|
OptionalInt |
fixedSizeInBytesPerPosition()
Returns the number of bytes (in terms of
Block.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. |
long |
getApproximateRegionLogicalSizeInBytes(int position,
int length)
Returns the approximate logical size of
block.getRegion(position, length). |
Block |
getBlock(int position)
Gets a block in the value at
position. |
Block |
getBlockUnchecked(int internalPosition)
Gets a Block value at
internalPosition - getOffsetBase(). |
String |
getEncodingName()
Get the encoding for this block.
|
long |
getEstimatedDataSizeForStats(int position)
Returns the estimated in memory data size for stats of position.
|
abstract int |
getOffsetBase() |
protected abstract int[] |
getOffsets() |
long |
getPositionsSizeInBytes(boolean[] positions,
int selectedArrayPositions)
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 |
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). |
protected Block |
getSingleValueBlockInternal(int position) |
protected abstract boolean[] |
getValueIsNull() |
boolean |
isNullUnchecked(int internalPosition) |
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 |
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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbytesCompare, bytesEqual, compareTo, equals, getByte, getInt, getLoadedBlock, getLogicalSizeInBytes, getLong, getLong, getPositionCount, getPositions, getRetainedSizeInBytes, getShort, getSingleValueBlock, getSizeInBytes, getSlice, getSliceLength, hash, isNull, retainedBytesForEachPart, writeBytesTo, writeBytesTogetByteUnchecked, getIntUnchecked, getLongUnchecked, getLongUnchecked, getShortUnchecked, getSliceLengthUnchecked, getSliceUncheckedprotected abstract Block getRawElementBlock()
protected abstract int[] getOffsets()
public abstract int getOffsetBase()
getOffsetBase in interface UncheckedBlock@Nullable protected abstract boolean[] getValueIsNull()
public String getEncodingName()
BlockgetEncodingName in interface Blockpublic final Block copyPositions(int[] positions, int offset, int length)
Blockpositions 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.
copyPositions in interface Blockpublic Block getRegion(int position, int length)
BlockThe 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.
public OptionalInt fixedSizeInBytesPerPosition()
BlockBlock.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 Block.getPositionsSizeInBytes(boolean[], int) which
would require computing the specific positions selectedfixedSizeInBytesPerPosition in interface Blockpublic long getRegionSizeInBytes(int position,
int length)
Blockblock.getRegion(position, length).
The method can be expensive. Do not use it outside an implementation of Block.getRegionSizeInBytes in interface Blockpublic long getRegionLogicalSizeInBytes(int position,
int length)
Blockblock.getRegion(position, length).
The method can be expensive. Do not use it outside an implementation of Block.getRegionLogicalSizeInBytes in interface Blockpublic long getApproximateRegionLogicalSizeInBytes(int position,
int length)
Blockblock.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.getApproximateRegionLogicalSizeInBytes in interface Blockpublic final long getPositionsSizeInBytes(boolean[] positions,
int selectedArrayPositions)
Blockblock.getRegionSizeInBytes(position, length)
where you mark all positions for the regions first.getPositionsSizeInBytes in interface Blockpublic Block copyRegion(int position, int length)
BlockThe 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.
copyRegion in interface Blockpublic Block getBlock(int position)
Blockposition.public void writePositionTo(int position,
BlockBuilder blockBuilder)
Blockposition to blockBuilder and close the entry.writePositionTo in interface Blockpublic void writePositionTo(int position,
io.airlift.slice.SliceOutput output)
Blockposition to output.writePositionTo in interface Blockprotected Block getSingleValueBlockInternal(int position)
public long getEstimatedDataSizeForStats(int position)
BlockgetEstimatedDataSizeForStats in interface Blockpublic boolean mayHaveNull()
BlockmayHaveNull in interface Blockpublic <T> T apply(AbstractArrayBlock.ArrayBlockFunction<T> function, int position)
protected final void checkReadablePosition(int position)
public Block getBlockUnchecked(int internalPosition)
UncheckedBlockinternalPosition - getOffsetBase().getBlockUnchecked in interface UncheckedBlockpublic boolean isNullUnchecked(int internalPosition)
isNullUnchecked in interface UncheckedBlockinternalPosition - getOffsetBase() is nullpublic Block appendNull()
BlockappendNull in interface BlockCopyright © 2012–2022. All rights reserved.