You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/16 23:34:18 UTC

[GitHub] [arrow] westonpace commented on a diff in pull request #13344: ARROW-16686: [C++] Use shared_ptr with FunctionOptions

westonpace commented on code in PR #13344:
URL: https://github.com/apache/arrow/pull/13344#discussion_r899640401


##########
cpp/src/arrow/compute/exec/plan_test.cc:
##########
@@ -390,7 +391,8 @@ TEST(ExecPlan, ToString) {
                           }}},
               {"aggregate",
                AggregateNodeOptions{
-                   /*aggregates=*/{{"hash_sum", nullptr}, {"hash_count", &options}},
+                   /*aggregates=*/{{"hash_sum", nullptr},
+                                   {"hash_count", std::move(options)}},

Review Comment:
   You use `options` again on line 437 so I'm not sure it is safe to move it here.



##########
cpp/src/arrow/compute/exec/aggregate.cc:
##########
@@ -61,7 +61,11 @@ Result<std::vector<std::unique_ptr<KernelState>>> InitKernels(
       // use known default options for the named function if possible
       auto maybe_function = ctx->func_registry()->GetFunction(aggregates[i].function);
       if (maybe_function.ok()) {
-        options = maybe_function.ValueOrDie()->default_options();
+        const FunctionOptions* default_opts =

Review Comment:
   I think if you change line 58 to...
   
   ```
   const FunctionOptions* options = aggregates[i].options.get();
   ```
   
   ...then this change isn't needed.  We are just grabbing a read-only view of the options which we can safely discard after the call to `init`



##########
cpp/examples/arrow/execution_plan_documentation_examples.cc:
##########
@@ -539,9 +539,9 @@ arrow::Status SourceGroupAggregateSinkExample(cp::ExecContext& exec_context) {
 
   ARROW_ASSIGN_OR_RAISE(cp::ExecNode * source,
                         cp::MakeExecNode("source", plan.get(), {}, source_node_options));
-  cp::CountOptions options(cp::CountOptions::ONLY_VALID);
+  auto options = std::make_shared<cp::CountOptions>(cp::CountOptions::ONLY_VALID);
   auto aggregate_options =
-      cp::AggregateNodeOptions{/*aggregates=*/{{"hash_count", &options}},
+      cp::AggregateNodeOptions{/*aggregates=*/{{"hash_count", options}},

Review Comment:
   ```suggestion
         cp::AggregateNodeOptions{/*aggregates=*/{{"hash_count", std::move(options)}},
   ```
   
   Minor nit



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org