Skip to content

Commit 1164d60

Browse files
authored
Minor: avoid a few clones in sum accumulator setup (#24309)
## Which issue does this PR close? - follow on to #24035 ## Rationale for this change This is a minor thing I found while doing some performance profiling for #24035 ## What changes are included in this PR? Avoid a few clone calls ## Are these changes tested? By CI ## Are there any user-facing changes? realistically nothing that someone will measure
1 parent ab12f5e commit 1164d60

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

datafusion/functions-aggregate-common/src/aggregate/avg_distinct/decimal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<I: DecimalType + Debug, S: DecimalType + Debug> DecimalDistinctAvgAccumulat
5656
let data_type = I::TYPE_CONSTRUCTOR(I::MAX_PRECISION, sum_scale);
5757

5858
Self {
59-
sum_accumulator: DistinctSumAccumulator::new(&data_type),
59+
sum_accumulator: DistinctSumAccumulator::new(data_type),
6060
sum_scale,
6161
target_precision,
6262
target_scale,

datafusion/functions-aggregate-common/src/aggregate/avg_distinct/numeric.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Default for Float64DistinctAvgAccumulator {
3636
fn default() -> Self {
3737
Self {
3838
sum_accumulator: DistinctSumAccumulator::<Float64Type>::new(
39-
&DataType::Float64,
39+
DataType::Float64,
4040
),
4141
}
4242
}

datafusion/functions-aggregate-common/src/aggregate/sum_distinct/numeric.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ pub struct DistinctSumAccumulator<T: ArrowPrimitiveType> {
4040
}
4141

4242
impl<T: ArrowPrimitiveType> DistinctSumAccumulator<T> {
43-
pub fn new(data_type: &DataType) -> Self {
43+
pub fn new(data_type: DataType) -> Self {
4444
Self {
4545
values: GenericDistinctBuffer::new(data_type.clone()),
46-
data_type: data_type.clone(),
46+
data_type,
4747
}
4848
}
4949

datafusion/functions-aggregate/src/sum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,14 @@ impl AggregateUDFImpl for Sum {
264264
if args.is_distinct {
265265
macro_rules! helper {
266266
($t:ty, $dt:expr) => {
267-
Ok(Box::new(DistinctSumAccumulator::<$t>::new(&$dt)))
267+
Ok(Box::new(DistinctSumAccumulator::<$t>::new($dt)))
268268
};
269269
}
270270
downcast_sum!(args, helper)
271271
} else {
272272
macro_rules! helper {
273273
($t:ty, $dt:expr) => {
274-
Ok(Box::new(SumAccumulator::<$t>::new($dt.clone())))
274+
Ok(Box::new(SumAccumulator::<$t>::new($dt)))
275275
};
276276
}
277277
downcast_sum!(args, helper)

0 commit comments

Comments
 (0)