Expand description
§kora-doc
Document layer that turns Kora from a key-value cache engine into a JSON-native document database. Documents are stored in a compact binary packed format, queried via a WHERE expression parser, and indexed through four secondary index types (hash, sorted, array, unique).
§Architecture
A JSON document passes through a pipeline of transformations before it reaches storage:
-
Decomposition (
decompose) – a JSON object is recursively walked, each leaf field is assigned a numericFieldIdvia theIdRegistry, string values are dictionary-encoded when their field cardinality is low, and the result is assembled into aPackedDoc. -
Packed encoding (
packed) – fields are stored in a flat binary buffer with an offset table sorted by field ID, enabling O(log F) single-field reads via binary search. -
Recomposition (
recompose) – the inverse of decomposition, rebuilding aserde_json::Valuefrom packed bytes, dictionary lookups, and registry path resolution. Supports full reconstruction or field-level projection.
§Key Modules
| Module | Purpose |
|---|---|
packed | Binary packed document format and builder |
registry | Integer-keyed ID mapping for collections, fields, and docs |
dictionary | Dictionary encoding for low-cardinality string values |
decompose | JSON to packed document conversion |
recompose | Packed document to JSON reconstruction |
engine | Collection CRUD, index maintenance, and query execution |
expr | WHERE clause recursive-descent parser |
index | Hash, sorted, array, and unique secondary indexes |
collection | Collection metadata and configuration |
key | Binary key encoding for storage and index records |
Re-exports§
pub use collection::Collection;pub use collection::CollectionConfig;pub use collection::CollectionError;pub use collection::CompressionProfile;pub use decompose::DecomposeError;pub use decompose::Decomposer;pub use dictionary::DictionaryError;pub use dictionary::StoredValue;pub use dictionary::ValueDictionary;pub use dictionary::ValueDictionaryConfig;pub use engine::CollectionInfo;pub use engine::DictionaryFieldInfo;pub use engine::DictionaryInfo;pub use engine::DocEngine;pub use engine::DocError;pub use engine::DocMutation;pub use engine::InsertResult;pub use engine::SetResult;pub use engine::StorageInfo;pub use expr::Expr;pub use expr::ExprError;pub use expr::ExprValue;pub use index::hash32;pub use index::CollectionIndexes;pub use index::IndexConfig;pub use index::IndexError;pub use index::IndexType;pub use key::decode_cdc_event_key;pub use key::decode_cold_doc_key;pub use key::decode_collection_key;pub use key::decode_compound_index_key;pub use key::decode_doc_key;pub use key::decode_hashed_bucket_key;pub use key::decode_sorted_index_key;pub use key::encode_cdc_event_key;pub use key::encode_cold_doc_key;pub use key::encode_collection_key;pub use key::encode_compound_index_key;pub use key::encode_doc_key;pub use key::encode_hashed_bucket_key;pub use key::encode_sorted_index_key;pub use key::KeyDecodeError;pub use key::KeyTag;pub use packed::FieldValue;pub use packed::PackedDoc;pub use packed::PackedDocBuilder;pub use packed::PackedDocError;pub use packed::PackedDocIter;pub use recompose::RecomposeError;pub use recompose::Recomposer;pub use registry::CollectionId;pub use registry::DocId;pub use registry::FieldId;pub use registry::IdRegistry;pub use registry::RegistryError;pub use registry::RegistrySegment;pub use registry::RegistrySegmentRef;
Modules§
- collection
- Collection metadata and configuration.
- decompose
- JSON-to-packed-document decomposition pipeline.
- dictionary
- Dictionary encoding for low-cardinality string field values.
- engine
- In-memory document engine providing collection CRUD, secondary indexes, and WHERE-clause query execution.
- expr
- Recursive-descent parser for WHERE-clause filter expressions.
- index
- Secondary index data structures for document collections.
- key
- Binary key encoding and decoding for document and index records.
- packed
- Compact binary packed document format.
- recompose
- Packed document to JSON reconstruction pipeline.
- registry
- Integer-keyed ID registry for collections, fields, and documents.