Rich-T-kid commented on code in PR #10813:
URL: https://github.com/apache/arrow-rs/pull/10813#discussion_r3848142723


##########
arrow-select/src/take.rs:
##########
@@ -462,37 +462,169 @@ fn take_bits<I: ArrowPrimitiveType>(
     indices: &PrimitiveArray<I>,
 ) -> BooleanBuffer {
     let len = indices.len();
+    let src_offset = values.offset();
+    let src_ptr = values.values().as_ptr();
+    let out_bytes = len.div_ceil(8);
 
     match indices.nulls().filter(|n| n.null_count() > 0) {
         Some(nulls) => {
-            let mut output_buffer = MutableBuffer::new_null(len);
-            let output_slice = output_buffer.as_slice_mut();
-            nulls.valid_indices().for_each(|idx| {
-                // SAFETY: idx is a valid index in indices.nulls() --> 
idx<indices.len()
-                if values.value(unsafe { 
indices.value_unchecked(idx).as_usize() }) {
-                    // SAFETY: MutableBuffer was created with space for 
indices.len() bit, and idx < indices.len()
-                    unsafe { bit_util::set_bit_raw(output_slice.as_mut_ptr(), 
idx) };
+            let mut output = MutableBuffer::new_null(len);
+            let out_ptr = output.as_mut_ptr();
+            nulls.valid_indices().for_each(|i| {
+                // SAFETY: i < len from the validity bitmap
+                let src_idx = unsafe { indices.value_unchecked(i) }.as_usize() 
+ src_offset;
+                // SAFETY: src_idx bounded by take's prior bounds check
+                unsafe {
+                    if bit_util::get_bit_raw(src_ptr, src_idx) {

Review Comment:
   this PR is in an unfinished state. I'm waiting for other PR's to be merged 
as theres some plumbing that is needed that i will rebase this PR on top of



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