Class

io.snappydata.collection

ByteBufferHashMap

Related Doc: package collection

Permalink

class ByteBufferHashMap extends AnyRef

A HashMap implementation using a serialized ByteBuffer for key data and another one for value data. Key data is required to hold fixed-width values while the value data will be written back-to-back as new data is inserted into the map. Key data is stored in the following format:

  .------------------------ Offset into value data (4 bytes)
  |   .-------------------- Hash code (4 bytes)
  |   |
  |   |        .----------- Fixed-width fields of key data
  |   |        |        .-- Padding for 8 byte word alignment
  V   V        V        V
+---+---+-------------+---+
|   |   | ... ... ... |   |
+---+---+-------------+---+
 \-----/ \------------/\--/
  header      body    padding

If key has variable length data, then it should be appended to the value data. The offset+hash code is read as a single long where LSB is used for hash code while MSB is used for offset, so the two can be reverse in actual memory layout on big-endian machines. Since there is no disk storage of this map so no attempt is made to have consistent endianness or memory layout of the data.

Rehash of the map (when loadFactor exceeds) moves around the above key fields to create a new array as per the new hash locations. The value fields are left untouched with the headers of keys having the offsets into value array as before the rehash.

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ByteBufferHashMap
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ByteBufferHashMap(initialCapacity: Int, loadFactor: Double, keySize: Int, valueSize: Int, allocator: BufferAllocator, keyData: ByteBufferData = null, valueData: ByteBufferData = null, valueDataPosition: Long = 0L)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val allocator: BufferAllocator

    Permalink
    Attributes
    protected
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. final def capacity: Int

    Permalink
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def getKeyData: ByteBufferData

    Permalink
  13. final def getValueData: ByteBufferData

    Permalink
  14. def handleExisting(mapKeyObject: AnyRef, mapKeyOffset: Long): Int

    Permalink
    Attributes
    protected
  15. def handleNew(mapKeyObject: AnyRef, mapKeyOffset: Long): Int

    Permalink
    Attributes
    protected
  16. final def handleNewInsert(): Unit

    Permalink

    Double the table's size and re-hash everything.

    Double the table's size and re-hash everything.

    Attributes
    protected
  17. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  19. var keyData: ByteBufferData

    Permalink
    Attributes
    protected
  20. val loadFactor: Double

    Permalink
  21. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. final def newInsert(baseObject: AnyRef, baseOffset: Long, numKeyBytes: Int, numBytes: Int): Int

    Permalink
    Attributes
    protected
  23. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  25. final def putBufferIfAbsent(baseObject: AnyRef, baseOffset: Long, numKeyBytes: Int, numBytes: Int, hash: Int): Int

    Permalink

    Insert raw bytes with given hash code into the map if not present.

    Insert raw bytes with given hash code into the map if not present. The key bytes for comparison is assumed to be at the start having "numKeyBytes" size, while the total size including value is "numBytes". Normally one would have serialized form of key bytes followed by self-contained serialized form of value bytes (i.e. including its size).

    This method will handle writing only the 8 byte key header while any additional fixed-width bytes to be tracked in read/write should be taken care of in handleExisting and handleNew. These bytes are not part of key equality check itself.

    baseObject

    the base object for the bytes as required by Unsafe API

    baseOffset

    the base offset for the bytes as required by Unsafe API

    numKeyBytes

    number of bytes used by the key which should be at the start of "baseObject" with value after that

    numBytes

    the total number of bytes used by key and value together (excluding the four bytes of "numKeyBytes" itself)

    hash

    the hash code of key bytes

  26. final def release(): Unit

    Permalink
  27. final def reset(): Unit

    Permalink
  28. final def size: Int

    Permalink
  29. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  30. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  31. var valueData: ByteBufferData

    Permalink
    Attributes
    protected
  32. var valueDataPosition: Long

    Permalink
    Attributes
    protected
  33. final def valueDataSize: Long

    Permalink
  34. val valueSize: Int

    Permalink
    Attributes
    protected
  35. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped