zeroshade commented on code in PR #37468:
URL: https://github.com/apache/arrow/pull/37468#discussion_r1351212729


##########
go/arrow/array/concat.go:
##########
@@ -465,6 +476,26 @@ func concatListView(data []arrow.ArrayData, offsetType 
arrow.FixedWidthDataType,
        // Concatenate the sizes
        sizeBuffers := gatherBuffersFixedWidthType(data, 2, offsetType)
        sizeBuffer := concatBuffers(sizeBuffers, mem)
+       if out.Buffers()[0] != nil {
+               // To make sure the sizes don't reference values that are not 
in the new
+               // concatenated values array, we zero the sizes of null 
list-view values.
+               validity := out.Buffers()[0].Bytes()
+               if offsetType.ID() == arrow.INT32 {
+                       sizes := 
arrow.Int32Traits.CastFromBytes(sizeBuffer.Bytes())
+                       for i := 0; i < out.Len(); i++ {
+                               if !bitutil.BitIsSet(validity, out.offset+i) {
+                                       sizes[i] = 0
+                               }
+                       }
+               } else {
+                       sizes := 
arrow.Int64Traits.CastFromBytes(sizeBuffer.Bytes())
+                       for i := 0; i < out.Len(); i++ {
+                               if !bitutil.BitIsSet(validity, out.offset+i) {
+                                       sizes[i] = 0
+                               }
+                       }
+               }

Review Comment:
   lets avoid the duplication and just make this a generic function:
   
   ```go
   func zeroSizes[T int32 | int64](sizes []T, out ArrayData) {
           validity := out.Buffers()[0].Bytes()
           for i := 0; i < out.Len(); i++ {
                 if !bitutil.BitIsSet(validity, out.offset+i) {
                         sizes[i] = 0
                  }
             }
   }
   ```
   



-- 
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]

Reply via email to