pub struct DagTopology {
pub views: Vec<ViewDescriptor>,
pub edges: Vec<DagEdge>,
pub topo_order: Vec<ViewId>,
}Expand description
The static topology of the IVM DAG.
Built once when the view pipeline is constructed. The topological order is pre-computed and cached for efficient per-epoch propagation.
§Invariants
- The DAG is acyclic (enforced on edge insertion).
- Topological order includes all views.
- For every edge (A, B), A appears before B in the topological order.
- Adding or removing views invalidates the cached topological order.
Fields§
§views: Vec<ViewDescriptor>All views in the DAG, indexed by ViewId.
edges: Vec<DagEdge>All edges in the DAG.
topo_order: Vec<ViewId>Pre-computed topological order (view indices).
Implementations§
Source§impl DagTopology
impl DagTopology
Sourcepub fn add_view(
&mut self,
label: impl Into<String>,
domain: ViewDomain,
) -> ViewId
pub fn add_view( &mut self, label: impl Into<String>, domain: ViewDomain, ) -> ViewId
Add a view to the DAG. Returns its ViewId.
Sourcepub fn add_edge(&mut self, from: ViewId, to: ViewId)
pub fn add_edge(&mut self, from: ViewId, to: ViewId)
Add an edge: from produces deltas consumed by to.
§Panics
Panics if this would create a cycle in the DAG.
Sourcepub fn compute_topo_order(&mut self)
pub fn compute_topo_order(&mut self)
Compute the topological order via Kahn’s algorithm.
Must be called after all views and edges are added. The result is
cached in self.topo_order for efficient per-epoch propagation.
§Panics
Panics if the DAG contains a cycle (should be impossible due to
add_edge validation, but checked defensively).
Sourcepub fn downstream(&self, view_id: ViewId) -> Vec<ViewId>
pub fn downstream(&self, view_id: ViewId) -> Vec<ViewId>
Get the downstream views that consume deltas from view_id.
Sourcepub fn upstream(&self, view_id: ViewId) -> Vec<ViewId>
pub fn upstream(&self, view_id: ViewId) -> Vec<ViewId>
Get the upstream views that produce deltas for view_id.
Sourcepub fn view_count(&self) -> usize
pub fn view_count(&self) -> usize
Number of views in the DAG.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of edges in the DAG.
Trait Implementations§
Source§impl Clone for DagTopology
impl Clone for DagTopology
Source§fn clone(&self) -> DagTopology
fn clone(&self) -> DagTopology
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more