Package io.trino.spi.block
Class MapBlock
java.lang.Object
io.trino.spi.block.AbstractMapBlock
io.trino.spi.block.MapBlock
- All Implemented Interfaces:
Block
-
Method Summary
Modifier and TypeMethodDescriptionReturns a block that contains a copy of the contents of the current block, and an appended null at the end.static MapBlockcreateMapBlockInternal(MapType mapType, int startOffset, int positionCount, Optional<boolean[]> mapIsNull, int[] offsets, Block keyBlock, Block valueBlock, MapHashTables hashTables) Create a map block directly without per element validations.protected voidstatic MapBlockfromKeyValueBlock(Optional<boolean[]> mapIsNull, int[] offsets, int mapCount, Block keyBlock, Block valueBlock, MapType mapType) static MapBlockfromKeyValueBlock(Optional<boolean[]> mapIsNull, int[] offsets, Block keyBlock, Block valueBlock, MapType mapType) Create a map block directly from columnar nulls, keys, values, and offsets into the keys and values.protected MapHashTablesReturns a fully loaded block that assures all data is in memory.protected boolean[]protected intoffset is entry-based, not position-based.protected int[]offset is entry-based, not position-based.intReturns the number of positions in this block.protected Blockprotected BlocklongReturns the retained size of this block in memory, including over-allocations.longReturns the size of this block as if it was compacted, ignoring any over-allocations and any unloaded nested blocks.booleanisLoaded()Returns true if block data is fully loaded into memory.booleanIs it possible the block may have a null value? If false, the block cannot contain a null, but if true, the block may or may not have a null.voidretainedBytesForEachPart(ObjLongConsumer<Object> consumer) consumervisits each of the internal data container and accepts the size for it.toString()Methods inherited from class io.trino.spi.block.AbstractMapBlock
copyPositions, copyRegion, fixedSizeInBytesPerPosition, getChildren, getEncodingName, getEstimatedDataSizeForStats, getMapType, getObject, getPositionsSizeInBytes, getRegion, getRegionSizeInBytes, getSingleValueBlock, isHashTablesPresent, isNullMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.trino.spi.block.Block
bytesCompare, bytesEqual, compareTo, equals, getByte, getInt, getLogicalSizeInBytes, getLong, getPositions, getShort, getSlice, getSliceLength, hash, writeBytesTo
-
Method Details
-
fromKeyValueBlock
public static MapBlock fromKeyValueBlock(Optional<boolean[]> mapIsNull, int[] offsets, Block keyBlock, Block valueBlock, MapType mapType) Create a map block directly from columnar nulls, keys, values, and offsets into the keys and values. A null map must have no entries. -
fromKeyValueBlock
-
createMapBlockInternal
public static MapBlock createMapBlockInternal(MapType mapType, int startOffset, int positionCount, Optional<boolean[]> mapIsNull, int[] offsets, Block keyBlock, Block valueBlock, MapHashTables hashTables) Create a map block directly without per element validations.Internal use by this package and io.trino.spi.Type only.
-
getRawKeyBlock
- Specified by:
getRawKeyBlockin classAbstractMapBlock
-
getRawValueBlock
- Specified by:
getRawValueBlockin classAbstractMapBlock
-
getHashTables
- Specified by:
getHashTablesin classAbstractMapBlock
-
getOffsets
protected int[] getOffsets()Description copied from class:AbstractMapBlockoffset is entry-based, not position-based. In other words, if offset[1] is 6, it means the first map has 6 key-value pairs, not 6 key/values (which would be 3 pairs).- Specified by:
getOffsetsin classAbstractMapBlock
-
getOffsetBase
protected int getOffsetBase()Description copied from class:AbstractMapBlockoffset is entry-based, not position-based. (see getOffsets)- Specified by:
getOffsetBasein classAbstractMapBlock
-
getMapIsNull
@Nullable protected boolean[] getMapIsNull()- Specified by:
getMapIsNullin classAbstractMapBlock
-
mayHaveNull
public boolean mayHaveNull()Description copied from interface:BlockIs it possible the block may have a null value? If false, the block cannot contain a null, but if true, the block may or may not have a null. -
getPositionCount
public int getPositionCount()Description copied from interface:BlockReturns the number of positions in this block. -
getSizeInBytes
public long getSizeInBytes()Description copied from interface:BlockReturns the size of this block as if it was compacted, ignoring any over-allocations and any unloaded nested blocks. For example, in dictionary blocks, this only counts each dictionary entry once, rather than each time a value is referenced. -
getRetainedSizeInBytes
public long getRetainedSizeInBytes()Description copied from interface:BlockReturns the retained size of this block in memory, including over-allocations. This method is called from the inner most execution loop and must be fast. -
retainedBytesForEachPart
Description copied from interface:Blockconsumervisits 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 blocksconsumershould be called at least once with the current block and must include the instance size of the current block -
toString
-
isLoaded
public boolean isLoaded()Description copied from interface:BlockReturns true if block data is fully loaded into memory. -
getLoadedBlock
Description copied from interface:BlockReturns a fully loaded block that assures all data is in memory. Neither the returned block nor any nested block will be aLazyBlock. The same block will be returned if neither the current block nor any nested blocks areLazyBlock,This allows streaming data sources to skip sections that are not accessed in a query.
-
ensureHashTableLoaded
protected void ensureHashTableLoaded()- Specified by:
ensureHashTableLoadedin classAbstractMapBlock
-
copyWithAppendedNull
Description copied from interface:BlockReturns a block that contains a copy of the contents of the current block, and an appended null at the end. The original block will not be modified. The purpose of this method is to leverage the contents of a block and the structure of the implementation to efficiently produce a copy of the block with a NULL element inserted - so that it can be used as a dictionary. This method is expected to be invoked on completely builtBlockinstances i.e. not on in-progress block builders.
-