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


##########
arrow-select/src/filter.rs:
##########
@@ -676,6 +677,74 @@ where
     RunArray::try_new(&run_ends, &values)
 }
 
+/// Extract bits from `src` at positions where `filter` has a 1, packed 
densely,
+/// processing 64 filter bits at a time
+fn gather_bits(src: &BooleanBuffer, filter: &BooleanBuffer, count: usize) -> 
Buffer {
+    let filter_chunks = filter.bit_chunks();
+    let src_chunks = BitChunks::new(src.values(), src.offset(), filter.len());
+
+    let out_u64s = bit_util::ceil(count, 64);
+    let mut out: Vec<u64> = Vec::with_capacity(out_u64s);
+    let mut current_word = 0u64;
+    let mut bits_filled = 0usize;
+
+    // Appends `bits_selected` densely-packed bits from `selected_bits` into 
the output word stream.
+    let mut push_chunk = |selected_bits: u64, bits_selected: usize| {
+        let bits_remaining = 64 - bits_filled;
+        current_word |= selected_bits << bits_filled;
+        if bits_selected < bits_remaining {
+            bits_filled += bits_selected;
+        } else {
+            // Current word is full; carry the overflow into the next word.
+            out.push(current_word);
+            current_word = if bits_selected == bits_remaining {
+                0
+            } else {
+                selected_bits >> bits_remaining
+            };
+            bits_filled = bits_selected - bits_remaining;
+        }
+    };
+
+    for (filter_word, src_word) in filter_chunks.iter().zip(src_chunks.iter()) 
{

Review Comment:
   I agree, can open up a follow on PR



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