mbutrovich commented on code in PR #10136:
URL: https://github.com/apache/arrow-rs/pull/10136#discussion_r4094211181
##########
arrow-buffer/src/util/bit_chunk_iterator.rs:
##########
@@ -360,6 +374,38 @@ impl<'a> IntoIterator for &BitChunks<'a> {
}
}
+/// Reads the `index`th complete 64-bit chunk of `buffer`, whose bits start
+/// at `bit_offset` (in `0..8`)
+///
+/// # Safety
+///
+/// `index` must be less than the number of complete chunks, so that the
+/// buffer holds at least `index * 8 + 8` bytes, plus one more byte when
+/// `bit_offset != 0` (the remainder byte the constructor guarantees)
+#[inline]
+unsafe fn read_chunk(buffer: &[u8], bit_offset: usize, index: usize) -> u64 {
+ // cast to *const u64 should be fine since we are using read_unaligned
below
Review Comment:
`bit_offset` can be 0 here, and `read_chunk` is a free function without
`chunk_len`, so those two asserts would need adjusting. Checking the byte count
from the `# Safety` doc directly would work for both callers:
```rust
debug_assert!(bit_offset < 8);
debug_assert!(buffer.len() >= index * 8 + 8 + usize::from(bit_offset !=
0));
```
I ran the `arrow-buffer` `bit_chunk` tests and the `arrow-select` filter
tests with these in place and they pass.
--
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]