dragonknightk opened a new pull request, #1684: URL: https://github.com/apache/arrow-go/pull/1684
### Rationale for this change Fixes #1576 The import docs in `arrow/cdata` still say the stream reader and imported arrays are released through `runtime.SetFinalizer`. The code no longer works that way. The stream reader releases the stream on its last `Release` and only keeps `runtime.AddCleanup` as a fallback. An imported array calls its C release callback when its last buffer is released, and has no GC cleanup at all. The docs also say that batches returned by `Read` must be released by the caller, but the reader owns them and drops them on the next `Read`, so following the docs leads to a double release. ### What changes are included in this PR? Only docs and tests change: there is no new API, `arrio.Reader` is unchanged, and the docs now name a type assertion to `array.RecordReader` as the supported way to reach `Release`. ### Are these changes tested? Yes. A new test wraps an exported Go stream in a C stream that counts the stream release callback and the release callback of every batch it hands out. The batches mix a list column, a dictionary column and a null column. The cases are reading to the end, release before the first read, release in the middle of the stream, a retained reader, a get_next error, a get_schema error during import, a batch retained after the reader is released, and a batch with no buffers whose release callback runs at import. Every case checks that the stream was released once, that each batch was released once, and that the source memory goes back to zero. No case calls `runtime.GC`. ### Are there any user-facing changes? The import docs are updated. There is no API or behavior change. ## AI Disclosure Human-led contribution. Grok Bot, working for dragonknightk, assisted with this change, including the code, tests, and description. All submitted content was reviewed by a human before submission. -- 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]
