Javadoc
A store for a key and a list of 1 or more arbitrary length values in memory.
The memory is a "infinite" byte array as a WriteBuffers object.
We give the client (e.g. hash map logic) a 64-bit key and value reference to keep that has
the offset within the "infinite" byte array of the key. The 64 bits includes about half
of the upper hash code to help during matching.
We optimize the common case when the key length is short and store that information in the
64 bit reference.
When there are more than 1 value, the zero padding is overwritten with a relative offset to
the next value. The next value always includes the value length.
Cases:
1) One element when key and is small (and stored in the reference word):
Key and Value Reference
|
| absoluteOffset
|
---------------------------------
|
v
NEXT (NONE) KEY VALUE
NOTE: AbsoluteOffset.byteLength = 5
2) One element, general: shows optional big key length.
Key and Value Reference
|
| absoluteOffset
|
---------------------------------
|
v
[Big Key Length]
NEXT (NONE) optional KEY VALUE
3) Two elements when key length is small and stored in reference word:
Key and Value Reference
|
| absoluteOffset
|
------------------------------------
|
v
| NEXT KEY VALUE
|
| first record absolute offset + relative offset
|
--------
|
v
NEXT (NONE) VALUE
4) Three elements showing how first record updated to point to new value and
new value points to most recent (additional) value:
Key and Value Reference
|
| absoluteOffset
|
------------------------------------
|
v
| NEXT KEY VALUE
|
| first record absolute offset + relative offset
|
|
|
| ^ NEXT (NONE) VALUE
| |
| ------
| |
| | new record absolute offset - (minus) relative offset
| |
----->
NEXT VALUE
5) Four elements showing how first record is again updated to point to new value and
new value points to most recent (additional) value:
Key and Value Reference
|
| absoluteOffset
|
------------------------------------
|
v
| NEXT KEY VALUE
|
| first record absolute offset + relative offset
|
|
|
| ^ NEXT (NONE) VALUE
| |
| ------
| | record absolute offset - (minus) relative offset
| |
|
| ^ NEXT VALUE
| |
| ------
| |
| | new record absolute offset - (minus) relative offset
| |
----->
NEXT VALUE
You get the idea.