wesm commented on a change in pull request #7418: URL: https://github.com/apache/arrow/pull/7418#discussion_r439755593
########## File path: cpp/src/arrow/compute/kernels/scalar_string.cc ########## @@ -37,26 +39,108 @@ struct AsciiLength { } }; -struct AsciiUpper { - // XXX: the Scalar codegen path passes template arguments that are unused - template <typename... Ignored> - static std::string Call(KernelContext*, const util::string_view& val) { - std::string result = val.to_string(); - std::transform(result.begin(), result.end(), result.begin(), - [](unsigned char c) { return std::toupper(c); }); - return result; +using TransformFunc = std::function<void(const uint8_t*, int64_t, uint8_t*)>; + +void StringDataTransform(KernelContext* ctx, const ExecBatch& batch, + TransformFunc transform, Datum* out) { + if (batch[0].kind() == Datum::ARRAY) { + const ArrayData& input = *batch[0].array(); + ArrayData* out_arr = out->mutable_array(); + // Reuse offsets from input + out_arr->buffers[1] = input.buffers[1]; + int64_t data_nbytes = input.buffers[2]->size(); + KERNEL_RETURN_IF_ERROR(ctx, ctx->Allocate(data_nbytes).Value(&out_arr->buffers[2])); + transform(input.buffers[2]->data(), data_nbytes, out_arr->buffers[2]->mutable_data()); Review comment: Good point. It's not accounted for in the unit tests either, can you open a JIRA issue? ---------------------------------------------------------------- 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