Rindle docs and package mapSkip to main content

CountingSource

Struct CountingSource 

Source
pub struct CountingSource { /* private fields */ }
Expand description

A Source decorator that counts the rows crossing the connection boundary — the one new measurement the analyze query diagnostic needs (designs-implemented/ANALYZE-QUERY-DESIGN.md §3.4). It wraps any object-safe Source and delegates every method to inner unchanged, except fetch, whose returned RowFlow is wrapped in a lazy .inspect that bumps emitted once per row as the row is pulled. Because it counts inner.fetch()’s final stream — after the backend’s overlay/start/constraint/filter chain and across both the ordered and unordered fetch paths — it sees exactly what the pipeline sees, on either backend (SQLite or memory), and a downstream Take that abandons the stream early counts only what it consumed (the correct “emitted into the pipeline” semantics).

This is installed only on the throwaway pipeline analyze_query builds; the live Graph::fetch and every live source stay byte-for-byte unchanged — there is no branch or wrapper on any steady-state fetch or push. The only per-analyze cost is one vtable hop plus one Cell increment per emitted row.

Implementations§

Source§

impl CountingSource

Source

pub fn new(inner: Box<dyn Source>, emitted: EmitCounter) -> CountingSource

Wrap inner; rows it emits are tallied into emitted (a cell the caller keeps a clone of, to read the total back after hydration).

Trait Implementations§

Source§

impl Source for CountingSource

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 fetch<'g>(&'g self, conn: ConnId, req: &FetchRequest) -> RowFlow<'g>

Lazy pull for conn: a stream of rows in (reverse-aware) sort order, overlay-spliced, start-gated, constraint-trimmed, filtered. A source emits rows; the SourceConn operator wraps them in leaf nodes (Graph::fetch).
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 schema(&self) -> &Schema

The schema of rows this source vends.
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(&Connection, 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.