This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new fd9f4de6f8 MINOR: [Go] Test that we retain/release the right number of 
times (#36676)
fd9f4de6f8 is described below

commit fd9f4de6f89853f257bb61f0608aca839e63ca73
Author: David Li <[email protected]>
AuthorDate: Fri Jul 14 15:13:47 2023 -0400

    MINOR: [Go] Test that we retain/release the right number of times (#36676)
    
    
    
    ### Rationale for this change
    
    Just make sure that we're retaining/releasing the correct number of times 
in the C Data Interface.
    
    ### What changes are included in this PR?
    
    Add a unit test
    
    ### Are these changes tested?
    
    Yes
    
    ### Are there any user-facing changes?
    
    No
    
    Authored-by: David Li <[email protected]>
    Signed-off-by: David Li <[email protected]>
---
 go/arrow/cdata/cdata_test.go | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/go/arrow/cdata/cdata_test.go b/go/arrow/cdata/cdata_test.go
index f4c09000cb..0c4bbae3d5 100644
--- a/go/arrow/cdata/cdata_test.go
+++ b/go/arrow/cdata/cdata_test.go
@@ -769,6 +769,34 @@ func TestExportRecordReaderStream(t *testing.T) {
        assert.EqualValues(t, len(reclist), i)
 }
 
+func TestExportRecordReaderStreamLifetime(t *testing.T) {
+       mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
+       defer mem.AssertSize(t, 0)
+
+       schema := arrow.NewSchema([]arrow.Field{
+               {Name: "strings", Type: arrow.BinaryTypes.String, Nullable: 
false},
+       }, nil)
+
+       bldr := array.NewBuilder(mem, &arrow.StringType{})
+       defer bldr.Release()
+
+       arr := bldr.NewArray()
+       defer arr.Release()
+
+       rec := array.NewRecord(schema, []arrow.Array{arr}, 0)
+       defer rec.Release()
+
+       rdr, _ := array.NewRecordReader(schema, []arrow.Record{rec})
+       defer rdr.Release()
+
+       out := createTestStreamObj()
+       ExportRecordReader(rdr, out)
+
+       // C Stream is holding on to memory
+       assert.NotEqual(t, 0, mem.CurrentAlloc())
+       releaseStream(out)
+}
+
 func TestEmptyListExport(t *testing.T) {
        bldr := array.NewBuilder(memory.DefaultAllocator, 
arrow.LargeListOf(arrow.PrimitiveTypes.Int32))
        defer bldr.Release()

Reply via email to