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 for BytesHashMap and BytesMultiMap.
  • Field Details

    • BUCKET_SIZE

      public static final int BUCKET_SIZE
      See Also:
    • END_OF_LIST

      protected static final int END_OF_LIST
      See Also:
    • STEP_INCREMENT

      protected static final int STEP_INCREMENT
      See Also:
    • ELEMENT_POINT_LENGTH

      protected static final int ELEMENT_POINT_LENGTH
      See Also:
    • RECORD_EXTRA_LENGTH

      public static final int RECORD_EXTRA_LENGTH
      See Also:
    • BUCKET_SIZE_BITS

      protected static final int BUCKET_SIZE_BITS
      See Also:
    • 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:
    • INIT_BUCKET_MEMORY_IN_BYTES

      protected static final long INIT_BUCKET_MEMORY_IN_BYTES
      See Also:
    • 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
  • Constructor Details

    • BytesMap

      public BytesMap(Object owner, org.apache.flink.runtime.memory.MemoryManager memoryManager, long memorySize, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer)
  • Method Details

    • 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)