kou commented on code in PR #46706:
URL: https://github.com/apache/arrow/pull/46706#discussion_r2127490089


##########
cpp/src/arrow/ipc/writer.cc:
##########
@@ -329,15 +329,24 @@ class RecordBatchSerializer {
       return Status::OK();
     }
 
-    int64_t required_bytes = sizeof(offset_type) * (array.length() + 1);
-    if (array.value_offset(0) > 0) {
+    const int64_t required_bytes = sizeof(offset_type) * (array.length() + 1);
+
+    offset_type first_offset = 0;
+    RETURN_NOT_OK(MemoryManager::CopyBufferSliceToCPU(
+        array.data()->buffers[1], array.offset() * sizeof(offset_type),
+        sizeof(offset_type), reinterpret_cast<uint8_t*>(&first_offset)));
+
+    if (first_offset > 0) {
       // If the offset of the first value is non-zero, then we must create a 
new
       // offsets buffer with shifted offsets.
+      if (!array.data()->buffers[1]->is_cpu()) {
+        return Status::NotImplemented("Rebasing non-CPU offsets");
+      }

Review Comment:
   Ah, I misunderstood `MemoryManager::CopyBufferSliceToCPU()`.
   I thought that `MemoryManager::CopyBufferSliceToCPU()` updates 
`array.data()->buffers[1]`. But it copies to `first_offset`.



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