hcrosse commented on code in PR #1595:
URL: https://github.com/apache/arrow-go/pull/1595#discussion_r4604724678
##########
arrow/compute/exprs/exec_test.go:
##########
@@ -1187,6 +1207,37 @@ func TestListElementRefPerRow(t *testing.T) {
})
}
+// makeListView returns a function that builds a (large) list view whose rows
+// are the given views over the strings "a" to "f". A nil valid means all rows
+// are valid.
+func makeListView(large bool, offsets, sizes []int32, valid []bool)
func(memory.Allocator) arrow.Array {
+ return func(mem memory.Allocator) arrow.Array {
+ values := []string{"a", "b", "c", "d", "e", "f"}
+ if valid == nil {
+ valid = make([]bool, len(offsets))
+ for i := range valid {
+ valid[i] = true
+ }
+ }
Review Comment:
When `valid` is nil, the first call fills it with `true` for every row.
Later calls reuse that slice and build arrays with the same values.
##########
arrow/compute/exprs/exec_test.go:
##########
@@ -1187,6 +1207,37 @@ func TestListElementRefPerRow(t *testing.T) {
})
}
+// makeListView returns a function that builds a (large) list view whose rows
+// are the given views over the strings "a" to "f". A nil valid means all rows
+// are valid.
+func makeListView(large bool, offsets, sizes []int32, valid []bool)
func(memory.Allocator) arrow.Array {
+ return func(mem memory.Allocator) arrow.Array {
+ values := []string{"a", "b", "c", "d", "e", "f"}
+ if valid == nil {
+ valid = make([]bool, len(offsets))
+ for i := range valid {
+ valid[i] = true
+ }
+ }
+ if !large {
+ b := array.NewListViewBuilder(mem,
arrow.BinaryTypes.String)
+ defer b.Release()
+
b.ValueBuilder().(*array.StringBuilder).AppendValues(values, nil)
+ b.AppendValuesWithSizes(offsets, sizes, valid)
+ return b.NewArray()
+ }
+ b := array.NewLargeListViewBuilder(mem,
arrow.BinaryTypes.String)
+ defer b.Release()
+ b.ValueBuilder().(*array.StringBuilder).AppendValues(values,
nil)
+ offsets64, sizes64 := make([]int64, len(offsets)),
make([]int64, len(sizes))
+ for i := range offsets {
+ offsets64[i], sizes64[i] = int64(offsets[i]),
int64(sizes[i])
+ }
Review Comment:
I use this helper only for the literal tables in this test, where the
lengths match.
--
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]