mbutrovich commented on code in PR #11829:
URL: https://github.com/apache/arrow-rs/pull/11829#discussion_r4354827153


##########
arrow-select/src/take.rs:
##########
@@ -207,7 +207,14 @@ where
         };
     };
 
-    if indices.null_count() > 0 {
+    // Null slots usually hold in-bounds values, so first check every value 
with a loop that
+    // vectorizes, and look at validity only if that finds one out of bounds
+    let in_bounds = indices.values().iter().fold(true, |in_bounds, &i| {
+        in_bounds & (i >= T::Native::ZERO) & (i < len)

Review Comment:
   > using bit and here is intentional to enable vectorization?
   
   Yes. This is the existing fold from #8966, moved unchanged from the 
[no-nulls branch on 
`main`](https://github.com/apache/arrow-rs/blob/01a9917658fecd639991e92a5a5810be710b539c/arrow-select/src/take.rs#L220-L222)
 so that it also runs when the indices have nulls. #8966 links a godbolt 
example of the loop vectorizing.



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