hcrosse commented on code in PR #1602:
URL: https://github.com/apache/arrow-go/pull/1602#discussion_r4607849766
##########
arrow/scalar/append.go:
##########
@@ -190,13 +190,22 @@ func appendToBldr(bldr array.Builder, scalars []Scalar)
error {
}
bldr.ValueBuilder().Reserve(numChildren)
+ // List-view builders do not support Append and need the size
up front.
+ appendList := func(int) { bldr.Append(true) }
+ switch b := bldr.(type) {
+ case *array.ListViewBuilder:
+ appendList = func(n int) { b.AppendWithSize(true, n) }
Review Comment:
`ListBuilder` narrows the child length the same way, through
`appendNextOffset` and `int32(o)`, so on main `Append` of `list` scalars whose
children pass `math.MaxInt32` gives the same invalid offsets. List views follow
that existing builder behavior here. A check for it would belong in the
builders, for every list type with 32 bit offsets.
##########
arrow/scalar/append.go:
##########
@@ -190,13 +190,22 @@ func appendToBldr(bldr array.Builder, scalars []Scalar)
error {
}
bldr.ValueBuilder().Reserve(numChildren)
+ // List-view builders do not support Append and need the size
up front.
+ appendList := func(int) { bldr.Append(true) }
+ switch b := bldr.(type) {
+ case *array.ListViewBuilder:
+ appendList = func(n int) { b.AppendWithSize(true, n) }
+ case *array.LargeListViewBuilder:
+ appendList = func(n int) { b.AppendWithSize(true, n) }
+ }
+
for _, s := range scalars {
if !s.IsValid() {
bldr.AppendNull()
continue
}
- bldr.Append(true)
list := s.(ListScalar).GetList()
+ appendList(list.Len())
Review Comment:
This loop is shared with `list` and `large_list`, and on main it also never
releases the scalars from `GetScalar`. I left that existing leak out of this
change.
--
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]