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 2020/06/17 14:08:33 UTC

[GitHub] [arrow] bkietz commented on a change in pull request #7458: ARROW-9122: [C++] Properly handle sliced arrays in ascii_lower, ascii_upper kernels

bkietz commented on a change in pull request #7458:
URL: https://github.com/apache/arrow/pull/7458#discussion_r441572451



##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -41,16 +41,50 @@ struct AsciiLength {
 
 using TransformFunc = std::function<void(const uint8_t*, int64_t, uint8_t*)>;
 
+template <typename T>

Review comment:
       ```suggestion
   // Transform a buffer of offsets to one which begins with 0 and has equivalent value lengths
   template <typename T>
   ```

##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -41,16 +41,50 @@ struct AsciiLength {
 
 using TransformFunc = std::function<void(const uint8_t*, int64_t, uint8_t*)>;
 
+template <typename T>
+Status GetShiftedOffsets(KernelContext* ctx, const Buffer& input_buffer, int64_t offset,
+                         int64_t length, std::shared_ptr<Buffer>* out) {
+  ARROW_ASSIGN_OR_RAISE(*out, ctx->Allocate((length + 1) * sizeof(T)));
+  const T* input_offsets = reinterpret_cast<const T*>(input_buffer.data()) + offset;
+  T* out_offsets = reinterpret_cast<T*>((*out)->mutable_data());
+  T first_offset = *input_offsets;
+  for (int64_t i = 0; i < length; ++i) {
+    *out_offsets++ = input_offsets[i] - first_offset;
+  }
+  *out_offsets = input_offsets[length] - first_offset;
+  return Status::OK();
+}
+
+template <typename Type>

Review comment:
       ```suggestion
   // Apply `transform` to input character data- this function cannot change the length
   // of any string value in the input.
   template <typename Type>
   ```




----------------------------------------------------------------
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:
users@infra.apache.org