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
impl CountingSource
Sourcepub fn new(inner: Box<dyn Source>, emitted: EmitCounter) -> CountingSource
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
impl Source for CountingSource
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 fetch<'g>(&'g self, conn: ConnId, req: &FetchRequest) -> RowFlow<'g>
fn fetch<'g>(&'g self, conn: ConnId, req: &FetchRequest) -> RowFlow<'g>
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
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(&Connection, SourceChange),
strict: bool,
) -> Result<(), RindleError>
fn try_push( &self, change: SourceChange, push_one: &dyn Fn(&Connection, 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.