Expand description
Large-value codec for the vector B-tree large-value path.
Self-contained byte-slice codec: knows nothing about pages, MVCC,
or overflow chains. encode runs LZ4 and only keeps the
compressed bytes if they are strictly smaller than the input —
otherwise it returns the input verbatim under a Raw flag, so
callers never pay negative-savings storage.
The flag is a single byte. The algorithm (LZ4) lives behind this interface so it can change later without touching callers.
Enums§
- Value
Codec Error - Errors returned by
decode. Encoding is infallible — the codec always has a Raw fallback when LZ4 would grow the input. - Value
Flag - One-byte tag stored alongside the encoded payload. Distinguishes
raw passthrough from compressed bytes so
decodeknows what to do without re-running compression.
Functions§
- decode
- Decode a
(flag, bytes)pair produced byencodeback to the original input bytes. - encode
- Encode
inputfor storage. Returns the flag indicating which representation is stored, plus the bytes themselves. When LZ4 would not shrink the input (including the 4-byte length header), the codec returns(Raw, input.to_vec())— never a longer payload. - would_
encode_ to - Predicate companion to
encode: would the encoded form fit inlimitbytes? Returns the on-disk size the codec would use, without committing to a spill decision. Callers compare the returned size to their page budget and choose to spill or inline without re-running compression — encode is idempotent so re-running after a yes answer is cheap, but this keeps the budget check decoupled from the commit.