candiduslynx commented on code in PR #35972:
URL: https://github.com/apache/arrow/pull/35972#discussion_r1221903051


##########
go/parquet/pqarrow/column_readers.go:
##########
@@ -296,11 +306,11 @@ func (sr *structReader) BuildArray(lenBound int64) 
(*arrow.Chunked, error) {
        buffers := make([]*memory.Buffer, 1)
        if validityIO.NullCount > 0 {
                buffers[0] = nullBitmap
+               defer nullBitmap.Release()
        }
-
        data := array.NewData(sr.filtered.Type, int(validityIO.Read), buffers, 
childArrData, int(validityIO.NullCount), 0)
        defer data.Release()
-       arr := array.MakeFromData(data)
+       arr := array.NewStructData(data)

Review Comment:
   call directly



##########
go/parquet/pqarrow/column_readers.go:
##########
@@ -443,14 +454,16 @@ func chunksToSingle(chunked *arrow.Chunked) 
(arrow.ArrayData, error) {
        case 0:
                return array.NewData(chunked.DataType(), 0, 
[]*memory.Buffer{nil, nil}, nil, 0, 0), nil
        case 1:
-               return chunked.Chunk(0).Data(), nil
+               data := chunked.Chunk(0).Data()
+               data.Retain() // we pass control to the caller

Review Comment:
   we want the caller to have the full control of the data (so, releasing the 
array after the chunksToSingle should have no effect on the returned data.
   For 0 len it was already true (we constructed a new data), so this retain 
comes in naturally



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to