Class BytesMap<K,V>
- java.lang.Object
-
- org.apache.flink.table.runtime.util.collections.binary.BytesMap<K,V>
-
- Type Parameters:
K- type of the map key.V- type of the map value.
- Direct Known Subclasses:
AbstractBytesHashMap,AbstractBytesMultiMap
public abstract class BytesMap<K,V> extends Object
Base class forBytesHashMapandBytesMultiMap.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBytesMap.LookupInfo<K,V>Result fetched when looking up a key.
-
Field Summary
Fields Modifier and Type Field Description static intBUCKET_SIZEprotected static intBUCKET_SIZE_BITSprotected List<org.apache.flink.core.memory.MemorySegment>bucketSegmentsprotected static intELEMENT_POINT_LENGTHprotected static intEND_OF_LISTprotected intgrowthThresholdThe map will be expanded once the number of elements exceeds this threshold.protected static longINIT_BUCKET_MEMORY_IN_BYTESprotected intlastBucketPositionprotected static doubleLOAD_FACTORprotected intlog2NumBucketsprotected LazyMemorySegmentPoolmemoryPoolprotected intnumBucketsMaskprotected intnumBucketsMask2protected intnumBucketsPerSegmentprotected intnumBucketsPerSegmentBitsprotected intnumBucketsPerSegmentMaskprotected longnumElementsprotected longnumSpillFilesstatic intRECORD_EXTRA_LENGTHprotected org.apache.flink.table.runtime.util.collections.binary.BytesMap.RecordArea<K,V>recordAreaThe segments where the actual data is stored.protected intreservedNumBuffersprotected KreusedKeyUsed as a reused object when lookup and iteration.protected VreusedValueUsed as a reused object when retrieve the map's value by key and iteration.protected intsegmentSizeprotected longspillInBytesprotected static intSTEP_INCREMENT
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected intcalcSecondHashCode(int firstHashCode)voidfree(boolean reservedRecordMemory)longgetNumElements()abstract longgetNumKeys()Returns the number of keys in this map.longgetNumSpillFiles()longgetSpillInBytes()protected voidgrowAndRehash()protected voidinitBucketSegments(int numBucketSegments)BytesMap.LookupInfo<K,V>lookup(K key)voidreset()reset the map's record and bucket area's memory segments for reusing.protected voidresetBucketSegments(List<org.apache.flink.core.memory.MemorySegment> resetBucketSegs)protected voidreturnSegments(List<org.apache.flink.core.memory.MemorySegment> segments)
-
-
-
Field Detail
-
BUCKET_SIZE
public static final int BUCKET_SIZE
- See Also:
- Constant Field Values
-
END_OF_LIST
protected static final int END_OF_LIST
- See Also:
- Constant Field Values
-
STEP_INCREMENT
protected static final int STEP_INCREMENT
- See Also:
- Constant Field Values
-
ELEMENT_POINT_LENGTH
protected static final int ELEMENT_POINT_LENGTH
- See Also:
- Constant Field Values
-
RECORD_EXTRA_LENGTH
public static final int RECORD_EXTRA_LENGTH
- See Also:
- Constant Field Values
-
BUCKET_SIZE_BITS
protected static final int BUCKET_SIZE_BITS
- See Also:
- Constant Field Values
-
numBucketsPerSegment
protected final int numBucketsPerSegment
-
numBucketsPerSegmentBits
protected final int numBucketsPerSegmentBits
-
numBucketsPerSegmentMask
protected final int numBucketsPerSegmentMask
-
lastBucketPosition
protected final int lastBucketPosition
-
segmentSize
protected final int segmentSize
-
memoryPool
protected final LazyMemorySegmentPool memoryPool
-
bucketSegments
protected List<org.apache.flink.core.memory.MemorySegment> bucketSegments
-
reservedNumBuffers
protected final int reservedNumBuffers
-
numElements
protected long numElements
-
numBucketsMask
protected int numBucketsMask
-
log2NumBuckets
protected int log2NumBuckets
-
numBucketsMask2
protected int numBucketsMask2
-
LOAD_FACTOR
protected static final double LOAD_FACTOR
- See Also:
- Constant Field Values
-
INIT_BUCKET_MEMORY_IN_BYTES
protected static final long INIT_BUCKET_MEMORY_IN_BYTES
- See Also:
- Constant Field Values
-
growthThreshold
protected int growthThreshold
The map will be expanded once the number of elements exceeds this threshold.
-
recordArea
protected org.apache.flink.table.runtime.util.collections.binary.BytesMap.RecordArea<K,V> recordArea
The segments where the actual data is stored.
-
reusedKey
protected K reusedKey
Used as a reused object when lookup and iteration.
-
reusedValue
protected V reusedValue
Used as a reused object when retrieve the map's value by key and iteration.
-
numSpillFiles
protected long numSpillFiles
-
spillInBytes
protected long spillInBytes
-
-
Method Detail
-
getNumKeys
public abstract long getNumKeys()
Returns the number of keys in this map.
-
initBucketSegments
protected void initBucketSegments(int numBucketSegments)
-
resetBucketSegments
protected void resetBucketSegments(List<org.apache.flink.core.memory.MemorySegment> resetBucketSegs)
-
getNumSpillFiles
public long getNumSpillFiles()
-
getSpillInBytes
public long getSpillInBytes()
-
getNumElements
public long getNumElements()
-
free
public void free(boolean reservedRecordMemory)
- Parameters:
reservedRecordMemory- reserved fixed memory or not.
-
reset
public void reset()
reset the map's record and bucket area's memory segments for reusing.
-
lookup
public BytesMap.LookupInfo<K,V> lookup(K key)
- Parameters:
key- by which looking up the value in the hash map. Only support the key in the BinaryRowData form who has only one MemorySegment.- Returns:
BytesMap.LookupInfo
-
growAndRehash
protected void growAndRehash() throws EOFException- Throws:
EOFException- if the map can't allocate much more memory.
-
returnSegments
protected void returnSegments(List<org.apache.flink.core.memory.MemorySegment> segments)
-
calcSecondHashCode
protected int calcSecondHashCode(int firstHashCode)
-
-