zeroshade commented on code in PR #557:
URL: https://github.com/apache/arrow-go/pull/557#discussion_r2478529987


##########
arrow/compute/internal/kernels/vector_selection.go:
##########
@@ -1486,7 +1486,15 @@ func VarBinaryImpl[OffsetT int32 | int64](ctx 
*exec.KernelCtx, batch *exec.ExecS
        if values.Len > 0 {
                dataLength := rawOffsets[values.Len] - rawOffsets[0]
                meanValueLen := float64(dataLength) / float64(values.Len)
-               dataBuilder.reserve(int(meanValueLen))
+               estimatedTotalSize := int(meanValueLen * float64(outputLength))
+
+               // Cap the pre-allocation at a reasonable size
+               const maxPreAlloc = 16777216 // 16 MB
+               if estimatedTotalSize > maxPreAlloc {
+                       estimatedTotalSize = maxPreAlloc
+               }

Review Comment:
   ```suggestion
                estimatedTotalSize = min(maxPreAlloc, estimatedTotalSize)
   ```



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