You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/14 05:12:52 UTC

[GitHub] [arrow-rs] viirya commented on a diff in pull request #2061: Use `read_volatile` in `BitChunkIterator.next`

viirya commented on code in PR #2061:
URL: https://github.com/apache/arrow-rs/pull/2061#discussion_r920756928


##########
arrow/src/util/bit_chunk_iterator.rs:
##########
@@ -333,7 +333,7 @@ impl Iterator for BitChunkIterator<'_> {
             // the constructor ensures that bit_offset is in 0..8
             // that means we need to read at most one additional byte to fill in the high bits
             let next = unsafe {
-                std::ptr::read_unaligned(raw_data.add(index + 1) as *const u8) as u64
+                std::ptr::read_volatile(raw_data.add(index + 1) as *const u8) as u64

Review Comment:
   I think the doc is for `read_unaligned` usage that accesses the buffer pointer as u64:
   
   ```
   let current = unsafe { std::ptr::read_unaligned(raw_data.add(index)).to_le() };
   ```
   
   For accessing `next`, we only read a byte and case the byte to u64. So it is not a problem.
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org