avgMergeState
Description
TheMergeState combinator
can be applied to the avg
function to merge partial aggregate states of type AverageFunction(avg, T) and
return a new intermediate aggregation state.
Example usage
TheMergeState combinator is particularly useful for multi-level aggregation
scenarios where you want to combine pre-aggregated states and maintain them as
states (rather than finalizing them) for further processing. To illustrate, we’ll
look at an example in which we transform individual server performance metrics
into hierarchical aggregations across multiple levels: Server level → Region level
→ Datacenter level.
First we create a table to store the raw data:
- Service level
- Regional level
- Datacenter level