public abstract class AbstractMapBlock extends Object implements Block
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractMapBlock.HashTables |
| Modifier and Type | Field and Description |
|---|---|
protected long |
logicalSizeInBytes |
| Constructor and Description |
|---|
AbstractMapBlock() |
| 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.
|
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.
|
protected abstract void |
ensureHashTableLoaded(MethodHandle keyBlockHashCode) |
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.
|
protected abstract AbstractMapBlock.HashTables |
getHashTables() |
long |
getLogicalSizeInBytes()
Returns the size of the block contents, regardless of internal representation.
|
protected abstract boolean[] |
getMapIsNull() |
abstract int |
getOffsetBase()
offset is entry-based, not position-based.
|
protected abstract int[] |
getOffsets()
offset is entry-based, not position-based.
|
long |
getPositionsSizeInBytes(boolean[] positions,
int selectedMapPositions)
Returns the size of all positions marked true in the positions array.
|
protected abstract Block |
getRawKeyBlock() |
protected abstract Block |
getRawValueBlock() |
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) |
boolean |
isHashTablesPresent() |
boolean |
isNull(int position)
Is the specified position null?
|
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, getLong, getLong, getPositionCount, getPositions, getRetainedSizeInBytes, getShort, getSingleValueBlock, getSizeInBytes, getSlice, getSliceLength, hash, retainedBytesForEachPart, writeBytesTo, writeBytesTogetByteUnchecked, getIntUnchecked, getLongUnchecked, getLongUnchecked, getShortUnchecked, getSliceLengthUnchecked, getSliceUncheckedprotected abstract Block getRawKeyBlock()
protected abstract Block getRawValueBlock()
protected abstract AbstractMapBlock.HashTables getHashTables()
protected abstract int[] getOffsets()
public abstract int getOffsetBase()
getOffsetBase in interface UncheckedBlock@Nullable protected abstract boolean[] getMapIsNull()
protected abstract void ensureHashTableLoaded(MethodHandle keyBlockHashCode)
public String getEncodingName()
BlockgetEncodingName in interface Blockpublic 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 getLogicalSizeInBytes()
BlockBlock.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.getLogicalSizeInBytes 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 selectedMapPositions)
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 boolean isNull(int position)
Blockpublic boolean isHashTablesPresent()
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.