public abstract class AbstractBytesMultiMap<K> extends BytesMap<K,Iterator<RowData>>
Map<K, List<V>>
, where there are multiple values under
a single key, and they are all bytes based. It can be used for performing aggregations where the
accumulator of aggregations are unfixed-width. The memory is divided into three areas:
Bucket area: pointer + hashcode
|---- 4 Bytes (pointer to key entry) ----| |----- 4 Bytes (key hashcode) ----------|
Key area: a key entry contains key data, pointer to the tail value, and the head value entry.
|--- 4 + len(K) Bytes (key data) ------| |--- 4 Bytes (pointer to tail value) ---| |--- 4 Bytes (pointer to next value) ---| |--- 4 + len(V) Bytes (value data) -----|
Value area: a value entry contains a pointer to the next value and the value data. Pointer is -1 if this is the last entry.
|--- 4 Bytes (pointer to next value) ---| |--- 4 + len(V) Bytes (value data) -----|
BytesMap.LookupInfo<K,V>
Modifier and Type | Field and Description |
---|---|
protected PagedTypeSerializer<K> |
keySerializer
Used to serialize map key into RecordArea's MemorySegments.
|
BUCKET_SIZE, BUCKET_SIZE_BITS, bucketSegments, ELEMENT_POINT_LENGTH, END_OF_LIST, growthThreshold, INIT_BUCKET_MEMORY_IN_BYTES, lastBucketPosition, LOAD_FACTOR, log2NumBuckets, memoryPool, numBucketsMask, numBucketsMask2, numBucketsPerSegment, numBucketsPerSegmentBits, numBucketsPerSegmentMask, numElements, numSpillFiles, RECORD_EXTRA_LENGTH, recordArea, reservedNumBuffers, reusedKey, reusedValue, segmentSize, spillInBytes, STEP_INCREMENT
Constructor and Description |
---|
AbstractBytesMultiMap(Object owner,
MemoryManager memoryManager,
long memorySize,
PagedTypeSerializer<K> keySerializer,
int valueArity) |
AbstractBytesMultiMap(Object owner,
MemoryManager memoryManager,
long memorySize,
PagedTypeSerializer<K> keySerializer,
LogicalType[] valueTypes) |
Modifier and Type | Method and Description |
---|---|
void |
append(BytesMap.LookupInfo<K,Iterator<RowData>> lookupInfo,
BinaryRowData value)
Append an value into the hash map's record area.
|
void |
free()
release the map's record and bucket area's memory segments.
|
void |
free(boolean reservedFixedMemory) |
KeyValueIterator<K,Iterator<RowData>> |
getEntryIterator(boolean requiresCopy) |
long |
getNumKeys()
Returns the number of keys in this map.
|
void |
reset()
reset the map's record and bucket area's memory segments for reusing.
|
calcSecondHashCode, getNumElements, getNumSpillFiles, getSpillInBytes, growAndRehash, initBucketSegments, lookup, resetBucketSegments, returnSegments
protected final PagedTypeSerializer<K> keySerializer
public AbstractBytesMultiMap(Object owner, MemoryManager memoryManager, long memorySize, PagedTypeSerializer<K> keySerializer, LogicalType[] valueTypes)
public AbstractBytesMultiMap(Object owner, MemoryManager memoryManager, long memorySize, PagedTypeSerializer<K> keySerializer, int valueArity)
public long getNumKeys()
BytesMap
getNumKeys
in class BytesMap<K,Iterator<RowData>>
public void append(BytesMap.LookupInfo<K,Iterator<RowData>> lookupInfo, BinaryRowData value) throws IOException
IOException
public KeyValueIterator<K,Iterator<RowData>> getEntryIterator(boolean requiresCopy)
public void free()
public void free(boolean reservedFixedMemory)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.