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
| Tag | Layout | Size | Purpose |
|---|---|---|---|
0x01 | [tag][col:2][doc:4] | 7 | Hot document |
0x02..0x05, 0x20 | [tag][col:2] | 3 | Collection metadata / schema / dictionary / registry / CDC head |
0x06 | [tag][col:2][doc:4] | 7 | Cold-tier document |
0x10, 0x12, 0x13 | [tag][col:2][field:2][vhash:4] | 10 | Hash / array / unique index bucket |
0x11 | [tag][col:2][field:2] | 5 | Sorted index |
0x14 | [tag][col:2][f1:2][f2:2][vhash:4] | 11 | Compound index bucket |
0x21 | [tag][col:2][seq:8] | 11 | CDC 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§
- KeyDecode
Error - 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].