pitrou commented on code in PR #46408:
URL: https://github.com/apache/arrow/pull/46408#discussion_r2095263076


##########
cpp/src/arrow/ipc/writer.cc:
##########
@@ -327,11 +327,9 @@ class RecordBatchSerializer {
     auto offsets = array.value_offsets();
 
     int64_t required_bytes = sizeof(offset_type) * (array.length() + 1);
-    if (array.offset() != 0) {
-      // If we have a non-zero offset, then the value offsets do not start at
-      // zero. We must a) create a new offsets array with shifted offsets and
-      // b) slice the values array accordingly
-
+    if (array.offset() != 0 || (array.length() > 0 && array.value_offset(0) > 
0)) {

Review Comment:
   I wonder if we cannot remove the old condition:
   ```suggestion
       if (array.length() > 0 && array.value_offset(0) > 0) {
   ```
   
   For example, if the offsets buffer contains `[0, 0, 0, 2, 3]`, then with 
`array.offset() == 2` we would just need to truncate the offsets buffer without 
rebuilding a new one. That could be done by generalizing the `SliceBuffer` path 
below.
   
   (but we would have to make sure this case is properly unit-tested, of course)



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