bkietz commented on a change in pull request #9621: URL: https://github.com/apache/arrow/pull/9621#discussion_r599007104
########## File path: cpp/src/arrow/compute/kernel.h ########## @@ -680,26 +682,71 @@ using ScalarAggregateFinalize = std::function<void(KernelContext*, Datum*)>; /// * finalize: produces the end result of the aggregation using the /// KernelState in the KernelContext. struct ScalarAggregateKernel : public Kernel { - ScalarAggregateKernel() {} + ScalarAggregateKernel() = default; ScalarAggregateKernel(std::shared_ptr<KernelSignature> sig, KernelInit init, ScalarAggregateConsume consume, ScalarAggregateMerge merge, ScalarAggregateFinalize finalize) - : Kernel(std::move(sig), init), + : Kernel(std::move(sig), std::move(init)), consume(std::move(consume)), merge(std::move(merge)), finalize(std::move(finalize)) {} ScalarAggregateKernel(std::vector<InputType> in_types, OutputType out_type, KernelInit init, ScalarAggregateConsume consume, ScalarAggregateMerge merge, ScalarAggregateFinalize finalize) - : ScalarAggregateKernel(KernelSignature::Make(std::move(in_types), out_type), init, - consume, merge, finalize) {} + : ScalarAggregateKernel( + KernelSignature::Make(std::move(in_types), std::move(out_type)), + std::move(init), std::move(consume), std::move(merge), std::move(finalize)) {} ScalarAggregateConsume consume; ScalarAggregateMerge merge; ScalarAggregateFinalize finalize; }; +// ---------------------------------------------------------------------- +// HashAggregateKernel (for HashAggregateFunction) + +using HashAggregateConsume = std::function<void(KernelContext*, const ExecBatch&)>; + +using HashAggregateMerge = + std::function<void(KernelContext*, KernelState&&, KernelState*)>; + +// Finalize returns Datum to permit multiple return values +using HashAggregateFinalize = std::function<void(KernelContext*, Datum*)>; + +/// \brief Kernel data structure for implementations of +/// HashAggregateFunction. The four necessary components of an aggregation +/// kernel are the init, consume, merge, and finalize functions. +/// +/// * init: creates a new KernelState for a kernel. +/// * consume: processes an ExecBatch (which includes the argument as well +/// as an array of group identifiers) and updates the KernelState found in the +/// KernelContext. +/// * finalize: produces the end result of the aggregation using the Review comment: Huh, missed that one. Will do -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org