Skip to content

Commit

Permalink
Speed up avg
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniël Heres committed Jul 5, 2023
1 parent ffd5cbe commit 6846970
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 3 additions & 12 deletions datafusion/physical-expr/src/aggregate/average.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,19 +532,8 @@ where
assert_eq!(values.len(), 1, "single argument to update_batch");
let values = values.get(0).unwrap().as_primitive::<T>();

// increment counts
// increment counts, update sums
self.counts.resize(total_num_groups, 0);
self.null_state.accumulate(
group_indices,
values,
opt_filter,
total_num_groups,
|group_index, _new_value| {
self.counts[group_index] += 1;
},
);

// update sums
self.sums.resize(total_num_groups, T::default_value());
self.null_state.accumulate(
group_indices,
Expand All @@ -554,6 +543,8 @@ where
|group_index, new_value| {
let sum = &mut self.sums[group_index];
*sum = sum.add_wrapping(new_value);

self.counts[group_index] += 1;
},
);

Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/aggregate/min_max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use arrow::{
};
use arrow_array::cast::AsArray;
use arrow_array::types::{
ArrowPrimitiveType, Decimal128Type, Float32Type, Float64Type, UInt32Type, UInt64Type,
Decimal128Type, Float32Type, Float64Type, UInt32Type, UInt64Type,
};
use arrow_array::{ArrowNumericType, PrimitiveArray};
use datafusion_common::ScalarValue;
Expand Down

0 comments on commit 6846970

Please sign in to comment.