Expand description
Aggregation module for computing statistics over streaming data
This module provides a comprehensive set of aggregators for computing various statistics over streaming data. All aggregators support:
- Incremental updates: Feed values one at a time
- Batch updates: Feed multiple values at once
- Accumulator merging: Combine results from distributed processing
- State serialization: Persist and restore aggregator state
§Available Aggregators
CountAggregator: Count the number of valuesSumAggregator: Sum all valuesAverageAggregator: Compute the meanMinAggregator: Track the minimum valueMaxAggregator: Track the maximum valuePercentileAggregator: Compute percentiles (p50, p95, p99, etc.)StandardDeviationAggregator: Compute standard deviationCompositeAggregator: Run multiple aggregations in parallel
§Examples
§Basic Usage
use processor::aggregation::{Aggregator, AverageAggregator};
let mut agg = AverageAggregator::new();
agg.update(10.0).unwrap();
agg.update(20.0).unwrap();
agg.update(30.0).unwrap();
assert_eq!(agg.finalize().unwrap(), 20.0);§Distributed Processing
use processor::aggregation::{Aggregator, SumAggregator};
// Process data in parallel
let mut agg1 = SumAggregator::new();
agg1.update_batch(&[1.0, 2.0, 3.0]).unwrap();
let mut agg2 = SumAggregator::new();
agg2.update_batch(&[4.0, 5.0, 6.0]).unwrap();
// Merge results
let acc2 = agg2.accumulator();
agg1.merge(acc2).unwrap();
assert_eq!(agg1.finalize().unwrap(), 21.0);§Composite Aggregation
use processor::aggregation::CompositeAggregator;
let mut composite = CompositeAggregator::new();
composite
.add_count("request_count")
.add_avg("avg_latency")
.add_p95("p95_latency")
.add_stddev("stddev_latency");
// Feed data
for latency in vec![100.0, 150.0, 200.0, 250.0, 300.0] {
composite.update(latency).unwrap();
}
// Get all results at once
let results = composite.finalize().unwrap();
println!("Count: {}", results.get_count("request_count").unwrap());
println!("Avg: {:.2}", results.get_value("avg_latency").unwrap());
println!("P95: {:.2}", results.get_value("p95_latency").unwrap());Modules§
- statistics
- Enhanced statistical utilities for stream processing
Structs§
- Aggregation
Result - Results from a composite aggregation
- Average
Accumulator - Accumulator for average aggregation
- Average
Aggregator - Average aggregator - computes the mean of all values
- Composite
Aggregator - A composite aggregator that runs multiple aggregations in parallel
- Count
Accumulator - Accumulator for count aggregation
- Count
Aggregator - Count aggregator - counts the number of values
- MaxAccumulator
- Accumulator for max aggregation
- MaxAggregator
- Max aggregator - tracks the maximum value seen
- MinAccumulator
- Accumulator for min aggregation
- MinAggregator
- Min aggregator - tracks the minimum value seen
- Percentile
Accumulator - Accumulator for percentile aggregation
- Percentile
Aggregator - Percentile aggregator - computes percentiles (p50, p95, p99, etc.)
- Standard
Deviation Aggregator - Standard deviation aggregator - computes sample standard deviation
- StdDev
Accumulator - Accumulator for standard deviation aggregation
- SumAccumulator
- Accumulator for sum aggregation
- SumAggregator
- Sum aggregator - computes the sum of all values
Traits§
- Aggregator
- Core trait for all aggregators
- ToF64
- Helper trait for converting values to f64 for numeric aggregations