Copilot commented on code in PR #536:
URL: https://github.com/apache/arrow-dotnet/pull/536#discussion_r4799648744


##########
src/Apache.Arrow/RecordBatch.cs:
##########
@@ -111,6 +121,11 @@ public RecordBatch Slice(int offset, int length)
             return new RecordBatch(Schema, _arrays.Select(a => 
ArrowArrayFactory.Slice(a, offset, length)), length);
         }
 
+        /// <summary>
+        /// Slices this record batch with shared ownership. The result keeps 
the underlying
+        /// buffers alive via reference counting, so it remains valid after 
the original is
+        /// disposed. The caller must dispose the returned record batch when 
done.

Review Comment:
   This lifetime guarantee does not hold for uncompressed IPC batches: 
`ArrowReaderImplementation.cs:174-176` keeps the body owner on the original 
batch, and retaining its non-owning buffers does not retain that owner. 
Disposing the original therefore invalidates the shared slice's backing memory. 
Qualify this summary and the `Slice` recommendation at lines 110–111, advising 
callers to keep the original alive or use `Clone` for independently owned 
memory.



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