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 12:27:51 UTC

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

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



##########
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:
       Addressed in https://github.com/apache/arrow/pull/8946/commits/075277c7ae64c8d1aacf7a07c7cbf501c945570b -- I am actually quite happy with how the code looks now given this suggestion. 👍 




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