1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! Uncompiled reactive map operation chains.
//!
//! A [`MapQuery`] is a recipe for a reactive map computation — a chain of
//! pure operators (joins, projections, selections) that has not yet been
//! materialized into a [`CellMap`]. Map queries deliberately do not implement
//! `subscribe`: to observe output you must call [`MapQuery::materialize`],
//! which installs ONE subscription per root source and returns a
//! subscribable cell map.
//!
//! This design makes the memoization boundary explicit. Today, chaining map
//! operators (`inner_join`, `left_join`, `project`, ...) creates an
//! intermediate [`CellMap`] per stage — each with its own diff cell and
//! per-key cells. By moving these operators onto `MapQuery`, the cost of an
//! intermediate map is paid only when the caller explicitly asks for one
//! with `.materialize()`.
use ;
use crate::;
pub
pub use ;
/// Boxed diff sink shape used by every [`MapQueryInstall::install`] hop.
///
/// A sink consumes diffs from an upstream stage and applies them to a
/// downstream stage's state (or, at the materialize boundary, to the output
/// [`CellMap`]). Sinks are `Arc`-cloneable so a stage can fan out to multiple
/// downstream consumers if needed.
pub type MapDiffSink<K, V> = ;
/// Crate-private installer hook used by [`MapQuery::materialize`].
///
/// `install` consumes the plan node, subscribes upstream sources, and pipes
/// the diff stream to the provided sink. Returns guards owning upstream
/// subscriptions and any per-stage state that must outlive the materialized
/// output cell map.
///
/// This is separate from [`MapQuery`] so that the public trait stays minimal
/// and cannot be accidentally used to subscribe without materializing.
pub
/// Uncompiled reactive map operation chain.
///
/// Map queries are built by chaining pure operators on a source ([`CellMap`]
/// or another `MapQuery`). They deliberately do not expose `subscribe` —
/// call [`MapQuery::materialize`] to produce a subscribable [`CellMap`].
///
/// # Invariants
///
/// - `materialize(self)` consumes the plan and installs ONE subscription per
/// root source running the fully fused diff-propagation closure.
/// - No intermediate `CellMap` is allocated anywhere in a query chain.
///
/// # Sealing
///
/// The `MapQueryInstall<K, V>` supertrait is `pub(crate)`, which seals
/// `MapQuery` so external crates cannot define new query shapes. New plan
/// shapes are added inside this crate.
///
/// # Not `Clone`
///
/// Map queries are deliberately not `Clone`. Cloning would silently
/// duplicate join / projection work — each clone's `materialize()` would
/// install independent root subscriptions and run the entire op chain on
/// every emission. To share work across consumers, materialize once into a
/// [`CellMap`] (which IS `Clone` — the clone is an `Arc` bump referencing
/// the same multicast cache) and then clone the cell map.