wesm commented on a change in pull request #7240:
URL: https://github.com/apache/arrow/pull/7240#discussion_r428738847



##########
File path: cpp/src/arrow/compute/kernels/codegen_internal.h
##########
@@ -0,0 +1,648 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "arrow/array.h"
+#include "arrow/compute/kernel.h"
+#include "arrow/scalar.h"
+#include "arrow/type_traits.h"
+#include "arrow/util/bit_util.h"
+#include "arrow/util/logging.h"
+#include "arrow/util/optional.h"
+#include "arrow/util/string_view.h"
+#include "arrow/visitor_inline.h"
+
+namespace arrow {
+
+using internal::BitmapReader;
+using internal::FirstTimeBitmapWriter;
+using internal::GenerateBitsUnrolled;
+
+namespace compute {
+
+#ifdef ARROW_EXTRA_ERROR_CONTEXT
+
+#define KERNEL_ABORT_IF_ERROR(ctx, expr)                \
+  do {                                                  \
+    Status _st = (expr);                                \
+    if (ARROW_PREDICT_FALSE(!_st.ok())) {               \
+      _st.AddContextLine(__FILE__, __LINE__, #expr);    \
+      ctx->SetStatus(_st);                              \
+      return;                                           \
+    }                                                   \
+  } while (0)
+
+#else
+
+#define KERNEL_ABORT_IF_ERROR(ctx, expr)        \
+  do {                                          \
+    Status _st = (expr);                        \
+    if (ARROW_PREDICT_FALSE(!_st.ok())) {       \
+      ctx->SetStatus(_st);                      \
+      return;                                   \
+    }                                           \
+  } while (0)
+
+#endif  // ARROW_EXTRA_ERROR_CONTEXT
+
+// A kernel that exposes Call methods that handles iteration over ArrayData
+// inputs itself
+//
+
+constexpr int kValidity = 0;
+constexpr int kBinaryOffsets = 1;
+constexpr int kPrimitiveData = 1;
+constexpr int kBinaryData = 2;
+
+// ----------------------------------------------------------------------
+// Iteration / value access utilities
+
+template <typename T, typename R = void>
+using enable_if_has_c_type_not_boolean = enable_if_t<has_c_type<T>::value &&
+                                                     
!is_boolean_type<T>::value, R>;
+
+template <typename T, typename Enable = void>
+struct CodegenTraits;
+
+template <typename T>
+struct CodegenTraits<T, enable_if_has_c_type<T>> {
+  using value_type = typename T::c_type;
+};
+
+template <typename T>
+struct CodegenTraits<T, enable_if_base_binary<T>> {
+  using value_type = util::string_view;
+};
+
+template <typename Type, typename Enable = void>
+struct ArrayIterator;
+
+template <typename Type>
+struct ArrayIterator<Type, enable_if_has_c_type_not_boolean<Type>> {
+  using T = typename Type::c_type;
+  const T* values;
+  ArrayIterator(const ArrayData& data) : values(data.GetValues<T>(1)) {}
+  T operator()() { return *values++; }
+};
+
+template <typename Type>
+struct ArrayIterator<Type, enable_if_boolean<Type>> {
+  BitmapReader reader;
+  ArrayIterator(const ArrayData& data)
+      : reader(data.buffers[1]->data(), data.offset, data.length) {}
+  bool operator()() {
+    bool out = reader.IsSet();
+    reader.Next();
+    return out;
+  }
+};
+
+template <typename Type>
+struct ArrayIterator<Type, enable_if_base_binary<Type>> {
+  int64_t position = 0;
+  typename TypeTraits<Type>::ArrayType arr;
+  ArrayIterator(const ArrayData& data)
+      : arr(data.Copy()) {}
+  util::string_view operator()() { return arr.GetView(position++); }
+};
+
+template <typename Type, typename Enable = void>
+struct UnboxScalar;
+
+template <typename Type>
+struct UnboxScalar<Type, enable_if_has_c_type<Type>> {
+  using ScalarType = typename TypeTraits<Type>::ScalarType;
+  static typename Type::c_type Unbox(const Datum& datum) {
+    return datum.scalar_as<ScalarType>().value;
+  }
+};
+
+template <typename Type>
+struct UnboxScalar<Type, enable_if_base_binary<Type>> {
+  static util::string_view Unbox(const Datum& datum) {
+    return util::string_view(*datum.scalar_as<BaseBinaryScalar>().value);
+  }
+};
+
+template <typename Type, typename Enable = void>
+struct GetValueType;
+
+template <typename Type>
+struct GetValueType<Type, enable_if_has_c_type<Type>> {
+  using T = typename Type::c_type;

Review comment:
       It may not be, I will look

##########
File path: cpp/src/arrow/compute/kernels/codegen_internal.h
##########
@@ -0,0 +1,648 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "arrow/array.h"
+#include "arrow/compute/kernel.h"
+#include "arrow/scalar.h"
+#include "arrow/type_traits.h"
+#include "arrow/util/bit_util.h"
+#include "arrow/util/logging.h"
+#include "arrow/util/optional.h"
+#include "arrow/util/string_view.h"
+#include "arrow/visitor_inline.h"
+
+namespace arrow {
+
+using internal::BitmapReader;
+using internal::FirstTimeBitmapWriter;
+using internal::GenerateBitsUnrolled;
+
+namespace compute {
+
+#ifdef ARROW_EXTRA_ERROR_CONTEXT
+
+#define KERNEL_ABORT_IF_ERROR(ctx, expr)                \
+  do {                                                  \
+    Status _st = (expr);                                \
+    if (ARROW_PREDICT_FALSE(!_st.ok())) {               \
+      _st.AddContextLine(__FILE__, __LINE__, #expr);    \
+      ctx->SetStatus(_st);                              \
+      return;                                           \
+    }                                                   \
+  } while (0)
+
+#else
+
+#define KERNEL_ABORT_IF_ERROR(ctx, expr)        \
+  do {                                          \
+    Status _st = (expr);                        \
+    if (ARROW_PREDICT_FALSE(!_st.ok())) {       \
+      ctx->SetStatus(_st);                      \
+      return;                                   \
+    }                                           \
+  } while (0)
+
+#endif  // ARROW_EXTRA_ERROR_CONTEXT
+
+// A kernel that exposes Call methods that handles iteration over ArrayData
+// inputs itself
+//
+
+constexpr int kValidity = 0;
+constexpr int kBinaryOffsets = 1;
+constexpr int kPrimitiveData = 1;
+constexpr int kBinaryData = 2;
+
+// ----------------------------------------------------------------------
+// Iteration / value access utilities
+
+template <typename T, typename R = void>
+using enable_if_has_c_type_not_boolean = enable_if_t<has_c_type<T>::value &&
+                                                     
!is_boolean_type<T>::value, R>;
+
+template <typename T, typename Enable = void>
+struct CodegenTraits;
+
+template <typename T>
+struct CodegenTraits<T, enable_if_has_c_type<T>> {
+  using value_type = typename T::c_type;
+};
+
+template <typename T>
+struct CodegenTraits<T, enable_if_base_binary<T>> {
+  using value_type = util::string_view;
+};
+
+template <typename Type, typename Enable = void>
+struct ArrayIterator;
+
+template <typename Type>
+struct ArrayIterator<Type, enable_if_has_c_type_not_boolean<Type>> {
+  using T = typename Type::c_type;
+  const T* values;
+  ArrayIterator(const ArrayData& data) : values(data.GetValues<T>(1)) {}
+  T operator()() { return *values++; }
+};
+
+template <typename Type>
+struct ArrayIterator<Type, enable_if_boolean<Type>> {
+  BitmapReader reader;
+  ArrayIterator(const ArrayData& data)
+      : reader(data.buffers[1]->data(), data.offset, data.length) {}
+  bool operator()() {
+    bool out = reader.IsSet();
+    reader.Next();
+    return out;
+  }
+};
+
+template <typename Type>
+struct ArrayIterator<Type, enable_if_base_binary<Type>> {
+  int64_t position = 0;
+  typename TypeTraits<Type>::ArrayType arr;
+  ArrayIterator(const ArrayData& data)
+      : arr(data.Copy()) {}
+  util::string_view operator()() { return arr.GetView(position++); }
+};
+
+template <typename Type, typename Enable = void>
+struct UnboxScalar;
+
+template <typename Type>
+struct UnboxScalar<Type, enable_if_has_c_type<Type>> {
+  using ScalarType = typename TypeTraits<Type>::ScalarType;
+  static typename Type::c_type Unbox(const Datum& datum) {
+    return datum.scalar_as<ScalarType>().value;
+  }
+};
+
+template <typename Type>
+struct UnboxScalar<Type, enable_if_base_binary<Type>> {
+  static util::string_view Unbox(const Datum& datum) {
+    return util::string_view(*datum.scalar_as<BaseBinaryScalar>().value);
+  }
+};
+
+template <typename Type, typename Enable = void>
+struct GetValueType;
+
+template <typename Type>
+struct GetValueType<Type, enable_if_has_c_type<Type>> {
+  using T = typename Type::c_type;
+};
+
+template <typename Type>
+struct GetValueType<
+    Type, enable_if_t<is_base_binary_type<Type>::value || 
is_decimal_type<Type>::value ||
+                      is_fixed_size_binary_type<Type>::value>> {
+  using T = util::string_view;
+};
+
+// ----------------------------------------------------------------------
+// Generate an array kernel given template classes
+
+void ExecFail(KernelContext* ctx, const ExecBatch& batch, Datum* out);
+
+void BinaryExecFlipped(KernelContext* ctx, ArrayKernelExec exec,
+                       const ExecBatch& batch, Datum* out);
+
+// ----------------------------------------------------------------------
+// Boolean data utilities
+
+// ----------------------------------------------------------------------
+// Template kernel exec function generators
+
+template <typename T>
+void Extend(const std::vector<T>& values, std::vector<T>* out) {
+  for (const auto& t : values) {
+    out->push_back(t);
+  }
+}
+
+const std::vector<std::shared_ptr<DataType>>& BaseBinaryTypes();
+const std::vector<std::shared_ptr<DataType>>& SignedIntTypes();
+const std::vector<std::shared_ptr<DataType>>& UnsignedIntTypes();
+const std::vector<std::shared_ptr<DataType>>& IntTypes();
+const std::vector<std::shared_ptr<DataType>>& FloatingPointTypes();
+
+// Number types without boolean
+const std::vector<std::shared_ptr<DataType>>& NumericTypes();
+
+// Temporal types including time and timestamps for each unit
+const std::vector<std::shared_ptr<DataType>>& TemporalTypes();
+
+// Integer, floating point, base binary, and temporal
+const std::vector<std::shared_ptr<DataType>>& PrimitiveTypes();
+
+namespace codegen {
+
+struct SimpleExec {
+  // Operator must implement
+  //
+  // static void Call(KernelContext*, const ArrayData& in, ArrayData* out)
+  template <typename Operator>
+  static void Unary(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+    if (batch[0].kind() == Datum::SCALAR) {
+      ctx->SetStatus(Status::NotImplemented("NYI"));
+    } else if (batch.length > 0) {
+      Operator::Call(ctx, *batch[0].array(), out->mutable_array());
+    }
+  }
+
+  // Operator must implement
+  //
+  // static void Call(KernelContext*, const ArrayData& arg0, const ArrayData& 
arg1,
+  //                  ArrayData* out)
+  template <typename Operator>
+  static void Binary(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+    if (batch[0].kind() == Datum::SCALAR || batch[1].kind() == Datum::SCALAR) {
+      ctx->SetStatus(Status::NotImplemented("NYI"));
+    } else if (batch.length > 0) {
+      Operator::Call(ctx, *batch[0].array(), *batch[1].array(), 
out->mutable_array());
+    }
+  }
+};
+
+// TODO: Run benchmarks to determine if OutputAdapter is a zero-cost 
abstraction
+struct ScalarPrimitiveExec {
+  template <typename Op, typename OutType, typename Arg0Type>
+  static void Unary(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+    using OUT = typename OutType::c_type;
+    using ARG0 = typename Arg0Type::c_type;
+
+    if (batch[0].kind() == Datum::SCALAR) {
+      ctx->SetStatus(Status::NotImplemented("NYI"));
+    } else {
+      ArrayData* out_arr = out->mutable_array();
+      auto out_data = out_arr->GetMutableValues<OUT>(kPrimitiveData);
+      auto arg0_data = batch[0].array()->GetValues<ARG0>(kPrimitiveData);
+      for (int64_t i = 0; i < batch.length; ++i) {
+        *out_data++ = Op::template Call<OUT, ARG0>(ctx, *arg0_data++);
+      }
+    }
+  }
+
+  template <typename Op, typename OutType, typename Arg0Type, typename 
Arg1Type>
+  static void Binary(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+    using OUT = typename OutType::c_type;
+    using ARG0 = typename Arg0Type::c_type;
+    using ARG1 = typename Arg1Type::c_type;
+
+    if (batch[0].kind() == Datum::SCALAR || batch[1].kind() == Datum::SCALAR) {
+      ctx->SetStatus(Status::NotImplemented("NYI"));
+    } else {
+      ArrayData* out_arr = out->mutable_array();
+      auto out_data = out_arr->GetMutableValues<OUT>(kPrimitiveData);
+      auto arg0_data = batch[0].array()->GetValues<ARG0>(kPrimitiveData);
+      auto arg1_data = batch[1].array()->GetValues<ARG1>(kPrimitiveData);
+      for (int64_t i = 0; i < batch.length; ++i) {
+        *out_data++ = Op::template Call<OUT, ARG0, ARG1>(ctx, *arg0_data++, 
*arg1_data++);
+      }
+    }
+  }
+};
+
+template <typename Type, typename Enable = void>
+struct OutputAdapter;
+
+template <typename Type>
+struct OutputAdapter<Type, enable_if_boolean<Type>> {
+  template <typename Generator>
+  static void Write(KernelContext*, Datum* out, Generator&& generator) {
+    ArrayData* out_arr = out->mutable_array();
+    auto out_bitmap = out_arr->buffers[1]->mutable_data();
+    GenerateBitsUnrolled(out_bitmap, out_arr->offset, out_arr->length,
+                         std::forward<Generator>(generator));
+  }
+};
+
+template <typename Type>
+struct OutputAdapter<Type, enable_if_has_c_type_not_boolean<Type>> {
+  template <typename Generator>
+  static void Write(KernelContext*, Datum* out, Generator&& generator) {
+    ArrayData* out_arr = out->mutable_array();
+    auto out_data = out_arr->GetMutableValues<typename 
Type::c_type>(kPrimitiveData);
+    // TODO: Is this as fast as a more explicitly inlined function?
+    for (int64_t i = 0 ; i < out_arr->length; ++i) {
+      *out_data++ = generator();
+    }
+  }
+};
+
+template <typename Type>
+struct OutputAdapter<Type, enable_if_base_binary<Type>> {
+  template <typename Generator>
+  static void Write(KernelContext* ctx, Datum* out, Generator&& generator) {
+    ctx->SetStatus(Status::NotImplemented("NYI"));
+  }
+};
+
+template <typename OutType, typename Arg0Type, typename Op>
+struct ScalarUnary {
+  using OutScalar = typename TypeTraits<OutType>::ScalarType;
+
+  using OUT = typename CodegenTraits<OutType>::value_type;
+  using ARG0 = typename CodegenTraits<Arg0Type>::value_type;
+
+  static void Array(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+    ArrayIterator<Arg0Type> arg0(*batch[0].array());
+    OutputAdapter<OutType>::Write(ctx, out, [&]() -> OUT {
+        return Op::template Call<OUT, ARG0>(ctx, arg0());
+    });
+  }
+
+  static void Scalar(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+    if (batch[0].scalar()->is_valid) {
+      ARG0 arg0 = UnboxScalar<Arg0Type>::Unbox(batch[0]);
+      out->value = std::make_shared<OutScalar>(Op::template Call<OUT, 
ARG0>(ctx, arg0),
+                                               out->type());
+    } else {
+      out->value = MakeNullScalar(batch[0].type());
+    }
+  }
+
+  static void Exec(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+    if (batch[0].kind() == Datum::ARRAY) {
+      return Array(ctx, batch, out);
+    } else {
+      return Scalar(ctx, batch, out);
+    }
+  }
+};
+
+// Applies a scalar operation with state on the null-null values of a single

Review comment:
       yes

##########
File path: cpp/src/arrow/compute/kernels/codegen_internal.h
##########
@@ -0,0 +1,648 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "arrow/array.h"
+#include "arrow/compute/kernel.h"
+#include "arrow/scalar.h"
+#include "arrow/type_traits.h"
+#include "arrow/util/bit_util.h"
+#include "arrow/util/logging.h"
+#include "arrow/util/optional.h"
+#include "arrow/util/string_view.h"
+#include "arrow/visitor_inline.h"
+
+namespace arrow {
+
+using internal::BitmapReader;
+using internal::FirstTimeBitmapWriter;
+using internal::GenerateBitsUnrolled;
+
+namespace compute {
+
+#ifdef ARROW_EXTRA_ERROR_CONTEXT
+
+#define KERNEL_ABORT_IF_ERROR(ctx, expr)                \
+  do {                                                  \
+    Status _st = (expr);                                \
+    if (ARROW_PREDICT_FALSE(!_st.ok())) {               \
+      _st.AddContextLine(__FILE__, __LINE__, #expr);    \
+      ctx->SetStatus(_st);                              \
+      return;                                           \
+    }                                                   \
+  } while (0)
+
+#else
+
+#define KERNEL_ABORT_IF_ERROR(ctx, expr)        \
+  do {                                          \
+    Status _st = (expr);                        \
+    if (ARROW_PREDICT_FALSE(!_st.ok())) {       \
+      ctx->SetStatus(_st);                      \
+      return;                                   \
+    }                                           \
+  } while (0)
+
+#endif  // ARROW_EXTRA_ERROR_CONTEXT
+
+// A kernel that exposes Call methods that handles iteration over ArrayData
+// inputs itself
+//
+
+constexpr int kValidity = 0;
+constexpr int kBinaryOffsets = 1;
+constexpr int kPrimitiveData = 1;
+constexpr int kBinaryData = 2;
+
+// ----------------------------------------------------------------------
+// Iteration / value access utilities
+
+template <typename T, typename R = void>
+using enable_if_has_c_type_not_boolean = enable_if_t<has_c_type<T>::value &&
+                                                     
!is_boolean_type<T>::value, R>;
+
+template <typename T, typename Enable = void>
+struct CodegenTraits;
+
+template <typename T>
+struct CodegenTraits<T, enable_if_has_c_type<T>> {
+  using value_type = typename T::c_type;
+};
+
+template <typename T>
+struct CodegenTraits<T, enable_if_base_binary<T>> {
+  using value_type = util::string_view;
+};
+
+template <typename Type, typename Enable = void>
+struct ArrayIterator;
+
+template <typename Type>
+struct ArrayIterator<Type, enable_if_has_c_type_not_boolean<Type>> {
+  using T = typename Type::c_type;
+  const T* values;
+  ArrayIterator(const ArrayData& data) : values(data.GetValues<T>(1)) {}
+  T operator()() { return *values++; }
+};
+
+template <typename Type>
+struct ArrayIterator<Type, enable_if_boolean<Type>> {
+  BitmapReader reader;
+  ArrayIterator(const ArrayData& data)
+      : reader(data.buffers[1]->data(), data.offset, data.length) {}
+  bool operator()() {
+    bool out = reader.IsSet();
+    reader.Next();
+    return out;
+  }
+};
+
+template <typename Type>
+struct ArrayIterator<Type, enable_if_base_binary<Type>> {
+  int64_t position = 0;
+  typename TypeTraits<Type>::ArrayType arr;
+  ArrayIterator(const ArrayData& data)
+      : arr(data.Copy()) {}
+  util::string_view operator()() { return arr.GetView(position++); }
+};
+
+template <typename Type, typename Enable = void>
+struct UnboxScalar;
+
+template <typename Type>
+struct UnboxScalar<Type, enable_if_has_c_type<Type>> {
+  using ScalarType = typename TypeTraits<Type>::ScalarType;
+  static typename Type::c_type Unbox(const Datum& datum) {
+    return datum.scalar_as<ScalarType>().value;
+  }
+};
+
+template <typename Type>
+struct UnboxScalar<Type, enable_if_base_binary<Type>> {
+  static util::string_view Unbox(const Datum& datum) {
+    return util::string_view(*datum.scalar_as<BaseBinaryScalar>().value);
+  }
+};
+
+template <typename Type, typename Enable = void>
+struct GetValueType;
+
+template <typename Type>
+struct GetValueType<Type, enable_if_has_c_type<Type>> {
+  using T = typename Type::c_type;
+};
+
+template <typename Type>
+struct GetValueType<
+    Type, enable_if_t<is_base_binary_type<Type>::value || 
is_decimal_type<Type>::value ||
+                      is_fixed_size_binary_type<Type>::value>> {
+  using T = util::string_view;
+};
+
+// ----------------------------------------------------------------------
+// Generate an array kernel given template classes
+
+void ExecFail(KernelContext* ctx, const ExecBatch& batch, Datum* out);
+
+void BinaryExecFlipped(KernelContext* ctx, ArrayKernelExec exec,
+                       const ExecBatch& batch, Datum* out);
+
+// ----------------------------------------------------------------------
+// Boolean data utilities
+
+// ----------------------------------------------------------------------
+// Template kernel exec function generators
+
+template <typename T>
+void Extend(const std::vector<T>& values, std::vector<T>* out) {
+  for (const auto& t : values) {
+    out->push_back(t);
+  }
+}
+
+const std::vector<std::shared_ptr<DataType>>& BaseBinaryTypes();
+const std::vector<std::shared_ptr<DataType>>& SignedIntTypes();
+const std::vector<std::shared_ptr<DataType>>& UnsignedIntTypes();
+const std::vector<std::shared_ptr<DataType>>& IntTypes();
+const std::vector<std::shared_ptr<DataType>>& FloatingPointTypes();
+
+// Number types without boolean
+const std::vector<std::shared_ptr<DataType>>& NumericTypes();
+
+// Temporal types including time and timestamps for each unit
+const std::vector<std::shared_ptr<DataType>>& TemporalTypes();
+
+// Integer, floating point, base binary, and temporal
+const std::vector<std::shared_ptr<DataType>>& PrimitiveTypes();
+
+namespace codegen {
+
+struct SimpleExec {
+  // Operator must implement
+  //
+  // static void Call(KernelContext*, const ArrayData& in, ArrayData* out)
+  template <typename Operator>
+  static void Unary(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+    if (batch[0].kind() == Datum::SCALAR) {
+      ctx->SetStatus(Status::NotImplemented("NYI"));
+    } else if (batch.length > 0) {
+      Operator::Call(ctx, *batch[0].array(), out->mutable_array());
+    }
+  }
+
+  // Operator must implement
+  //
+  // static void Call(KernelContext*, const ArrayData& arg0, const ArrayData& 
arg1,
+  //                  ArrayData* out)
+  template <typename Operator>
+  static void Binary(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+    if (batch[0].kind() == Datum::SCALAR || batch[1].kind() == Datum::SCALAR) {
+      ctx->SetStatus(Status::NotImplemented("NYI"));
+    } else if (batch.length > 0) {
+      Operator::Call(ctx, *batch[0].array(), *batch[1].array(), 
out->mutable_array());
+    }
+  }
+};
+
+// TODO: Run benchmarks to determine if OutputAdapter is a zero-cost 
abstraction
+struct ScalarPrimitiveExec {

Review comment:
       I will add more comments

##########
File path: cpp/src/arrow/compute/kernels/CMakeLists.txt
##########
@@ -15,37 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 
-arrow_install_all_headers("arrow/compute/kernels")
-
-add_arrow_compute_test(boolean_test)
-add_arrow_compute_test(cast_test)
-add_arrow_compute_test(hash_test)
-add_arrow_compute_test(isin_test)
-add_arrow_compute_test(match_test)
-add_arrow_compute_test(sort_to_indices_test)
-add_arrow_compute_test(nth_to_indices_test)
-add_arrow_compute_test(util_internal_test)
-add_arrow_compute_test(add_test)
+# ----------------------------------------------------------------------
+# Scalar kernels
 
-# Aggregates
-add_arrow_compute_test(aggregate_test)
+add_arrow_compute_test(scalar_test
+                       SOURCES
+                       scalar_arithmetic_test.cc
+                       scalar_boolean_test.cc
+                       scalar_cast_test.cc
+                       scalar_compare_test.cc
+                       scalar_set_lookup_test.cc)
 
-# Comparison
-add_arrow_compute_test(compare_test)
+# add_arrow_compute_test(cast_test)
 
-# Selection
-add_arrow_compute_test(take_test)
-add_arrow_compute_test(filter_test)
+add_arrow_benchmark(scalar_compare_benchmark PREFIX "arrow-compute")
 
-add_arrow_benchmark(sort_to_indices_benchmark PREFIX "arrow-compute")
-add_arrow_benchmark(nth_to_indices_benchmark PREFIX "arrow-compute")
+# ----------------------------------------------------------------------
+# Vector kernels
 
-# Aggregates
-add_arrow_benchmark(aggregate_benchmark PREFIX "arrow-compute")
+add_arrow_compute_test(vector_test
+                       SOURCES
+                       vector_filter_test.cc
+                       vector_hash_test.cc
+                       vector_take_test.cc
+                       vector_sort_test.cc)
+
+# add_arrow_benchmark(vector_hash_benchmark PREFIX "arrow-compute")
+# add_arrow_benchmark(vector_sort_benchmark PREFIX "arrow-compute")
+# add_arrow_benchmark(vector_partition_benchmark PREFIX "arrow-compute")
+# add_arrow_benchmark(vector_filter_benchmark PREFIX "arrow-compute")a
+# add_arrow_benchmark(vector_take_benchmark PREFIX "arrow-compute")

Review comment:
       yes




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


Reply via email to