pub trait Accumulator {
type State;
type Update;
// Required methods
fn accumulate(
&self,
state: &mut Self::State,
update: Self::Update,
) -> Result<()>;
fn reducer_spec(&self) -> Option<ReducerSpec>;
}Expand description
An accumulator is a object that accumulates updates into a state.
Required Associated Types§
Sourcetype Update
type Update
The type of the updates sent to the accumulator. Updates will be accumulated into type Self::State.
Required Methods§
Sourcefn accumulate(
&self,
state: &mut Self::State,
update: Self::Update,
) -> Result<()>
fn accumulate( &self, state: &mut Self::State, update: Self::Update, ) -> Result<()>
Accumulate an update into the current state.
Sourcefn reducer_spec(&self) -> Option<ReducerSpec>
fn reducer_spec(&self) -> Option<ReducerSpec>
The specification used to build the reducer.
Implementors§
Source§impl<T> Accumulator for ValueMesh<T>
Accumulates sparse overlay updates into an authoritative mesh.
impl<T> Accumulator for ValueMesh<T>
Accumulates sparse overlay updates into an authoritative mesh.
Lifecycle:
- Mailbox initializes
StateviaDefault(empty mesh). - On the first update, the accumulator clones
self(the template passed toopen_accum_port_opts) intostate. Callers pass a template such asStatusMesh::from_single(region, NotExist). - Each overlay update is merged with right-wins semantics via
merge_from_overlay, and the accumulator emits a full ValueMesh.
The accumulator’s state is a ValueMesh<T> and its updates are
ValueOverlay<T> instances. On each update, the overlay’s
normalized runs are merged into the mesh using
ValueMesh::merge_from_overlay with right-wins semantics.
This enables incremental reduction of sparse updates across distributed reducers without materializing dense data.