fix: avoid BinaryViewBuilder ReserveData(0) allocating a block#895
fix: avoid BinaryViewBuilder ReserveData(0) allocating a block#895fallintoplace wants to merge 1 commit into
Conversation
zeroshade
left a comment
There was a problem hiding this comment.
The ReserveData(0) short-circuit is reasonable, but the branch doesn't compile on its own:
arrow/array/binary_test.go:705:28: undefined: binaryViewNoAllocAllocator
FAIL github.com/apache/arrow-go/v18/arrow/array [build failed]
binaryViewNoAllocAllocator is introduced in #888 — it's not on main and not in this PR. Please rebase this on top of #888 (so the helper exists) or add the helper here. Once it builds, the guard + test look good.
Verified by checking out the PR head and running go test ./arrow/array/.
ecb3281 to
2c4b9b4
Compare
|
Rebased onto |
Summary
Problem
BinaryViewBuilder.ReserveData(length)always delegates tomultiBufferBuilder.Reserve(length). In practice,Reserve(0)can still create a full default block in the current implementation, which triggers an unnecessary allocation for batches that keep all-view data inlined.Change
BinaryViewBuilder.ReserveDatawhenlength == 0.blockBuilder.Reserve(0)for that path.Impact
ReserveDatacalls.Testing
ReserveDataallocation behavior.