Skip to main content

Module flatengine

Module flatengine 

Source
Expand description

The flat directory layout engines over RawKv and AsyncRawKv views.

One layout, written and tested once here; the synchronous flat backends (btreemap, redb) implement RawKv over their transaction views and route every operation through FlatEngine, while asynchronous flat backends (IndexedDB) implement AsyncRawKv and route through AsyncFlatEngine. FDB does not use these — it uses FDB’s native directory layer over the same row layouts (the crate::flatdir module documents the shared layouts).

The engine’s layout is a verbatim port of FoundationDB’s DirectoryLayer (see crate::flatdir): a node tree of allocated prefixes (packed i64s from the High Contention Allocator), a version row, and HCA counter/recent rows, all under the 0xFE node region. Data keys are prefix ‖ key in the 0x00–0xFD region; 0xFF is reserved.

Stores are opened lazily: a fresh store (no version row) answers empty on reads, and the first create writes the version row. A store whose version row this layout does not read fails every operation with FlatError::Foreign.

Re-exports§

pub use crate::flatdir::error::FlatError;

Structs§

AsyncFlatEngine
The flat directory layout over an asynchronous raw byte view.
DataBounds
The raw engine range of one directory’s data: the resolved prefix and the raw byte bounds over the engine’s whole keyspace. The start bound carries its own inclusion (Included/Excluded); the end bound is always Excluded. Cursor-yielding keys carry the prefix; strip prefix.len() bytes to get the within-directory key.
FlatEngine
The flat directory layout over a raw byte view.

Functions§

map_data_bounds
Map within-directory key bounds onto the raw engine range under an already resolved directory prefix, returning None when the range is empty.