public class BytesHashMap extends Object
- Bucket area: this contains: pointer + hashcode. Bytes 0 to 8: a pointer to the record in the record area Bytes 8 to 16: a holds key's full 32-bit hashcode
- Record area: this contains the actual data in linked list records. A BytesHashMap's record has four parts: Bytes 0 to 4: len(k) Bytes 4 to 4 + len(k): key data Bytes 4 + len(k) to 8 + len(k): len(v) Bytes 8 + len(k) to 8 + len(k) + len(v): value data
BytesHashMap
are influenced by Apache Spark BytesToBytesMap.
Modifier and Type | Class and Description |
---|---|
static class |
BytesHashMap.Entry
BytesHashMap Entry contains key and value field.
|
static class |
BytesHashMap.LookupInfo
Handle returned by
lookup(BinaryRowData) function. |
Modifier and Type | Field and Description |
---|---|
static int |
BUCKET_SIZE |
static int |
RECORD_EXTRA_LENGTH |
Constructor and Description |
---|
BytesHashMap(Object owner,
MemoryManager memoryManager,
long memorySize,
LogicalType[] keyTypes,
LogicalType[] valueTypes) |
BytesHashMap(Object owner,
MemoryManager memoryManager,
long memorySize,
LogicalType[] keyTypes,
LogicalType[] valueTypes,
boolean inferBucketMemory) |
Modifier and Type | Method and Description |
---|---|
BinaryRowData |
append(BytesHashMap.LookupInfo info,
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 reservedRecordMemory) |
List<MemorySegment> |
getBucketAreaMemorySegments() |
MutableObjectIterator<BytesHashMap.Entry> |
getEntryIterator()
Returns a destructive iterator for iterating over the entries of this map.
|
long |
getNumElements() |
long |
getNumSpillFiles() |
ArrayList<MemorySegment> |
getRecordAreaMemorySegments() |
long |
getSpillInBytes() |
long |
getUsedMemoryInBytes() |
BytesHashMap.LookupInfo |
lookup(BinaryRowData key) |
void |
reset()
reset the map's record and bucket area's memory segments for reusing.
|
public static final int BUCKET_SIZE
public static final int RECORD_EXTRA_LENGTH
public BytesHashMap(Object owner, MemoryManager memoryManager, long memorySize, LogicalType[] keyTypes, LogicalType[] valueTypes)
public BytesHashMap(Object owner, MemoryManager memoryManager, long memorySize, LogicalType[] keyTypes, LogicalType[] valueTypes, boolean inferBucketMemory)
public BytesHashMap.LookupInfo lookup(BinaryRowData key)
key
- by which looking up the value in the hash map. Only support the key in the
BinaryRowData form who has only one MemorySegment.BytesHashMap.LookupInfo
public BinaryRowData append(BytesHashMap.LookupInfo info, BinaryRowData value) throws IOException
EOFException
- if the map can't allocate much more memory.IOException
public long getNumSpillFiles()
public long getUsedMemoryInBytes()
public long getSpillInBytes()
public long getNumElements()
public MutableObjectIterator<BytesHashMap.Entry> getEntryIterator()
public ArrayList<MemorySegment> getRecordAreaMemorySegments()
public List<MemorySegment> getBucketAreaMemorySegments()
public void free()
public void free(boolean reservedRecordMemory)
reservedRecordMemory
- reserved fixed memory or not.public void reset()
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.