public class VariableWidthBlockBuilder extends AbstractVariableWidthBlock implements BlockBuilder
| Constructor and Description |
|---|
VariableWidthBlockBuilder(BlockBuilderStatus blockBuilderStatus,
int expectedEntries,
int expectedBytes) |
| Modifier and Type | Method and Description |
|---|---|
BlockBuilder |
appendNull()
Appends a null value to the block.
|
Block |
build()
Builds the block.
|
BlockBuilder |
closeEntry()
Closes the current entry.
|
Block |
copyPositions(int[] positions,
int offset,
int length)
Returns a block containing the specified positions.
|
Block |
copyRegion(int positionOffset,
int length)
Returns a block starting at the specified position and extends for the
specified length.
|
byte |
getByteUnchecked(int internalPosition)
Gets a byte value at
internalPosition - getOffsetBase(). |
int |
getIntUnchecked(int internalPosition)
Gets a little endian int value at
internalPosition - getOffsetBase(). |
long |
getLongUnchecked(int internalPosition)
Gets a little endian long value at
internalPosition - getOffsetBase(). |
long |
getLongUnchecked(int internalPosition,
int offset)
Gets a little endian long at
offset in the value at internalPosition - getOffsetBase(). |
int |
getOffsetBase() |
int |
getPositionCount()
Returns the number of positions in this block.
|
int |
getPositionOffset(int position) |
long |
getPositionsSizeInBytes(boolean[] positions)
Returns the size of of all positions marked true in the positions array.
|
io.airlift.slice.Slice |
getRawSlice(int position) |
Block |
getRegion(int positionOffset,
int length)
Returns a block starting at the specified position and extends for the
specified length.
|
long |
getRegionSizeInBytes(int positionOffset,
int length)
Returns the size of
block.getRegion(position, length). |
long |
getRetainedSizeInBytes()
Returns the retained size of this block in memory, including over-allocations.
|
short |
getShortUnchecked(int internalPosition)
Gets a little endian short at value at
internalPosition - getOffsetBase(). |
long |
getSizeInBytes()
Returns the size of this block as if it was compacted, ignoring any over-allocations.
|
int |
getSliceLength(int position)
Gets the length of the value at the
position. |
int |
getSliceLengthUnchecked(int internalPosition)
Gets the length of the slice value at
internalPosition - getOffsetBase(). |
io.airlift.slice.Slice |
getSliceUnchecked(int internalPosition,
int offset,
int length)
Gets a slice with offset
offset at internalPosition - getOffsetBase(). |
protected boolean |
isEntryNull(int position) |
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.
|
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() |
BlockBuilder |
writeByte(int value)
Write a byte to the current entry;
|
BlockBuilder |
writeBytes(io.airlift.slice.Slice source,
int sourceIndex,
int length)
Write a byte sequences to the current entry;
|
BlockBuilder |
writeInt(int value)
Write a int to the current entry;
|
BlockBuilder |
writeLong(long value)
Write a long to the current entry;
|
BlockBuilder |
writeShort(int value)
Write a short to the current entry;
|
bytesCompare, bytesEqual, checkReadablePosition, compareTo, equals, getByte, getEncodingName, getEstimatedDataSizeForStats, getInt, getLong, getLong, getShort, getSingleValueBlock, getSlice, hash, isNull, writeBytesTo, writePositionTo, writePositionToclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendStructure, appendStructureInternal, beginBlockEntry, getPositionsbytesCompare, bytesEqual, compareTo, equals, getApproximateRegionLogicalSizeInBytes, getBlock, getByte, getEncodingName, getEstimatedDataSizeForStats, getInt, getLoadedBlock, getLogicalSizeInBytes, getLong, getLong, getRegionLogicalSizeInBytes, getShort, getSingleValueBlock, getSlice, hash, isNull, writeBytesTo, writePositionTo, writePositionTogetBlockUncheckedpublic VariableWidthBlockBuilder(@Nullable BlockBuilderStatus blockBuilderStatus, int expectedEntries, int expectedBytes)
public int getPositionOffset(int position)
getPositionOffset in class AbstractVariableWidthBlockpublic int getSliceLength(int position)
Blockposition.
This method must be implemented if @{code getSlice} is implemented.getSliceLength in interface Blockpublic io.airlift.slice.Slice getRawSlice(int position)
getRawSlice in class AbstractVariableWidthBlockpublic int getPositionCount()
BlockgetPositionCount in interface Blockpublic long getSizeInBytes()
BlockgetSizeInBytes in interface Blockpublic long getRegionSizeInBytes(int positionOffset,
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 getPositionsSizeInBytes(boolean[] positions)
Blockblock.getRegionSizeInBytes(position, length)
where you mark all positions for the regions first.getPositionsSizeInBytes 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 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 BlockBuilder writeByte(int value)
BlockBuilderwriteByte in interface BlockBuilderpublic BlockBuilder writeShort(int value)
BlockBuilderwriteShort in interface BlockBuilderpublic BlockBuilder writeInt(int value)
BlockBuilderwriteInt in interface BlockBuilderpublic BlockBuilder writeLong(long value)
BlockBuilderwriteLong in interface BlockBuilderpublic BlockBuilder writeBytes(io.airlift.slice.Slice source, int sourceIndex, int length)
BlockBuilderwriteBytes in interface BlockBuilderpublic BlockBuilder closeEntry()
BlockBuildercloseEntry in interface BlockBuilderpublic BlockBuilder appendNull()
BlockBuilderappendNull in interface BlockappendNull in interface BlockBuilderpublic BlockBuilder readPositionFrom(io.airlift.slice.SliceInput input)
BlockBuilderreadPositionFrom in interface BlockBuilderpublic boolean mayHaveNull()
BlockmayHaveNull in interface Blockprotected boolean isEntryNull(int position)
isEntryNull in class AbstractVariableWidthBlockpublic Block getRegion(int positionOffset, 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 Block copyRegion(int positionOffset, 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 build()
BlockBuilderbuild in interface BlockBuilderpublic BlockBuilder newBlockBuilderLike(BlockBuilderStatus blockBuilderStatus)
BlockBuildernewBlockBuilderLike in interface BlockBuilderpublic BlockBuilder newBlockBuilderLike(BlockBuilderStatus blockBuilderStatus, int expectedEntries)
BlockBuildernewBlockBuilderLike in interface BlockBuilderpublic byte getByteUnchecked(int internalPosition)
UncheckedBlockinternalPosition - getOffsetBase().getByteUnchecked in interface UncheckedBlockpublic short getShortUnchecked(int internalPosition)
UncheckedBlockinternalPosition - getOffsetBase().getShortUnchecked in interface UncheckedBlockpublic int getIntUnchecked(int internalPosition)
UncheckedBlockinternalPosition - getOffsetBase().getIntUnchecked in interface UncheckedBlockpublic long getLongUnchecked(int internalPosition)
UncheckedBlockinternalPosition - getOffsetBase().getLongUnchecked in interface UncheckedBlockpublic long getLongUnchecked(int internalPosition,
int offset)
UncheckedBlockoffset in the value at internalPosition - getOffsetBase().getLongUnchecked in interface UncheckedBlockpublic io.airlift.slice.Slice getSliceUnchecked(int internalPosition,
int offset,
int length)
UncheckedBlockoffset at internalPosition - getOffsetBase().getSliceUnchecked in interface UncheckedBlockpublic int getSliceLengthUnchecked(int internalPosition)
UncheckedBlockinternalPosition - getOffsetBase().
This method must be implemented if getSliceUnchecked is implemented.getSliceLengthUnchecked in interface UncheckedBlockpublic boolean isNullUnchecked(int internalPosition)
isNullUnchecked in interface UncheckedBlockinternalPosition - getOffsetBase() is nullpublic int getOffsetBase()
getOffsetBase in interface UncheckedBlockCopyright © 2012–2021. All rights reserved.