pub struct TableSource { /* private fields */ }Expand description
TableSource — the SQLite-backed leaf source. Mirrors MemorySource’s shape:
the overlay/push/edit-split machinery is shared; only the leaf scan (a real
rusqlite cursor instead of a COW B+tree) and the write path differ.
Implementations§
Source§impl TableSource
impl TableSource
Sourcepub fn new(
db: Rc<Connection>,
table: &str,
columns: Vec<ColumnDef>,
primary_key: Vec<ColId>,
) -> TableSource
pub fn new( db: Rc<Connection>, table: &str, columns: Vec<ColumnDef>, primary_key: Vec<ColId>, ) -> TableSource
Build a source over an existing table in db. Sets the load-bearing
PRAGMA case_sensitive_like = ON (db.ts:45 — makes bare LIKE
case-sensitive, the contract the ILIKE→lower() lowering relies on),
discovers unique indexes, asserts the PK has one (§5.1), and precomputes the
write SQL + the reported Schema.
pub fn try_new( db: Rc<Connection>, table: &str, columns: Vec<ColumnDef>, primary_key: Vec<ColId>, ) -> Result<TableSource, RindleError>
Sourcepub fn new_with_schema(
db: Rc<Connection>,
table: &str,
columns: Vec<ColumnDef>,
primary_key: Vec<ColId>,
schema: SourceSchema,
) -> TableSource
pub fn new_with_schema( db: Rc<Connection>, table: &str, columns: Vec<ColumnDef>, primary_key: Vec<ColId>, schema: SourceSchema, ) -> TableSource
Build a source while preserving the caller’s full reported [Schema]
(notably relationship slots). The SQLite projection still comes from
columns in ColId order; schema is what downstream operators see.
pub fn try_new_with_schema( db: Rc<Connection>, table: &str, columns: Vec<ColumnDef>, primary_key: Vec<ColId>, schema: SourceSchema, ) -> Result<TableSource, RindleError>
Sourcepub fn fork(&self) -> TableSource
pub fn fork(&self) -> TableSource
Cheaply build a new source handle over the same SQLite snapshot and table
metadata, with fresh connections and overlay state. This is the SQLite
peer of MemorySource::fork: useful for
building a clean graph/pipeline around an already-seeded backing store
without re-discovering schema metadata or re-inserting rows.
Sourcepub fn cursors_open(&self) -> i64
pub fn cursors_open(&self) -> i64
Open-cursor count (Primitive #2). 0 ⇒ no cursor is mid-iteration and the
connection is free for a write.
Sourcepub fn take_fetch_error(&self) -> Option<RindleError>
pub fn take_fetch_error(&self) -> Option<RindleError>
Take the error a cursor parked during the last drained fetch (05 §4.5):
a lossy integer-to-f64 conversion in a number column (UnsupportedValue) or a
sqlite3_step failure. None if the fetch drained cleanly. The consumer
drains the stream, THEN calls this — the error is resurfaced, not swallowed.
Sourcepub fn unique_indexes(&self) -> &[Vec<ColId>]
pub fn unique_indexes(&self) -> &[Vec<ColId>]
The unique-key column sets discovered at construction (§5.1). Each is a set
of ColIds in pragma_index_info order.
Sourcepub fn set_db(&self, db: Rc<Connection>)
pub fn set_db(&self, db: Rc<Connection>)
Swap the active snapshot DB handle (setDB, §5.7). In-flight cursors keep
their own Rc<Connection>, so they are unaffected. Full Snapshotter
integration is out of scope; only the handle rebind is wired here.
Sourcepub fn batch_delta(&self) -> Rc<BatchDelta>
pub fn batch_delta(&self) -> Rc<BatchDelta>
The shared BatchDelta this source reads through (design 306, plan D1). The
constructor builds one inactive delta per source; fork() clones the Rc, so
the original and every fork read the same storage. The replica engine retrieves
it here at register_table — before forking — and drives its lifecycle
(begin on snapshot open, end on rollback).
Sourcepub fn set_conn_output(&self, conn: ConnId, edge: OutEdge)
pub fn set_conn_output(&self, conn: ConnId, edge: OutEdge)
Wire a connection’s downstream edge (mirrors input.setOutput).
Sourcepub fn push(&self, change: SourceChange, push_one: &dyn Fn(&Conn, SourceChange))
pub fn push(&self, change: SourceChange, push_one: &dyn Fn(&Conn, SourceChange))
Eager push: fan change to every wired connection (overlay live,
epoch-gated), clear the overlay, then write — via the backend-agnostic
[try_gen_push_and_write_with_split_edit]. The write is committed after
the drain (§3.11), so a reentrant self-join fetch sees the overlay but not
the written row. push_one is the graph’s downstream driver.
pub fn try_push( &self, change: SourceChange, push_one: &dyn Fn(&Conn, SourceChange), strict: bool, ) -> Result<(), RindleError>
Sourcepub fn get_row(&self, key: &[(ColId, OwnedValue)]) -> Option<Row>
pub fn get_row(&self, key: &[(ColId, OwnedValue)]) -> Option<Row>
Retrieve a single row by an arbitrary unique key (getRow, §3.12) — not
used in the IVM pipeline but useful for consistency reads. Builds SELECT <all declared cols> … WHERE keyCols = ? (bare =, like the constraint
path), runs it, and returns an owned row (it is meant to escape) or
None. Use Self::try_get_row to surface SQLite and value-conversion
failures as [RindleError]; this compatibility wrapper panics on those errors.
pub fn try_get_row( &self, key: &[(ColId, OwnedValue)], ) -> Result<Option<Row>, RindleError>
Trait Implementations§
Source§impl ScalarSource for TableSource
The build-time read seam for scalar-subquery resolution
(SCALAR-SUBQUERY-DESIGN.md §8): uniqueness metadata + a point lookup. Distinct
from the runtime [Source] trait — no connect/fetch/push, just a read.
impl ScalarSource for TableSource
The build-time read seam for scalar-subquery resolution
(SCALAR-SUBQUERY-DESIGN.md §8): uniqueness metadata + a point lookup. Distinct
from the runtime [Source] trait — no connect/fetch/push, just a read.
Source§fn unique_keys(&self) -> Vec<Vec<ColId>>
fn unique_keys(&self) -> Vec<Vec<ColId>>
PK first — always available, even for a rowid-alias PK with no separate index
row — then each discovered non-PK unique key (the hardened
discover_unique_indexes set, design §4.1).
Source§fn lookup_unique(&self, bound: &[(ColId, OwnedValue)]) -> Option<Row>
fn lookup_unique(&self, bound: &[(ColId, OwnedValue)]) -> Option<Row>
The single row whose bound key columns match — a real SELECT … WHERE k = ?
point read against the snapshot (TableSource::get_row).
Source§impl Source for TableSource
impl Source for TableSource
Source§fn fetch<'g>(&'g self, conn: ConnId, req: &FetchRequest) -> RowFlow<'g>
fn fetch<'g>(&'g self, conn: ConnId, req: &FetchRequest) -> RowFlow<'g>
#fetch (the hot read path, §5.3). Compile the request to a SELECT
(constraint + multiConstraints + start-prefilter + filter + ORDER BY all
lowered into SQL), open the lazy zero-copy cursor, then drive it through the
shared overlay/start seam. Unlike the memory leaf there is NO committed-row
constraint-trim or filter pass — SQL already did them; the connection’s
predicate narrows only the (not-in-SQL) overlay rows (table-source.ts:297).
Source§fn connect(
&self,
sort: Option<Sort>,
filters: Option<ConnectionFilters>,
split_edit_keys: Vec<ColId>,
) -> ConnId
fn connect( &self, sort: Option<Sort>, filters: Option<ConnectionFilters>, split_edit_keys: Vec<ColId>, ) -> ConnId
sort = None ⇒
unordered. Self-joins call this twice. Builds the [Connection] from the
(07-compiled) filter spec + split-edit keys, and asserts the ordering
includes the PK when ordered. Mirrors connect (memory-source.ts:162).Source§fn conn_sort(&self, conn: ConnId) -> Sort
fn conn_sort(&self, conn: ConnId) -> Sort
Source§fn destroy(&self, conn: ConnId)
fn destroy(&self, conn: ConnId)
Source§fn cursors_open(&self) -> i64
fn cursors_open(&self) -> i64
0 ⇒ no cursor is mid-iteration and the connection is
free for a write.Source§fn try_push(
&self,
change: SourceChange,
push_one: &dyn Fn(&Conn, SourceChange),
strict: bool,
) -> Result<(), RindleError>
fn try_push( &self, change: SourceChange, push_one: &dyn Fn(&Conn, SourceChange), strict: bool, ) -> Result<(), RindleError>
change to every connection (overlay live,
epoch-gated), clear the overlay, then write. push_one is the graph’s
downstream driver. When strict, a malformed change returns a typed
[RindleError] instead of a debug_assert. (A backend may keep a faster
infallible push as an inherent method; this is the object-safe seam the
graph drives.)Source§fn take_error(&self) -> Option<RindleError>
fn take_error(&self) -> Option<RindleError>
05 §4.5);
None if it drained cleanly. Infallible backends always return None.Source§fn set_conn_output(&self, conn: ConnId, edge: OutEdge)
fn set_conn_output(&self, conn: ConnId, edge: OutEdge)
input.setOutput).Source§fn add_guard_value(&self, conn: ConnId, value: OwnedValue)
fn add_guard_value(&self, conn: ConnId, value: OwnedValue)
conn (design 310 §4.1 — a family
root’s binding set growing; see ConnTable::add_guard_value). Required, not
defaulted: a decorator that forgot to forward it would leave the family root
unindexed and silently drop its deltas.Source§fn remove_guard_value(&self, conn: ConnId, value: &OwnedValue)
fn remove_guard_value(&self, conn: ConnId, value: &OwnedValue)
add_guard_value.