Skip to main content

Accumulator

Trait Accumulator 

Source
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§

Source

type State

The type of the accumulated state.

Source

type Update

The type of the updates sent to the accumulator. Updates will be accumulated into type Self::State.

Required Methods§

Source

fn accumulate( &self, state: &mut Self::State, update: Self::Update, ) -> Result<()>

Accumulate an update into the current state.

Source

fn reducer_spec(&self) -> Option<ReducerSpec>

The specification used to build the reducer.

Implementors§

Source§

impl<T> Accumulator for ValueMesh<T>
where T: Eq + Clone + Named,

Accumulates sparse overlay updates into an authoritative mesh.

Lifecycle:

  • Mailbox initializes State via Default (empty mesh).
  • On the first update, the accumulator clones self (the template passed to open_accum_port_opts) into state. Callers pass a template such as StatusMesh::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.