pub struct View {
pub input: NodeId,
pub schema: Arc<Schema>,
pub with_ids: bool,
pub root: RefCell<Arc<Entry>>,
/* private fields */
}Expand description
The materialization sink (ports ArrayView). Lives in the arena as
Operator::View; its graph-touching halves (hydrate/view_push) are
Graph methods that delegate the pure folding to [apply_change].
Fields§
§input: NodeIdUpstream operator we fetch/receive pushes from.
schema: Arc<Schema>Output schema of input (hierarchical; names resolved to ColId/RelId).
This is also the view shape: a relationship slot is in-view iff its RelDef
carries a child schema (rel_child(slot).is_some()).
with_ids: boolAlways false for ArrayView (09 §1.2); kept for a future SolidView.
root: RefCell<Arc<Entry>>The synthetic root. root[""] is the top-level result; Arc-shared
subtrees give reference stability.
Implementations§
Source§impl View
impl View
Sourcepub fn new(
input: NodeId,
schema: Schema,
with_ids: bool,
result_type: ResultType,
) -> View
pub fn new( input: NodeId, schema: Schema, with_ids: bool, result_type: ResultType, ) -> View
Construct a View over input with the given hierarchical schema (which
also carries the view shape). The caller (Graph::add_array_view) then
hydrates it.
Sourcepub fn result_type(&self) -> ResultType
pub fn result_type(&self) -> ResultType
Current result type.
Sourcepub fn set_result_type(&self, rt: ResultType)
pub fn set_result_type(&self, rt: ResultType)
Set the result type (the async queryComplete resolution, 09 §3.8). Fires
listeners out of band (it does not touch the txn dirty state).
Sourcepub fn add_listener(&self, l: Listener) -> usize
pub fn add_listener(&self, l: Listener) -> usize
Register a listener; fires it once immediately with the current snapshot
(addListener, array-view.ts:115). Returns the index (for removal).
Sourcepub fn listener_count(&self) -> usize
pub fn listener_count(&self) -> usize
Number of registered listeners (test/inspection helper).
Sourcepub fn mark_dirty(&self)
pub fn mark_dirty(&self)
Mark the view dirty (a push happened). view_push (in graph.rs) calls
this before folding the change.
Sourcepub fn flush(&self)
pub fn flush(&self)
flush (array-view.ts:173): if dirty, fire listeners with the snapshot,
then bump the txn generation (so the next txn copy-on-writes again — the
fresh-WeakSet analogue). No-op when not dirty.
Sourcepub fn txn_gen(&self) -> TxnGen
pub fn txn_gen(&self) -> TxnGen
The current transaction generation (used by view_push/hydrate).
Sourcepub fn hydrate_from<'g>(&self, nodes: impl Iterator<Item = Node<'g>>)
pub fn hydrate_from<'g>(&self, nodes: impl Iterator<Item = Node<'g>>)
Hydrate the tree from the input’s fetch stream (the caller supplies the
already-fetched node iterator so the Graph borrow stays with the caller).
Builds InPlace (the root is unobserved), then flushes once
(array-view.ts:140-157).
Sourcepub fn push_change<'g>(&self, change: Change<'g>)
pub fn push_change<'g>(&self, change: Change<'g>)
Fold one dataflow Change into the tree
(array-view.ts:159-171). Transaction-scoped COW: takes the root out (so
owned spine objects are uniquely held and mutate in place), applies, writes
back. Does not flush — the caller flushes at the transaction boundary
(the legacy source_push tests read the tree directly without flushing,
which is fine: the change is applied to root synchronously).
Sourcepub fn dump_col0(&self) -> Vec<(i64, Vec<i64>)>
pub fn dump_col0(&self) -> Vec<(i64, Vec<i64>)>
[(col0_id, [child_col0_id, …]), …] — top rows + their children’s col-0
ids, children flattened across all relationship slots in slot order (the
spike dump_view contract). Assumes col 0 is Int.
Sourcepub fn dump_rows(&self) -> Vec<(Vec<i64>, Vec<Vec<i64>>)>
pub fn dump_rows(&self) -> Vec<(Vec<i64>, Vec<Vec<i64>>)>
[(full_int_row, [child_full_int_row, …]), …] — like View::dump_col0
but every column as i64 (so an edit’s non-key value is observable).
Sourcepub fn dump_col0_deep(&self) -> Vec<Col0Node>
pub fn dump_col0_deep(&self) -> Vec<Col0Node>
Recursive col-0 dump: each entry’s col-0 id plus its children’s (recursively,
across all relationship slots in slot order). The deep counterpart of
View::dump_col0 — surfaces grandchildren, so a nested relationship
(issue{comments{reactions}}) is fully observable. Assumes col 0 is Int.