mzabaluev commented on code in PR #11872:
URL: https://github.com/apache/arrow-rs/pull/11872#discussion_r4381321406


##########
arrow-select/src/filter.rs:
##########
@@ -1245,6 +1255,105 @@ fn filter_sparse_union(
     })
 }
 
+/// Sets the bits of `bytes` in the non-empty range `start..end`
+fn set_bit_range(bytes: &mut [u8], start: usize, end: usize) {
+    debug_assert!(start < end);
+    let (start_byte, end_byte) = (start / 8, end / 8);
+    let head = 0xFF << (start % 8);
+    let tail = !(0xFF << (end % 8));
+    if start_byte == end_byte {
+        bytes[start_byte] |= head & tail;
+        return;
+    }
+    bytes[start_byte] |= head;
+    bytes[start_byte + 1..end_byte].fill(0xFF);
+    if tail != 0 {

Review Comment:
   The only way this condition is true is when `end` is aligned to the byte 
following the range, as the range end is non-inclusive. So this guards against 
a one-past-the-end write.



-- 
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]

Reply via email to