fix(arrow/array): avoid allocating for ReserveData(0)#895
fix(arrow/array): avoid allocating for ReserveData(0)#895fallintoplace wants to merge 2 commits 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 |
4b25336 to
7241331
Compare
Rationale for this change
BinaryViewBuilder.ReserveData always delegated to the block builder. ReserveData(0) could therefore create a full default data block even when every value remains inline.
What changes are included in this PR?
Are these changes tested?
Yes. A no-allocation allocator verifies that ReserveData(0) does not allocate. The array and arrjson packages pass normal and race tests.
Are there any user-facing changes?
Zero-length reservations no longer allocate an unused data block. Positive reservations and the public API are unchanged.