Expand description
§rindle-sqlite — the SQLite backend for the [rindle] IVM engine
Split out of the core rindle crate so the engine stays std-only / wasm-clean (no
rusqlite, no C toolchain). This crate owns the native-server leaf and its
supporting machinery:
table_source::TableSource— a [rindle::graph::Source] backed by a SQLite table (05): lazy zero-copy cursor reads + write-through pushes, plugged into a graph viaGraphTableSourceExt::add_table_source.query_builder— theFetchRequest→ parameterizedSELECTlowering (05).sqlite— the zero-copyRowStreamcursor + value marshalling.stmt_cache— a prepared-statement cache.storage— the spill-to-SQLite operator storage (DatabaseStorage/OpStorage), plugged into a graph via [rindle::storage::StorageFactory::custom].
It links the SAME vendored bedrock SQLite as the rest of the workspace through the
root [patch.crates-io] redirect, so no build.rs is needed here.
Re-exports§
pub use batch_delta::BatchDelta;pub use batch_delta::DeltaBudget;pub use batch_delta::DeltaLookup;pub use batch_delta::DEFAULT_MAX_DELTA_BYTES;pub use cost_model::btree_cost;pub use cost_model::SqliteCostModel;pub use query_builder::build_select_query;pub use query_builder::ColumnDef;pub use query_builder::CompiledQuery;pub use query_builder::SqliteParam;pub use storage::DatabaseStorage;pub use storage::DatabaseStorageOptions;pub use storage::OpStorage;pub use table_source::TableSource;
Modules§
- batch_
delta - The in-memory batch delta (
designs/306-BATCH-OVERLAY-DESIGN.md§4, impl plan §3): a per-TableSourcefold of the current transaction’sSourceChanges, standing in for the throwaway derivation writes the historical write-then-abort path performed (deleted with 306 S5). During a derivation, change k+1 must read a base state that already includes changes 1..k; this structure holds exactly that divergence from the pinned base snapshot, so the derivation connection can stay read-only. - cost_
model SqliteCostModel— a planner [ConnectionCostModel] backed by real SQLite statistics (port ofzqlite/src/sqlite-cost-model.ts).- query_
builder build_select_query— theFetchRequest→ parameterizedSELECTlowering (spec05§4.4). A faithful port ofpackages/zqlite/src/query-builder.ts.- sqlite
- Phase 2 — the SQLite leaf: a zero-copy lending [
RowStream] over a realrusqlitecursor. This is the hardest backend for the canonical value model (value.rs) to satisfy, and the reason the model is designed here rather than in the abstract: a SQLite statement has no row — only a prepared statement, astep, andcolumn_*(i)accessors whose text/blob pointers are valid only until the nextstep/reset. The borrow checker turns a use-after-step into a compile error, and forces an owned copy at exactly the points the JS already copies. - stmt_
cache - The prepared-statement cache (spec
05§4.3) — a thin wrapper over rusqlite’s built-in per-connection statement cache, not a from-scratch port ofinternal/statement-cache.ts. - storage
- Spec
10— SQLite-backed operator scratch state (the server spill path). - table_
source - The server-side leaf [
Source]: aSourcebacked by a SQLite table (the server-side replica of Postgres). Production port ofpackages/zqlite/src/table-source.ts(class TableSource), the peer of the client-sideMemorySource. It owns three things (05§1.1):
Traits§
- Graph
Table Source Ext - Adds
add_table_sourceto [rindle::graph::Graph] — the ergonomic equivalent of the former inherentGraph::add_table_source, now thatTableSourcelives in this crate. Delegates to the core [Graph::add_dyn_source].