package granary
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=8b18780ea373be48301d9f333925860a2f9110fc0ac28684295118d72b65a67e
sha512=25ca3c9c5e2b528704a542502e0f37dc33ba003f65622d969b8c2b800778585f8ef0cf89b36e6679832e3993e8303aecddfc662742baf7044d6afe4a796b8f11
doc/granary.ivm/Granary_ivm/Aggregate/index.html
Module Granary_ivm.AggregateSource
Incremental grouped aggregation over Z-sets (#417 Phase 2).
Maintains a SUM-style aggregate per group: each input element contributes measure element * weight to its group's running value, and the group's existence is tracked by its total weight (so COUNT is the special case measure = fun _ -> 1). Given an input delta, step returns the output delta that retracts each changed group's old (group, value) row and inserts its new one — keeping the result relation current without rescanning the input. A group's row is present iff its total weight is > 0, and each present group yields exactly one output row.
The measure is additive, which is what makes the running total maintainable from a delta (this covers COUNT, SUM, and AVG as sum-with-count). Order-sensitive aggregates (MIN/MAX) cannot be expressed this way — a retraction can lower the current extremum, which needs the full group, not a running scalar — and are out of scope here.
What to aggregate: the input/output Z-set domains, the grouping key, the per-element measure, and how to render a (group, value) result row.