icexelloss commented on code in PR #34885:
URL: https://github.com/apache/arrow/pull/34885#discussion_r1157358949


##########
cpp/src/arrow/acero/aggregate_node.cc:
##########
@@ -122,53 +158,91 @@ Result<std::unique_ptr<KernelState>> InitKernel(const 
HashAggregateKernel* kerne
   }
 
   ARROW_ASSIGN_OR_RAISE(
-      auto state,
-      kernel->init(&kernel_ctx, KernelInitArgs{kernel, aggr_in_types, 
options}));
+      auto state, kernel->init(&kernel_ctx, KernelInitArgs{kernel, in_types, 
options}));
   return std::move(state);
 }
 
-Result<std::vector<const HashAggregateKernel*>> GetKernels(
-    ExecContext* ctx, const std::vector<Aggregate>& aggregates,
+Result<std::unique_ptr<KernelState>> InitHashAggregateKernel(
+    const Kernel* kernel, ExecContext* ctx, const Aggregate& aggregate,
+    const std::vector<TypeHolder>& in_types) {
+  const auto aggr_in_types = ExtendWithGroupIdType(in_types);
+  return InitScalarAggregateKernel(kernel, ctx, aggregate, 
std::move(aggr_in_types));
+}
+
+Result<std::vector<const Kernel*>> GetKernels(
+    GetKernel get_kernel, ExecContext* ctx, std::vector<Aggregate>* 
aggregates_ptr,
     const std::vector<std::vector<TypeHolder>>& in_types) {
+  std::vector<Aggregate>& aggregates = *aggregates_ptr;
   if (aggregates.size() != in_types.size()) {
     return Status::Invalid(aggregates.size(), " aggregate functions were 
specified but ",
                            in_types.size(), " arguments were provided.");
   }
 
-  std::vector<const HashAggregateKernel*> kernels(in_types.size());
+  std::vector<const Kernel*> kernels(in_types.size());
   for (size_t i = 0; i < aggregates.size(); ++i) {
-    ARROW_ASSIGN_OR_RAISE(kernels[i], GetKernel(ctx, aggregates[i], 
in_types[i]));
+    ARROW_ASSIGN_OR_RAISE(kernels[i], get_kernel(ctx, &aggregates[i], 
in_types[i]));

Review Comment:
   Why this change?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to