writeBuffers
public WriteBuffers writeBuffers()
A store for "lists" of arbitrary length values in memory.
The memory is a "infinite" byte array or WriteBuffers object.
We give the client a 64-bit (long) value reference to keep that has the offset within
the "infinite" byte array of the last value inserted in a "list".
We optimize the common case when "list"s are 1 element and values are short and store the
value length in the value reference word.
We also support keeping a count (up to a limit or cap) so help with join result generation
algorithms.
If the last value is big, the big length will be encoded as an integer at the beginning
of the value followed by the big value bytes.
Due to optimizing by keeping the last value's length in the value reference, when we have
more than one value, a new value will need to keep the small value length of the next
value.
So, values after the first value have 4 parts: a relative offset word with flags, an
optional length if the current value is big, an optional next value length if it is small,
and the value bytes.
Cases:
1) One element, small:
Value Reference -------------
|
|
v
{Small Value Bytes}
2) One element, big:
Value Reference --------------
|
|
v
{Big Value Len} {Big Value Bytes}
1) Multiple elements:
Value Reference ----------------
|
| // Last value added.
|
v
{Rel Offset Word} [Big Value Len] [Next Value Small Len] {Value Bytes}
| optional optional
|
|
--- . . . ---
|
| // 0 or more
|
v
{Rel Offset Word} [Big Value Len] [Next Value Small Len] {Value Bytes}
| optional optional
|
|
--------------------
|
|
v
[Big Value Length] {Value Bytes}
optional
// First value added without Relative Offset Word, etc.