Skip to content

UnsafeAppendBoolToBitmap for dictionary and REE builders#758

Open
serramatutu wants to merge 2 commits intoapache:mainfrom
serramatutu:serramatutu/UnsafeAppendBoolToBitmap-ree
Open

UnsafeAppendBoolToBitmap for dictionary and REE builders#758
serramatutu wants to merge 2 commits intoapache:mainfrom
serramatutu:serramatutu/UnsafeAppendBoolToBitmap-ree

Conversation

@serramatutu
Copy link
Copy Markdown

@serramatutu serramatutu commented Apr 10, 2026

Rationale for this change

For more context: https://github.com/apache/arrow-go/pull/558/changes#r2758798540

The Builders for REE and dict-encoded arrays were inheriting the UnsafeAppendBoolToBitmap() and UnsafeAppend() from the Builder interface defined in arrow/array/builder.go. The default implementation does not bump the length of the inner idxBuilder or runEndsBuilder, which causes it to be in an inconsistent state where the parent has greater length than the index/run-ends builder. This causes a panic when instancing a record batch.

What changes are included in this PR?

This PR makes UnsafeAppendBoolToBitmap() for RunEndEncodedBuilder panic as there is not a good semantic meaning for this method in case of REE.

It also implements UnsafeAppendBoolToBitmap() and UnsafeAppend() for the Dictionary builders. This allows users to use bldr.Reserve(n) followed by n calls to UnsafeAppend() or UnsafeAppendBoolToBitmap() without the need to check if the array needs to grow everytime.

Are these changes tested?

Yes.

Are there any user-facing changes?

No. The API was already there (inherited from Builder), but the behavior was incorrect.

@serramatutu serramatutu force-pushed the serramatutu/UnsafeAppendBoolToBitmap-ree branch from c2b7711 to 374a42f Compare April 10, 2026 23:26
@serramatutu serramatutu changed the title Implement UnsafeAppendBoolToBitmap for dictionary and REE builders Panic on UnsafeAppendBoolToBitmap for dictionary and REE builders Apr 10, 2026
@serramatutu serramatutu marked this pull request as ready for review April 10, 2026 23:28
@serramatutu serramatutu requested a review from zeroshade as a code owner April 10, 2026 23:28
For more context: https://github.com/apache/arrow-go/pull/558/changes#r2758798540

This commit makes `UnsafeAppendBoolToBitmap()` and `RunEndEncodedBuilder`
panic. The current implementation pulled from `arrow/array/builder.go`
would leave the builder in an invalid state that would panic when
trying to finish a record batch.
This commit adds a proper implementation of `UnsafeAppend` and
`UnsafeAppendBoolToBitmap` to the dictionary-encoded array builder.

This allows using `Reserve(n)` followed by `n` calls to `UnsafeAppend`
or `UnsafeAppendBoolToBitmap`.

I also added a test to it.
@serramatutu serramatutu force-pushed the serramatutu/UnsafeAppendBoolToBitmap-ree branch from 374a42f to 4551ae0 Compare April 12, 2026 14:03
@serramatutu serramatutu changed the title Panic on UnsafeAppendBoolToBitmap for dictionary and REE builders UnsafeAppendBoolToBitmap for dictionary and REE builders Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant