Skip to main content

Module ordered_codec

Module ordered_codec 

Source
Expand description

Ordered key codec — order-preserving binary encoding for Value.

The byte-level comparison of encoded values matches the semantic ordering of values within the same index type. Distinct types are ordered by their stable type tags. This enables range and prefix scans on index keys without post-filtering while preserving the original value type in the key format.

§Format (version 2)

Each field starts with a type tag byte, followed by the encoded body. Fixed-length types encode to a fixed byte count; variable-length types (String, Blob) use an escaped 0x00 terminator. A zero byte in the data is encoded as 00 01; the terminator is 00 00.

The terminator enables tight prefix upper bounds: for a string or blob prefix value P, the range scan bound is [encode(P), tag + prefix_upper_bound(P_data_bytes)), covering all values that start with P and excluding those that do not.

Composite keys concatenate multiple field encodings; the entity tie-breaker is appended as the final field.

Structs§

OrderedCodec
Order-preserving codec for index keys.

Constants§

ORDERED_CODEC_VERSION
Current wire format version.