Skip to content

Commit

Permalink
MINOR: [Go] Test that we retain/release the right number of times (#3…
Browse files Browse the repository at this point in the history
…6676)

### 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 <li.davidm96@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
  • Loading branch information
lidavidm authored Jul 14, 2023
1 parent cf558cc commit fd9f4de
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions go/arrow/cdata/cdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit fd9f4de

Please sign in to comment.