Interface SoftBPlusTree.ValueSerializer<V>

Type Parameters:
V - value type
Enclosing class:
SoftBPlusTree<V>

public static interface SoftBPlusTree.ValueSerializer<V>
Serializes and deserializes values stored in leaf nodes. Values are written contiguously after the key-parts section of a serialized leaf node, so the serialized size of every value must be fixed or self-describing.

Important: every value in a leaf must serialize to exactly serializedSize(V) bytes. The tree relies on this for in-place value overwrites — when a key's value is replaced, only that value's bytes are rewritten at a calculated offset within the serialized node, without re-serializing the entire node.

  • Method Summary

    Modifier and Type
    Method
    Description
    read(ByteBuffer buffer)
    Reads a value from buffer starting at its current position.
    int
    Returns the number of bytes that write(V, ByteBuffer) will produce for value.
    void
    write(V value, ByteBuffer buffer)
    Writes the serialized form of value into buffer starting at the buffer's current position.
  • Method Details

    • write

      void write(V value, ByteBuffer buffer)
      Writes the serialized form of value into buffer starting at the buffer's current position. Must advance the position by exactly serializedSize(value) bytes.
    • read

      V read(ByteBuffer buffer)
      Reads a value from buffer starting at its current position. Must advance the position by exactly the number of bytes that were written by write(V, ByteBuffer) for this value.
    • serializedSize

      int serializedSize(V value)
      Returns the number of bytes that write(V, ByteBuffer) will produce for value. Must be consistent with write(V, ByteBuffer) — the buffer position must advance by exactly this amount.