public class MapBlockBuilder extends AbstractMapBlock implements BlockBuilder
AbstractMapBlock.HashTableslogicalSizeInBytes| Constructor and Description |
|---|
MapBlockBuilder(Type keyType,
Type valueType,
MethodHandle keyBlockEquals,
MethodHandle keyBlockHashCode,
BlockBuilderStatus blockBuilderStatus,
int expectedEntries) |
| Modifier and Type | Method and Description |
|---|---|
BlockBuilder |
appendNull()
Returns a block that has an appended null at the end, no matter if the original block has null or not.
|
BlockBuilder |
appendStructure(Block block)
Append a struct to the block and close the entry.
|
BlockBuilder |
appendStructureInternal(Block block,
int position)
Do not use this interface outside block package.
|
SingleMapBlockWriter |
beginBlockEntry()
Return a writer to the current entry.
|
void |
beginDirectEntry()
Recommended way to build a Map is to first call beginBlockEntry which returns a BlockBuilder
On this returned BlockBuilder, write key and value alternatively and call closeEntry.
|
Block |
build()
Builds the block.
|
BlockBuilder |
closeEntry()
Closes the current entry.
|
BlockBuilder |
closeEntryStrict(MethodHandle keyBlockEquals,
MethodHandle keyBlockHashCode)
This method will check duplicate keys and close entry.
|
protected void |
ensureHashTableLoaded(MethodHandle keyBlockHashCode) |
protected AbstractMapBlock.HashTables |
getHashTables() |
BlockBuilder |
getKeyBlockBuilder() |
protected boolean[] |
getMapIsNull() |
int |
getOffsetBase()
offset is entry-based, not position-based.
|
protected int[] |
getOffsets()
offset is entry-based, not position-based.
|
int |
getPositionCount()
Returns the number of positions in this block.
|
protected Block |
getRawKeyBlock() |
protected Block |
getRawValueBlock() |
long |
getRetainedSizeInBytes()
Returns the retained size of this block in memory, including over-allocations.
|
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.
|
BlockBuilder |
getValueBlockBuilder() |
void |
loadHashTables() |
BlockBuilder |
newBlockBuilderLike(BlockBuilderStatus blockBuilderStatus)
Creates a new block builder of the same type based on the current usage statistics of this block builder.
|
BlockBuilder |
newBlockBuilderLike(BlockBuilderStatus blockBuilderStatus,
int expectedEntries)
Creates a new block builder of the same type based on the expectedEntries and the current usage statistics of this block builder.
|
BlockBuilder |
readPositionFrom(io.airlift.slice.SliceInput input)
Read a single position from the input
|
void |
retainedBytesForEachPart(BiConsumer<Object,Long> consumer)
consumer visits each of the internal data container and accepts the size for it. |
String |
toString() |
copyPositions, copyRegion, fixedSizeInBytesPerPosition, getApproximateRegionLogicalSizeInBytes, getBlock, getBlockUnchecked, getEncodingName, getEstimatedDataSizeForStats, getLogicalSizeInBytes, getPositionsSizeInBytes, getRegion, getRegionLogicalSizeInBytes, getRegionSizeInBytes, getSingleValueBlockInternal, isHashTablesPresent, isNull, isNullUnchecked, mayHaveNull, writePositionTo, writePositionToclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetPositions, writeByte, writeBytes, writeInt, writeLong, writeShortbytesCompare, bytesEqual, compareTo, copyPositions, copyRegion, equals, fixedSizeInBytesPerPosition, getApproximateRegionLogicalSizeInBytes, getBlock, getByte, getEncodingName, getEstimatedDataSizeForStats, getInt, getLoadedBlock, getLogicalSizeInBytes, getLong, getLong, getPositionsSizeInBytes, getRegion, getRegionLogicalSizeInBytes, getRegionSizeInBytes, getShort, getSlice, getSliceLength, hash, isNull, mayHaveNull, writeBytesTo, writeBytesTo, writePositionTo, writePositionTogetBlockUnchecked, getByteUnchecked, getIntUnchecked, getLongUnchecked, getLongUnchecked, getShortUnchecked, getSliceLengthUnchecked, getSliceUnchecked, isNullUncheckedpublic MapBlockBuilder(Type keyType, Type valueType, MethodHandle keyBlockEquals, MethodHandle keyBlockHashCode, BlockBuilderStatus blockBuilderStatus, int expectedEntries)
protected Block getRawKeyBlock()
getRawKeyBlock in class AbstractMapBlockprotected Block getRawValueBlock()
getRawValueBlock in class AbstractMapBlockprotected AbstractMapBlock.HashTables getHashTables()
getHashTables in class AbstractMapBlockprotected int[] getOffsets()
AbstractMapBlockgetOffsets in class AbstractMapBlockpublic int getOffsetBase()
AbstractMapBlockgetOffsetBase in interface UncheckedBlockgetOffsetBase in class AbstractMapBlockprotected boolean[] getMapIsNull()
getMapIsNull in class AbstractMapBlockpublic int getPositionCount()
BlockgetPositionCount in interface Blockpublic long getSizeInBytes()
BlockgetSizeInBytes in interface Blockpublic long getRetainedSizeInBytes()
BlockgetRetainedSizeInBytes in interface Blockpublic void retainedBytesForEachPart(BiConsumer<Object,Long> consumer)
Blockconsumer 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 blockretainedBytesForEachPart in interface Blockpublic Block getSingleValueBlock(int position)
BlockThis method is useful for operators that hold on to a single value without holding on to the entire block.
getSingleValueBlock in interface Blockpublic BlockBuilder getKeyBlockBuilder()
public BlockBuilder getValueBlockBuilder()
public void beginDirectEntry()
beginDirectEntry in interface BlockBuilderpublic SingleMapBlockWriter beginBlockEntry()
BlockBuilderbeginBlockEntry in interface BlockBuilderpublic BlockBuilder closeEntry()
BlockBuildercloseEntry in interface BlockBuilderpublic BlockBuilder closeEntryStrict(MethodHandle keyBlockEquals, MethodHandle keyBlockHashCode) throws DuplicateMapKeyException, NotSupportedException
When duplicate keys are discovered, the block is guaranteed to be in
a consistent state before DuplicateMapKeyException is thrown.
In other words, one can continue to use this BlockBuilder.
public BlockBuilder appendNull()
BlockappendNull in interface BlockappendNull in interface BlockBuilderappendNull in class AbstractMapBlockpublic BlockBuilder readPositionFrom(io.airlift.slice.SliceInput input)
BlockBuilderreadPositionFrom in interface BlockBuilderpublic Block build()
BlockBuilderbuild in interface BlockBuilderpublic BlockBuilder appendStructure(Block block)
BlockBuilderappendStructure in interface BlockBuilderpublic BlockBuilder appendStructureInternal(Block block, int position)
BlockBuilderappendStructureInternal in interface BlockBuilderpublic BlockBuilder newBlockBuilderLike(BlockBuilderStatus blockBuilderStatus)
BlockBuildernewBlockBuilderLike in interface BlockBuilderpublic BlockBuilder newBlockBuilderLike(BlockBuilderStatus blockBuilderStatus, int expectedEntries)
BlockBuildernewBlockBuilderLike in interface BlockBuilderpublic void loadHashTables()
protected void ensureHashTableLoaded(MethodHandle keyBlockHashCode)
ensureHashTableLoaded in class AbstractMapBlockCopyright © 2012–2022. All rights reserved.