Commit ba22a21
authored
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`1 parent da98297 commit ba22a21
File tree
3 files changed
+135
-12
lines changed- arrow-array/src
- array
- builder
- arrow/benches
3 files changed
+135
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
439 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
440 | 482 | | |
441 | 483 | | |
442 | | - | |
443 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
444 | 517 | | |
445 | 518 | | |
446 | 519 | | |
| |||
450 | 523 | | |
451 | 524 | | |
452 | 525 | | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
457 | 534 | | |
458 | 535 | | |
459 | 536 | | |
| |||
599 | 676 | | |
600 | 677 | | |
601 | 678 | | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
602 | 693 | | |
603 | 694 | | |
604 | 695 | | |
| |||
617 | 708 | | |
618 | 709 | | |
619 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
620 | 734 | | |
621 | 735 | | |
622 | 736 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | | - | |
239 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | | - | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
236 | 235 | | |
237 | 236 | | |
238 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
239 | 245 | | |
240 | 246 | | |
241 | 247 | | |
| |||
0 commit comments