Skip to main content

Module engine

Module engine 

Source
Expand description

In-memory document engine providing collection CRUD, secondary indexes, and WHERE-clause query execution.

DocEngine is the top-level entry point. It owns an IdRegistry, a map of per-collection state (metadata, dictionary, packed documents, and indexes), and orchestrates the full document lifecycle:

§Write Path

  1. The caller supplies a JSON Value to DocEngine::set.
  2. The engine resolves (or allocates) a DocId via the registry.
  3. Unique-constraint indexes are checked before mutation.
  4. If the document already exists, old index entries are removed.
  5. The JSON is decomposed into a PackedDoc through the Decomposer pipeline.
  6. New index entries are inserted for every configured field.

§Read Path

  • DocEngine::get retrieves and recomposes a single document, with optional field-level projection.
  • DocEngine::find parses a WHERE expression via parse_where, walks the AST to collect candidate DocId sets (using indexes when available, falling back to a full collection scan), applies pagination, and recomposes results.

§Index Maintenance

DocEngine::create_index registers a secondary index and backfills every existing document. Four index types are supported: Hash, Sorted, Array, and Unique. Index entries are maintained automatically on set, update, and del.

§Mutation

DocEngine::update applies a sequence of DocMutation operations (Set, Del, Incr, Push, Pull) to an existing document’s JSON representation, then round-trips through set so indexes and packed storage stay consistent.

Structs§

CollectionInfo
Snapshot of collection metadata and current storage counters.
DictionaryFieldInfo
Cardinality details for one collection field.
DictionaryInfo
Snapshot of collection dictionary statistics.
DocEngine
Document engine with collection-local dictionaries and packed docs.
InsertResult
Result of a DocEngine::insert call with an auto-generated ID.
SetResult
Result of a successful set operation.
StorageInfo
Snapshot of collection storage footprint.

Enums§

DocError
Errors returned by DocEngine.
DocMutation
Mutation operation used by DocEngine::update.