felipecrv commented on code in PR #37468:
URL: https://github.com/apache/arrow/pull/37468#discussion_r1352838001
##########
go/arrow/array/concat.go:
##########
@@ -355,6 +356,164 @@ func concatOffsets(buffers []*memory.Buffer, byteWidth
int, mem memory.Allocator
}
}
+func sumArraySizes(data []arrow.ArrayData) int {
+ outSize := 0
+ for _, arr := range data {
+ outSize += arr.Len()
+ }
+ return outSize
+}
+
+func getListViewOffsets[T int32 | int64](data arrow.ArrayData, i int) []T {
+ bytes := data.Buffers()[i].Bytes()
+ base := (*T)(unsafe.Pointer(&bytes[0]))
+ ret := unsafe.Slice(base, data.Offset()+data.Len())
+ return ret[data.Offset():]
+}
+
+func putListViewOffsets32(in arrow.ArrayData, displacement int32, out
*memory.Buffer, outOff int) {
+ debug.Assert(in.DataType().ID() == arrow.LIST_VIEW,
"putListViewOffsets32: expected LIST_VIEW data")
+ inOff, inLen := in.Offset(), in.Len()
+ if inLen == 0 {
+ return
+ }
+ bitmap := in.Buffers()[0]
+ srcOffsets := getListViewOffsets[int32](in, 1)
+ srcSizes := getListViewOffsets[int32](in, 2)
+ isValidAndNonEmpty := func(i int) bool {
+ return (bitmap == nil || bitutil.BitIsSet(bitmap.Bytes(),
inOff+i)) && srcSizes[i] > 0
+ }
+
+ dstOffsets := arrow.Int32Traits.CastFromBytes(out.Bytes())
+ for i, offset := range srcOffsets {
+ if isValidAndNonEmpty(i) {
+ // This is guaranteed by RangeOfValuesUsed returning
the smallest offset
+ // of valid and non-empty list-views.
+ debug.Assert(offset+displacement >= 0,
"putListViewOffsets64: offset underflow while concatenating arrays")
Review Comment:
This is why I am a huge fan of meta-programming. I can't program. I need to
meta-program so the compiler programs for me.
--
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]