Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions cpp/src/arrow/compute/kernels/aggregate_basic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
#include "arrow/util/cpu_info.h"
#include "arrow/util/hashing.h"

#include <memory>
// Include templated definitions for aggregate kernels that must compiled here
// with the SIMD level configured for this compilation unit in the build.
#include "arrow/compute/kernels/aggregate_basic.inc.cc" // NOLINT(build/include)

namespace arrow {
namespace compute {
Expand Down Expand Up @@ -276,11 +278,6 @@ struct SumImplDefault : public SumImpl<ArrowType, SimdLevel::NONE> {
using SumImpl<ArrowType, SimdLevel::NONE>::SumImpl;
};

template <typename ArrowType>
struct MeanImplDefault : public MeanImpl<ArrowType, SimdLevel::NONE> {
using MeanImpl<ArrowType, SimdLevel::NONE>::MeanImpl;
};

Result<std::unique_ptr<KernelState>> SumInit(KernelContext* ctx,
const KernelInitArgs& args) {
SumLikeInit<SumImplDefault> visitor(
Expand All @@ -289,6 +286,14 @@ Result<std::unique_ptr<KernelState>> SumInit(KernelContext* ctx,
return visitor.Create();
}

// ----------------------------------------------------------------------
// Mean implementation

template <typename ArrowType>
struct MeanImplDefault : public MeanImpl<ArrowType, SimdLevel::NONE> {
using MeanImpl<ArrowType, SimdLevel::NONE>::MeanImpl;
};

Result<std::unique_ptr<KernelState>> MeanInit(KernelContext* ctx,
const KernelInitArgs& args) {
MeanKernelInit<MeanImplDefault> visitor(
Expand Down Expand Up @@ -482,8 +487,8 @@ void AddFirstOrLastAggKernel(ScalarAggregateFunction* func,
// ----------------------------------------------------------------------
// MinMax implementation

Result<std::unique_ptr<KernelState>> MinMaxInit(KernelContext* ctx,
const KernelInitArgs& args) {
Result<std::unique_ptr<KernelState>> MinMaxInitDefault(KernelContext* ctx,
const KernelInitArgs& args) {
ARROW_ASSIGN_OR_RAISE(TypeHolder out_type,
args.kernel->signature->out_type().Resolve(ctx, args.inputs));
MinMaxInitState<SimdLevel::NONE> visitor(
Expand Down Expand Up @@ -1114,14 +1119,14 @@ void RegisterScalarAggregateBasic(FunctionRegistry* registry) {
// Add min max function
func = std::make_shared<ScalarAggregateFunction>("min_max", Arity::Unary(), min_max_doc,
&default_scalar_aggregate_options);
AddMinMaxKernels(MinMaxInit, {null(), boolean()}, func.get());
AddMinMaxKernels(MinMaxInit, NumericTypes(), func.get());
AddMinMaxKernels(MinMaxInit, TemporalTypes(), func.get());
AddMinMaxKernels(MinMaxInit, BaseBinaryTypes(), func.get());
AddMinMaxKernel(MinMaxInit, Type::FIXED_SIZE_BINARY, func.get());
AddMinMaxKernel(MinMaxInit, Type::INTERVAL_MONTHS, func.get());
AddMinMaxKernel(MinMaxInit, Type::DECIMAL128, func.get());
AddMinMaxKernel(MinMaxInit, Type::DECIMAL256, func.get());
AddMinMaxKernels(MinMaxInitDefault, {null(), boolean()}, func.get());
AddMinMaxKernels(MinMaxInitDefault, NumericTypes(), func.get());
AddMinMaxKernels(MinMaxInitDefault, TemporalTypes(), func.get());
AddMinMaxKernels(MinMaxInitDefault, BaseBinaryTypes(), func.get());
AddMinMaxKernel(MinMaxInitDefault, Type::FIXED_SIZE_BINARY, func.get());
AddMinMaxKernel(MinMaxInitDefault, Type::INTERVAL_MONTHS, func.get());
AddMinMaxKernel(MinMaxInitDefault, Type::DECIMAL128, func.get());
AddMinMaxKernel(MinMaxInitDefault, Type::DECIMAL256, func.get());
// Add the SIMD variants for min max
#if defined(ARROW_HAVE_RUNTIME_AVX2)
if (cpu_info->IsSupported(arrow::internal::CpuInfo::AVX2)) {
Expand Down
Loading