From 57e655c3225a4e8c2c861e6f7da9011449e7ee0a Mon Sep 17 00:00:00 2001 From: Kevin H Wilson Date: Sun, 22 Sep 2024 21:50:02 -0400 Subject: [PATCH] linting --- .../arrow/compute/kernels/aggregate_basic.cc | 36 ++++++++++--------- .../compute/kernels/aggregate_basic.inc.cc | 12 ++++--- .../arrow/compute/kernels/codegen_internal.cc | 12 ++++--- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/cpp/src/arrow/compute/kernels/aggregate_basic.cc b/cpp/src/arrow/compute/kernels/aggregate_basic.cc index 4f72508c7aca3..32b5f2c7c8c4a 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_basic.cc +++ b/cpp/src/arrow/compute/kernels/aggregate_basic.cc @@ -366,10 +366,14 @@ struct ProductImpl : public ScalarAggregator { Status Finalize(KernelContext*, Datum* out) override { std::shared_ptr out_type_; - if (auto decimal128_type = std::dynamic_pointer_cast(this->out_type)) { - ARROW_ASSIGN_OR_RAISE(out_type_, Decimal128Type::Make(Decimal128Type::kMaxPrecision, decimal128_type->scale())); - } else if (auto decimal256_type = std::dynamic_pointer_cast(this->out_type)) { - ARROW_ASSIGN_OR_RAISE(out_type_, Decimal256Type::Make(Decimal256Type::kMaxPrecision, decimal256_type->scale())); + if (out_type->id() == Type::DECIMAL128) { + auto cast_type = checked_cast(out_type); + ARROW_ASSIGN_OR_RAISE(out_type_, Decimal128Type::Make(Decimal128Type::kMaxPrecision, + cast_type->scale())); + } else if (out_type->id() == Type::DECIMAL256) { + auto cast_type = checked_cast(out_type); + ARROW_ASSIGN_OR_RAISE(out_type_, Decimal256Type::Make(Decimal256Type::kMaxPrecision, + cast_type->scale())); } else { out_type_ = out_type; } @@ -1057,10 +1061,10 @@ void RegisterScalarAggregateBasic(FunctionRegistry* registry) { func = std::make_shared("sum", Arity::Unary(), sum_doc, &default_scalar_aggregate_options); AddArrayScalarAggKernels(SumInit, {boolean()}, uint64(), func.get()); - AddAggKernel(KernelSignature::Make({Type::DECIMAL128}, MaxPrecisionDecimalType), SumInit, func.get(), - SimdLevel::NONE); - AddAggKernel(KernelSignature::Make({Type::DECIMAL256}, MaxPrecisionDecimalType), SumInit, func.get(), - SimdLevel::NONE); + AddAggKernel(KernelSignature::Make({Type::DECIMAL128}, MaxPrecisionDecimalType), + SumInit, func.get(), SimdLevel::NONE); + AddAggKernel(KernelSignature::Make({Type::DECIMAL256}, MaxPrecisionDecimalType), + SumInit, func.get(), SimdLevel::NONE); AddArrayScalarAggKernels(SumInit, SignedIntTypes(), int64(), func.get()); AddArrayScalarAggKernels(SumInit, UnsignedIntTypes(), uint64(), func.get()); AddArrayScalarAggKernels(SumInit, FloatingPointTypes(), float64(), func.get()); @@ -1085,10 +1089,10 @@ void RegisterScalarAggregateBasic(FunctionRegistry* registry) { &default_scalar_aggregate_options); AddArrayScalarAggKernels(MeanInit, {boolean()}, float64(), func.get()); AddArrayScalarAggKernels(MeanInit, NumericTypes(), float64(), func.get()); - AddAggKernel(KernelSignature::Make({Type::DECIMAL128}, MaxPrecisionDecimalType), MeanInit, func.get(), - SimdLevel::NONE); - AddAggKernel(KernelSignature::Make({Type::DECIMAL256}, MaxPrecisionDecimalType), MeanInit, func.get(), - SimdLevel::NONE); + AddAggKernel(KernelSignature::Make({Type::DECIMAL128}, MaxPrecisionDecimalType), + MeanInit, func.get(), SimdLevel::NONE); + AddAggKernel(KernelSignature::Make({Type::DECIMAL256}, MaxPrecisionDecimalType), + MeanInit, func.get(), SimdLevel::NONE); AddArrayScalarAggKernels(MeanInit, {null()}, float64(), func.get()); // Add the SIMD variants for mean #if defined(ARROW_HAVE_RUNTIME_AVX2) @@ -1169,10 +1173,10 @@ void RegisterScalarAggregateBasic(FunctionRegistry* registry) { AddArrayScalarAggKernels(ProductInit::Init, UnsignedIntTypes(), uint64(), func.get()); AddArrayScalarAggKernels(ProductInit::Init, FloatingPointTypes(), float64(), func.get()); - AddAggKernel(KernelSignature::Make({Type::DECIMAL128}, MaxPrecisionDecimalType), ProductInit::Init, - func.get(), SimdLevel::NONE); - AddAggKernel(KernelSignature::Make({Type::DECIMAL256}, MaxPrecisionDecimalType), ProductInit::Init, - func.get(), SimdLevel::NONE); + AddAggKernel(KernelSignature::Make({Type::DECIMAL128}, MaxPrecisionDecimalType), + ProductInit::Init, func.get(), SimdLevel::NONE); + AddAggKernel(KernelSignature::Make({Type::DECIMAL256}, MaxPrecisionDecimalType), + ProductInit::Init, func.get(), SimdLevel::NONE); AddArrayScalarAggKernels(ProductInit::Init, {null()}, int64(), func.get()); DCHECK_OK(registry->AddFunction(std::move(func))); diff --git a/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc b/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc index 53772b64afc20..af67c76fac6e8 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc +++ b/cpp/src/arrow/compute/kernels/aggregate_basic.inc.cc @@ -95,10 +95,12 @@ struct SumImpl : public ScalarAggregator { std::shared_ptr out_type_; if (out_type->id() == Type::DECIMAL128) { auto cast_type = checked_cast(out_type); - ARROW_ASSIGN_OR_RAISE(out_type_, Decimal128Type::Make(Decimal128Type::kMaxPrecision, cast_type->scale())); + ARROW_ASSIGN_OR_RAISE(out_type_, Decimal128Type::Make(Decimal128Type::kMaxPrecision, + cast_type->scale())); } else if (out_type->id() == Type::DECIMAL256) { auto cast_type = checked_cast(out_type); - ARROW_ASSIGN_OR_RAISE(out_type_, Decimal256Type::Make(Decimal256Type::kMaxPrecision, cast_type->scale())); + ARROW_ASSIGN_OR_RAISE(out_type_, Decimal256Type::Make(Decimal256Type::kMaxPrecision, + cast_type->scale())); } else { out_type_ = out_type; } @@ -233,9 +235,11 @@ struct MeanImpl> std::shared_ptr out_type_; auto decimal_type = checked_cast(this->out_type); if (decimal_type->id() == Type::DECIMAL128) { - ARROW_ASSIGN_OR_RAISE(out_type_, Decimal128Type::Make(Decimal128Type::kMaxPrecision, decimal_type->scale())); + ARROW_ASSIGN_OR_RAISE(out_type_, Decimal128Type::Make(Decimal128Type::kMaxPrecision, + decimal_type->scale())); } else { - ARROW_ASSIGN_OR_RAISE(out_type_, Decimal256Type::Make(Decimal256Type::kMaxPrecision, decimal_type->scale())); + ARROW_ASSIGN_OR_RAISE(out_type_, Decimal256Type::Make(Decimal256Type::kMaxPrecision, + decimal_type->scale())); } if ((!options.skip_nulls && this->nulls_observed) || diff --git a/cpp/src/arrow/compute/kernels/codegen_internal.cc b/cpp/src/arrow/compute/kernels/codegen_internal.cc index 33956c59f27d2..fa29c622e7241 100644 --- a/cpp/src/arrow/compute/kernels/codegen_internal.cc +++ b/cpp/src/arrow/compute/kernels/codegen_internal.cc @@ -76,18 +76,22 @@ Result ListValuesType(KernelContext* ctx, return value_type; } -Result MaxPrecisionDecimalType(KernelContext*, const std::vector& args) { +Result MaxPrecisionDecimalType(KernelContext*, + const std::vector& args) { std::shared_ptr out_type_; auto type_id = args[0].type->id(); if (type_id == Type::DECIMAL128 || type_id == Type::DECIMAL256) { auto base_type_ = checked_cast(args[0].type); if (type_id == Type::DECIMAL128) { - ARROW_ASSIGN_OR_RAISE(out_type_, Decimal128Type::Make(Decimal128Type::kMaxPrecision, base_type_->scale())); + ARROW_ASSIGN_OR_RAISE(out_type_, Decimal128Type::Make(Decimal128Type::kMaxPrecision, + base_type_->scale())); } else { - ARROW_ASSIGN_OR_RAISE(out_type_, Decimal256Type::Make(Decimal256Type::kMaxPrecision, base_type_->scale())); + ARROW_ASSIGN_OR_RAISE(out_type_, Decimal256Type::Make(Decimal256Type::kMaxPrecision, + base_type_->scale())); } } else { - return Status::TypeError("A call to MaxPrecisionDecimalType was made with a non-DecimalType"); + return Status::TypeError( + "A call to MaxPrecisionDecimalType was made with a non-DecimalType"); } return out_type_; }