barrel_design_reduce (barrel_design v0.1.0)
View SourceOne group totalled by a Wasm reducer at read time, within bounds.
Values arrive in index order (key, document id, ordinal). A leaf call takes 1 to max_reduce_values values within max_reduce_bytes; a rereduce call takes 2 to max_reduce_values partials within the same bytes. Every value and partial is at most max_value_bytes, and max_reduce_bytes >= 2 * max_value_bytes + 16, so two partials always fit one call and combining always makes progress.
The state is a carried partial P, covering the group from its first row to the row at key K, plus pending partials and a leaf buffer after K: at most two max_reduce_bytes of values and P. When the pending partials and P could no longer take another partial, they combine into a new P. A deadline stop carries P and K without a guest call; a scan stop first combines everything into P. The reducer is never called with zero values.
Summary
Functions
What a deadline stop can carry without calling the guest: the partial P and the key it covers up to, or none.
Everything folded into one partial, for a scan stop: {P, K}.
The group's result.
A group whose first row is at key First.
A group carried in a continuation: P covers it up to key K.
Types
-type reducer() :: #{call := fun(([term()], boolean()) -> {ok, term()} | {error, term()}), values := pos_integer(), bytes := pos_integer(), value_bytes := pos_integer()}.
-type state() :: map().
Functions
What a deadline stop can carry without calling the guest: the partial P and the key it covers up to, or none.
Everything folded into one partial, for a scan stop: {P, K}.
The group's result.
A group whose first row is at key First.
A group carried in a continuation: P covers it up to key K.