Skip to main content

Module key

Module key 

Source
Expand description

Binary key encoding and decoding for document and index records.

Every persisted record in kora-doc is addressed by a compact binary key whose first byte is a KeyTag discriminant. The remaining bytes encode collection IDs, document IDs, field IDs, value hashes, or sequence numbers in little-endian order.

§Key Layouts

TagLayoutSizePurpose
0x01[tag][col:2][doc:4]7Hot document
0x02..0x05, 0x20[tag][col:2]3Collection metadata / schema / dictionary / registry / CDC head
0x06[tag][col:2][doc:4]7Cold-tier document
0x10, 0x12, 0x13[tag][col:2][field:2][vhash:4]10Hash / array / unique index bucket
0x11[tag][col:2][field:2]5Sorted index
0x14[tag][col:2][f1:2][f2:2][vhash:4]11Compound index bucket
0x21[tag][col:2][seq:8]11CDC event

All encode/decode functions are symmetric: encoding produces a fixed-size byte array, and decoding validates length and tag before extracting fields. Malformed keys surface as KeyDecodeError.

Enums§

KeyDecodeError
Binary key decode errors.
KeyTag
Key tags used in compact binary key encoding.

Functions§

decode_cdc_event_key
Decode [0x21][col:2][seq:8].
decode_cold_doc_key
Decode [0x06][col:2][doc:4].
decode_collection_key
Decode [tag][col:2].
decode_compound_index_key
Decode [0x14][col:2][f1:2][f2:2][vhash:4].
decode_doc_key
Decode [0x01][col:2][doc:4].
decode_hashed_bucket_key
Decode [tag][col:2][field:2][vhash:4].
decode_sorted_index_key
Decode [0x11][col:2][field:2].
encode_cdc_event_key
Encode [0x21][col:2][seq:8].
encode_cold_doc_key
Encode [0x06][col:2][doc:4].
encode_collection_key
Encode [tag][col:2] keys (0x02..0x05, 0x20).
encode_compound_index_key
Encode [0x14][col:2][f1:2][f2:2][vhash:4].
encode_doc_key
Encode [0x01][col:2][doc:4].
encode_hashed_bucket_key
Encode [tag][col:2][field:2][vhash:4].
encode_sorted_index_key
Encode [0x11][col:2][field:2].