Rindle docs and package mapSkip to main content

Crate rindle_sqlite

Crate rindle_sqlite 

Source
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 via GraphTableSourceExt::add_table_source.
  • query_builder — the FetchRequest → parameterized SELECT lowering (05).
  • sqlite — the zero-copy RowStream cursor + 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-TableSource fold of the current transaction’s SourceChanges, 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 of zqlite/src/sqlite-cost-model.ts).
query_builder
build_select_query — the FetchRequest → parameterized SELECT lowering (spec 05 §4.4). A faithful port of packages/zqlite/src/query-builder.ts.
sqlite
Phase 2 — the SQLite leaf: a zero-copy lending [RowStream] over a real rusqlite cursor. 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, a step, and column_*(i) accessors whose text/blob pointers are valid only until the next step/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 of internal/statement-cache.ts.
storage
Spec 10SQLite-backed operator scratch state (the server spill path).
table_source
The server-side leaf [Source]: a Source backed by a SQLite table (the server-side replica of Postgres). Production port of packages/zqlite/src/table-source.ts (class TableSource), the peer of the client-side MemorySource. It owns three things (05 §1.1):

Traits§

GraphTableSourceExt
Adds add_table_source to [rindle::graph::Graph] — the ergonomic equivalent of the former inherent Graph::add_table_source, now that TableSource lives in this crate. Delegates to the core [Graph::add_dyn_source].