singhpratech opened a new issue, #1298:
URL: https://github.com/apache/arrow-go/issues/1298
**Describe the bug**
`compute.NewDatumWithoutOwning` returns the same `Datum` implementation as
`compute.NewDatum`, so
calling `Release()` on it compiles and runs like any other datum. But the
datum did not retain the
value, so that `Release()` drops the reference the caller's array still
depends on: the allocator
reports the buffers freed while the array is in scope and readable, and the
array's own later
`Release()` does not panic. The doc comment says "should not have Release
called on it", and ends
with a truncated sentence: "For the most part this is just a convenience
function.+-" (datum.go
line 278).
With the Go allocator this is silent, because the memory stays alive under
the garbage collector.
With a C allocator, or when the buffers were imported from C through the
cdata package, the same
call frees memory under a live array.
Go 1.27.1, macOS 26.6 (arm64), arrow-go v18.7.0; identical on v18.8.0-rc1.
```go
mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
b := array.NewInt64Builder(mem)
b.AppendValues([]int64{1, 2, 3}, nil)
arr := b.NewArray().(*array.Int64)
b.Release()
fmt.Println("after build:", mem.CurrentAlloc(), "bytes") // 128
bytes
d := compute.NewDatumWithoutOwning(arr)
d.Release() //
compiles; the doc says not to
fmt.Println("after datum.Release():", mem.CurrentAlloc(), "bytes,
arr.Len()", arr.Len(), arr.Int64Values())
arr.Release() // no
panic
```
Output:
```
after build: 128 bytes
after datum.Release(): 0 bytes, arr.Len() 3 [1 2 3]
```
For contrast, `compute.NewDatum(arr)` followed by `Release()` leaves 128
bytes allocated until
`arr.Release()`, as expected.
**Expected behavior**
One of: a non-owning datum whose `Release()` is a no-op (it owns nothing);
or a distinct type that
does not expose `Release`; or, at least, a panic on the over-release. And
the doc comment completed.
**Component(s)**
Go, Compute
--
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]