Rindle docs and package mapSkip to main content

TableSource

Struct TableSource 

Source
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

Source

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 ILIKElower() lowering relies on), discovers unique indexes, asserts the PK has one (§5.1), and precomputes the write SQL + the reported Schema.

Source

pub fn try_new( db: Rc<Connection>, table: &str, columns: Vec<ColumnDef>, primary_key: Vec<ColId>, ) -> Result<TableSource, RindleError>

Source

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.

Source

pub fn try_new_with_schema( db: Rc<Connection>, table: &str, columns: Vec<ColumnDef>, primary_key: Vec<ColId>, schema: SourceSchema, ) -> Result<TableSource, RindleError>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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_tablebefore forking — and drives its lifecycle (begin on snapshot open, end on rollback).

Source

pub fn set_conn_output(&self, conn: ConnId, edge: OutEdge)

Wire a connection’s downstream edge (mirrors input.setOutput).

Source

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.

Source

pub fn try_push( &self, change: SourceChange, push_one: &dyn Fn(&Conn, SourceChange), strict: bool, ) -> Result<(), RindleError>

Source

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.

Source

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.

Source§

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>

The single row whose bound key columns match — a real SELECT … WHERE k = ? point read against the snapshot (TableSource::get_row).

Source§

fn schema(&self) -> &Schema

The child table’s schema (column names → [ColId], primary key).
Source§

impl Source for TableSource

Source§

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

Register a new connection (one downstream output). 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 schema(&self) -> &Schema

The schema of rows this source vends.
Source§

fn conn_sort(&self, conn: ConnId) -> Sort

The effective sort for a connection. This can differ from the table schema’s default/primary sort, and ordered downstream operators must use this.
Source§

fn destroy(&self, conn: ConnId)

Drop a connection’s downstream edge so it stops receiving pushes. Does NOT delete the backing indexes (§3.10).
Source§

fn cursors_open(&self) -> i64

Open-cursor count — 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>

Eager fallible push: fan 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>

Take any error a cursor parked during the last drained fetch (05 §4.5); None if it drained cleanly. Infallible backends always return None.
Source§

fn set_conn_output(&self, conn: ConnId, edge: OutEdge)

Wire a connection’s downstream output edge (mirrors input.setOutput).
Source§

fn add_guard_value(&self, conn: ConnId, value: OwnedValue)

Add a dynamic push-index guard value to 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)

Remove one dynamic guard value added with add_guard_value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,