MCPcopy Create free account
hub / github.com/apache/arrow / AddMinOrMaxAggKernel

Function AddMinOrMaxAggKernel

cpp/src/arrow/compute/kernels/aggregate_basic.cc:504–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502// For "min" and "max" functions: override finalize and return the actual value
503template <MinOrMax min_or_max>
504void AddMinOrMaxAggKernel(ScalarAggregateFunction* func,
505 ScalarAggregateFunction* min_max_func) {
506 auto sig = KernelSignature::Make({InputType::Any()}, FirstType);
507 auto init = [min_max_func](
508 KernelContext* ctx,
509 const KernelInitArgs& args) -> Result<std::unique_ptr<KernelState>> {
510 ARROW_ASSIGN_OR_RAISE(auto kernel, min_max_func->DispatchExact(args.inputs));
511 KernelInitArgs new_args{kernel, args.inputs, args.options};
512 return kernel->init(ctx, new_args);
513 };
514
515 auto finalize = [](KernelContext* ctx, Datum* out) -> Status {
516 Datum temp;
517 RETURN_NOT_OK(checked_cast<ScalarAggregator*>(ctx->state())->Finalize(ctx, &temp));
518 const auto& result = temp.scalar_as<StructScalar>();
519 DCHECK(result.is_valid);
520 *out = result.value[static_cast<uint8_t>(min_or_max)];
521 return Status::OK();
522 };
523
524 // Note SIMD level is always NONE, but the convenience kernel will
525 // dispatch to an appropriate implementation
526 AddAggKernel(std::move(sig), std::move(init), std::move(finalize), func);
527}
528
529// ----------------------------------------------------------------------
530// Any implementation

Callers

nothing calls this directly

Calls 7

AddAggKernelFunction · 0.85
MakeFunction · 0.50
AnyFunction · 0.50
OKFunction · 0.50
initMethod · 0.45
FinalizeMethod · 0.45
stateMethod · 0.45

Tested by

no test coverage detected