Skip to content

Aggregate Fns: Mean#6722

Draft
gatesn wants to merge 2 commits intongates/aggregate-fnsfrom
ngates/aggregate-fns-mean
Draft

Aggregate Fns: Mean#6722
gatesn wants to merge 2 commits intongates/aggregate-fnsfrom
ngates/aggregate-fns-mean

Conversation

@gatesn
Copy link
Contributor

@gatesn gatesn commented Feb 28, 2026

Summary

This PR implements a new Mean aggregate function for computing the arithmetic mean of numeric values in Vortex arrays.

The implementation includes:

  • A new Mean struct that implements the AggregateFnVTable trait
  • A MeanAccumulator that maintains running sum and count statistics
  • Support for both integer and floating-point input types, with f64 output
  • Proper handling of null values through validity masks
  • State management for distributed aggregation scenarios through merge operations
  • Automatic registration of the Mean function in the default AggregateFnSession

The accumulator efficiently processes batches by converting all numeric types to f64 and tracking valid values based on the array's validity mask. It supports flushing intermediate results for grouped operations and merging state from other accumulators for distributed computation.

Testing

The implementation includes comprehensive unit tests covering:

  • Basic mean calculation for i32 and f64 arrays
  • Null value handling (partial nulls and all-null arrays)
  • Empty flush scenarios
  • Multi-group aggregation with flush operations
  • State merging functionality for distributed aggregation

All tests verify correct f64 output values and proper null handling in edge cases.

Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Copy link
Contributor Author

gatesn commented Feb 28, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gatesn gatesn mentioned this pull request Feb 28, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 28, 2026

Merging this PR will degrade performance by 18.01%

❌ 3 regressed benchmarks
✅ 951 untouched benchmarks
⏩ 1466 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation bench_many_nulls[0.9] 481.8 µs 547.1 µs -11.94%
Simulation take_map[(0.1, 0.1)] 916.5 µs 1,032.1 µs -11.21%
Simulation take_map[(0.1, 1.0)] 3.6 ms 4.4 ms -18.01%

Comparing ngates/aggregate-fns-mean (1f43f0b) with ngates/aggregate-fns (6d9bcac)

Open in CodSpeed

Footnotes

  1. 1466 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@gatesn gatesn mentioned this pull request Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant