mbutrovich opened a new pull request, #12347: URL: https://github.com/apache/arrow-rs/pull/12347
# Which issue does this PR close? - Closes #12346 # Rationale for this change The issue explains the problem. @neilconway wrote the DataFusion version in apache/datafusion#26507, which this follows. # What changes are included in this PR? New public items: - `arrow_buffer::bit_iterator::SetBitCounter`, with `new`, `count_before`, and `count_range` - `BooleanBuffer::set_bit_counter` Compared with the DataFusion version, the counter takes the bitmap instead of an iterator of words, restarts from the start when a position decreases instead of looping forever, and panics on a position past the end. Positions that decrease past a 64-bit word each cost a rescan from the start, so a caller that visits rows out of order is slower than with `count_set_bits_offset`. # Are these changes tested? Unit tests in `arrow-buffer/src/util/bit_iterator.rs` compare every position and a set of ranges against a naive count, over lengths from 0 to 300 at aligned and unaligned offsets. They also cover decreasing positions and each panic. The new methods have doctests. The `set_bit_counter` benchmark in `arrow-buffer/benches` compares per-row `count_set_bits_offset` with the counter for 8192 rows of widths 4, 32, and 256, with constant and random row lengths, at offsets 0 and 3. TODO: benchmark bot results. # Are there any significant user-facing changes? No. The change only adds API. # AI usage disclosure I wrote this PR with help from Claude but understand and support the core approach, implementation, and test coverage. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
