alamb commented on code in PR #10136:
URL: https://github.com/apache/arrow-rs/pull/10136#discussion_r4087262930
##########
arrow-buffer/src/util/bit_chunk_iterator.rs:
##########
@@ -324,6 +324,20 @@ impl<'a> BitChunks<'a> {
ceil(self.chunk_len * 64 + self.remainder_len, 8)
}
+ /// Returns the `index`th complete chunk of 64 bits, the value
+ /// [`Self::iter`] yields at that position
+ ///
+ /// # Panics
+ ///
+ /// Panics if `index >= self.chunk_len()`
+ #[inline]
+ pub fn chunk(&self, index: usize) -> u64 {
+ assert!(index < self.chunk_len, "chunk index out of bounds");
+ // Safety: `index < chunk_len`, and the constructor checked the buffer
+ // covers every complete chunk plus the remainder byte
+ unsafe { read_chunk(self.buffer, self.bit_offset, index) }
Review Comment:
We may also want to add an unsafe version to elide this bounds check --
```rust
pub unsafe chunk_unchecked(..)
```
as that could help vectorize the inner loops even more
--
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]