CurtHagenlocher opened a new pull request, #543: URL: https://github.com/apache/arrow-dotnet/pull/543
### What's changed? This applies #537 to `maint-23.x`, along with the parts of #534 it builds on. A record batch read from a stream owned its message body and disposed it directly, while its buffers were plain views of the body. Anything that shared those buffers, such as `SliceShared`, `ArrayData.Retain` or export through the C Data Interface, did not keep the body alive. - The reader wraps a record batch message's body in a `MessageBody`. Each buffer that views the body, including a buffer stored uncompressed in a compressed stream, holds its own reference to its slice of it. - The batch holds no reference of its own, so the body is released along with the last buffer that refers to it. A compressed body is released as soon as its buffers have been decompressed. - A `SharedMemoryHandle` can now refer to a slice of its owner's memory, and keeps that slice when retained. - A batch read with the default allocator can now be disposed while it is exported. Before, the export pinned the body, and disposing the batch threw `InvalidOperationException`. The change is adapted by hand: this branch doesn't have #525, so `MessageBody` takes no allocation lifetime, and dictionary batches keep their current handling. Readers over a `ReadOnlyMemory<byte>`, and Flight, are unchanged. ### Testing - `RecordBatchBodyReferenceTests` comes from #537, except the two concatenation tests, which depend on #444. `GarbageMemoryAllocator` and `TestDeflateCodecFactory` come from main for these tests. - `CDataInterfacePythonTests.EarlyDisposeOfExportedBatch` now disposes the batch while it is exported and checks that pyarrow still reads the same data. All of `Apache.Arrow.Tests` (net8.0, net462, net472), `Apache.Arrow.Compression.Tests` and `Apache.Arrow.Flight.Tests` pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012dFdcrBz22tRjiyNwBd7VB -- 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]
