You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix "Incorrect Behavior of Collecting a filtered iterator to a BooleanArray" (#8543)
# Which issue does this PR close?
- Closes#8505 .
# Rationale for this change
Fix the bug and align `BooleanArray::from_iter` to
`PrimitiveArray::from_iter`
In `BooleanArray::from_iter`:
Collecting to a `Vec` and then using `from_trusted_len_iter` was almost
double as fast as using `BooleanBufferBuilder` on my machine.
# What changes are included in this PR?
- Use builders in `BooleanArray::from_iter` to fix the wrong behavior
- Introduce `BooleanArray::from_trusted_len_iter` for a more performant
version (The old version of `BooleanArray::from_iter`, just with unsafe
flavor of `bit_util::set_bit_raw`)
- Add `BooleanAdapter`, inspired by `NativeAdapter` from the
`PrimitiveArray`. This allows also doing `BooleanArray::from_iter([true,
false].into_iter())`.
# Are these changes tested?
- New test to cover the initial bug
- New test to cover `BooleanArray::from_trusted_len_iter` directly (old
`BooleanArray::from_iter` also cover it indirectly)
- New test to document that you can directly collect `[false, true,
...]` (no `Option`)
# Are there any user-facing changes?
- `BooleanArray::from_iter` has a "slight" performance regression that
users could observe.
- Allow directly collecting bools to a `BooleanArray`
- `BooleanArray::from_trusted_len_iter`
0 commit comments