This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-go.git
The following commit(s) were added to refs/heads/main by this push:
new 6331aa0a docs(arrow/cdata): clarify ExportRecordReader reference
ownership (#1599)
6331aa0a is described below
commit 6331aa0ad6484ddaab5c065ef7cf4cd54cde21e6
Author: Albert T. Wong <[email protected]>
AuthorDate: Tue Nov 17 13:52:43 2026 -0800
docs(arrow/cdata): clarify ExportRecordReader reference ownership (#1599)
### Rationale for this change
The `ExportRecordReader` comment says the caller does not need to
release the reader, but `exportStream` retains a separate reference and
the stream release callback releases that reference. Following the
existing comment can leave the caller's original reference unreleased.
Refs #1548. This is the comment clarification suggested in the
maintainer's reply; it does not attempt to close the broader
benchmarking request.
### What changes are included in this PR?
Clarify that the C stream retains its own reader reference, the caller
remains responsible for releasing its reference (which it may do
immediately after export), and the consumer must release the stream to
drop the stream's reference.
### Are these changes tested?
- `go test -count=1 -p 1 -race -tags assert,test ./arrow/cdata` — passed
on darwin/arm64 with Go 1.27.2.
- `git diff --check` — passed.
- Checked the wording against `exportStream`, `streamRelease`, and
`cRecordReader.release`.
### Are there any user-facing changes?
Corrected API documentation only; no runtime behavior or API changes.
---
arrow/cdata/interface.go | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arrow/cdata/interface.go b/arrow/cdata/interface.go
index 6641f267..53c402a5 100644
--- a/arrow/cdata/interface.go
+++ b/arrow/cdata/interface.go
@@ -277,10 +277,12 @@ func ExportArrowArray(arr arrow.Array, out *CArrowArray,
outSchema *CArrowSchema
// ExportRecordReader populates the CArrowArrayStream that is passed in with
the appropriate
// callbacks to be a working ArrowArrayStream utilizing the passed in
RecordReader. The
-// CArrowArrayStream takes ownership of the RecordReader until the consumer
calls the release
-// callback, as such it is unnecessary to call Release on the passed in reader
unless it has
-// previously been retained. To call that release callback and prevent a
memory leak, you can
-// call ReleaseCArrowArrayStream on the CArrowArrayStream once it is no longer
needed.
+// CArrowArrayStream retains its own reference to the RecordReader until the
consumer calls
+// the stream's release callback. The caller remains responsible for calling
Release on its
+// own reference to the reader and may do so immediately after
ExportRecordReader returns.
+// To release the stream's reference and prevent a memory leak, the consumer
must call the
+// stream's release callback, for example by calling ReleaseCArrowArrayStream
once the
+// CArrowArrayStream is no longer needed.
//
// WARNING: the output ArrowArrayStream MUST BE ZERO INITIALIZED, or the Go
garbage
// collector may error at runtime, due to CGO rules ("the current
implementation may