Dandandan commented on code in PR #9284:
URL: https://github.com/apache/arrow-rs/pull/9284#discussion_r2737754463


##########
arrow-buffer/src/buffer/boolean.rs:
##########
@@ -336,28 +329,60 @@ impl BooleanBuffer {
                 }
             }
         }
+
+        if left_offset_in_bits == right_offset_in_bits {
+            // is aligned to byte boundary
+            if left_offset_in_bits & 0x7 == 0 {
+                let left = &left[left_offset_in_bits / 8..];
+                let right = &right[right_offset_in_bits / 8..];
+
+                let left_chunks = BitChunks::new(left, 0, len_in_bits);
+                let right_chunks = BitChunks::new(right, 0, len_in_bits);
+                let mut result = 
Vec::with_capacity(bit_util::ceil(len_in_bits, 64));
+
+                let l_iter = left
+                    .chunks_exact(8)
+                    .map(|c| u64::from_le_bytes(c.try_into().unwrap()));
+                let r_iter = right
+                    .chunks_exact(8)
+                    .map(|c| u64::from_le_bytes(c.try_into().unwrap()));
+
+                result.extend(l_iter.zip(r_iter).map(|(l, r)| op(l, r)));
+
+                if left_chunks.remainder_len() > 0 {
+                    result.push(op(
+                        left_chunks.remainder_bits(),
+                        right_chunks.remainder_bits(),
+                    ));
+                }
+                return BooleanBuffer::new(Buffer::from(result), 0, 
len_in_bits);
+            }
+
+            // both buffers have the same offset, we can use UnalignedBitChunk 
for both
+            let left_chunks = UnalignedBitChunk::new(left, 
left_offset_in_bits, len_in_bits);

Review Comment:
   I think we actually don't have to use this part (use the byte aligned one 
above and set the correct offset).



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