HaoYang670 commented on code in PR #2646:
URL: https://github.com/apache/arrow-rs/pull/2646#discussion_r962310475


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -59,12 +59,30 @@ where
     let null_bit_buffer =
         combine_option_bitmap(&[left.data_ref(), right.data_ref()], 
left.len())?;
 
-    // Safety:
-    // `i < $left.len()` and $left.len() == $right.len()
-    let comparison = (0..left.len())
-        .map(|i| unsafe { op(left.value_unchecked(i), 
right.value_unchecked(i)) });
-    // same size as $left.len() and $right.len()
-    let buffer = unsafe { 
MutableBuffer::from_trusted_len_iter_bool(comparison) };
+    let mut buffer = MutableBuffer::new((left.len() + 7) / 8);
+
+    let chunks = left.len() / 8;

Review Comment:
   We should add some comment about why we don't use `iter` here, to avoid 
other developers bringing the `iter` back.



##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -59,12 +59,30 @@ where
     let null_bit_buffer =
         combine_option_bitmap(&[left.data_ref(), right.data_ref()], 
left.len())?;
 
-    // Safety:
-    // `i < $left.len()` and $left.len() == $right.len()
-    let comparison = (0..left.len())
-        .map(|i| unsafe { op(left.value_unchecked(i), 
right.value_unchecked(i)) });
-    // same size as $left.len() and $right.len()
-    let buffer = unsafe { 
MutableBuffer::from_trusted_len_iter_bool(comparison) };
+    let mut buffer = MutableBuffer::new((left.len() + 7) / 8);

Review Comment:
   We have the `ceil` function in `bit_util.rs`, you can use it.



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