You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/12/17 05:57:06 UTC

[GitHub] [arrow] jorgecarleitao commented on a change in pull request #8946: ARROW-10944: [Rust] Implement min/max aggregate kernels for BooleanArray

jorgecarleitao commented on a change in pull request #8946:
URL: https://github.com/apache/arrow/pull/8946#discussion_r544830660



##########
File path: rust/arrow/src/compute/kernels/aggregate.rs
##########
@@ -135,6 +137,40 @@ where
     Some(n)
 }
 
+/// Helper function to perform min/max lambda function on values from a `BooleanArray`
+fn min_max_boolean<F>(array: &BooleanArray, cmp: F) -> Option<bool>
+where
+    F: Fn(bool, bool) -> bool,
+{
+    let null_count = array.null_count();
+
+    // Includes case array.len() == 0
+    if null_count == array.len() {
+        return None;
+    }
+
+    let m0: Option<bool> = array.iter().next().unwrap();
+
+    array.iter().fold(m0, |max, item| match (max, item) {

Review comment:
       Good point. This is indeed simpler given the finite number of choices. Something like `.any(item)` would short-circuit, I think.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org