rtpsw commented on code in PR #14043:
URL: https://github.com/apache/arrow/pull/14043#discussion_r1016200159


##########
cpp/src/arrow/compute/function.cc:
##########
@@ -167,6 +179,109 @@ const Kernel* DispatchExactImpl(const Function* func,
   return nullptr;
 }
 
+struct FunctionExecutorImpl : public FunctionExecutor {
+  FunctionExecutorImpl(std::vector<TypeHolder> in_types, const Kernel* kernel,
+                       std::unique_ptr<detail::KernelExecutor> executor,
+                       const Function& func)
+      : in_types(std::move(in_types)),
+        kernel(kernel),
+        kernel_ctx(default_exec_context(), kernel),
+        executor(std::move(executor)),
+        func(func),
+        state(),
+        options(NULLPTR),
+        inited(false) {}
+  virtual ~FunctionExecutorImpl() {}
+
+  Status KernelInit(const FunctionOptions* options) {
+    RETURN_NOT_OK(CheckOptions(func, options));
+    if (options == NULLPTR) {
+      options = func.default_options();
+    }
+    if (kernel->init) {
+      ARROW_ASSIGN_OR_RAISE(state,
+                            kernel->init(&kernel_ctx, {kernel, in_types, 
options}));
+      kernel_ctx.SetState(state.get());
+    }
+
+    RETURN_NOT_OK(executor->Init(&kernel_ctx, {kernel, in_types, options}));
+    this->options = options;
+    inited = true;
+    return Status::OK();
+  }
+
+  Status Init(const FunctionOptions* options, ExecContext* exec_ctx) override {
+    kernel_ctx = KernelContext{exec_ctx, kernel};
+    return KernelInit(options);
+  }
+
+  Result<Datum> Execute(const std::vector<Datum>& args, int64_t passed_length) 
override {
+    util::tracing::Span span;
+
+    auto func_kind = func.kind();
+    auto func_name = func.name();

Review Comment:
   `func.name()` returns `const std::string&`, so no copying occurs. I'm fine 
with the suggested change, though.



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