Copilot commented on code in PR #1596:
URL: https://github.com/apache/arrow-go/pull/1596#discussion_r4603529664


##########
arrow/array/util.go:
##########
@@ -363,6 +363,27 @@ func GetDictArrayData(mem memory.Allocator, valueType 
arrow.DataType, memoTable
                        valuesz := offsets[len(offsets)-1] - offsets[0]
                        buffers[2].Resize(int(valuesz))
                        tbl.CopyValuesSubset(startOffset, buffers[2].Bytes())
+               case arrow.BINARY_VIEW, arrow.STRING_VIEW:
+                       bldr := NewBinaryViewBuilder(mem)
+                       defer bldr.Release()
+                       bldr.dtype = valueType.(arrow.BinaryDataType)
+                       bldr.Reserve(dictLen)
+                       nullIdx, hasNull := tbl.GetNull()
+                       outOfLine := 0
+                       for i := startOffset; i < tbl.Size(); i++ {
+                               if n := len(tbl.Value(i)); 
!arrow.IsViewInline(n) {
+                                       outOfLine += n
+                               }
+                       }

Review Comment:
   The `outOfLine` pre-reservation loop reads `tbl.Value(i)` for every entry, 
including the null slot. For view dictionaries, a null view may contain 
arbitrary bytes (as noted in the PR description), so using 
`len(tbl.Value(nullIdx))` can wildly over-reserve memory and also contradicts 
the later logic that avoids reading null values. Fix by skipping the null slot 
when computing `outOfLine` (e.g., treat null as length 0 when `hasNull && i == 
nullIdx`).



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