diff --git a/cpp/src/arrow/compute/kernels/codegen_internal.h b/cpp/src/arrow/compute/kernels/codegen_internal.h index 2a492f581f53b..e7e1a35674e83 100644 --- a/cpp/src/arrow/compute/kernels/codegen_internal.h +++ b/cpp/src/arrow/compute/kernels/codegen_internal.h @@ -141,6 +141,13 @@ struct GetViewType::value || static T LogicalValue(PhysicalType value) { return value; } }; +template +struct GetViewType> { + using T = typename TypeTraits::ScalarType; + + static T LogicalValue(T value) { return value; } +}; + template <> struct GetViewType { using T = Decimal32; @@ -322,6 +329,26 @@ struct ArrayIterator> { } }; +template +struct ArrayIterator> { + using T = typename TypeTraits::ScalarType; + using ArrayT = typename TypeTraits::ArrayType; + using offset_type = typename Type::offset_type; + + const ArraySpan& arr; + int64_t position; + + explicit ArrayIterator(const ArraySpan& arr) : arr(arr), position(0) {} + + T operator()() { + const auto array_ptr = arr.ToArray(); + const auto array = checked_cast(array_ptr.get()); + + T result{array->value_slice(position++)}; + return result; + } +}; + template <> struct ArrayIterator { const ArraySpan& arr; @@ -390,6 +417,12 @@ struct UnboxScalar> { } }; +template +struct UnboxScalar> { + using T = typename TypeTraits::ScalarType; + static const T& Unbox(const Scalar& val) { return checked_cast(val); } +}; + template <> struct UnboxScalar { using T = Decimal32; @@ -1383,6 +1416,22 @@ ArrayKernelExec GenerateDecimal(detail::GetTypeId get_id) { } } +// Generate a kernel given a templated functor for list types +// +// See "Numeric" above for description of the generator functor +template