This is an automated email from the ASF dual-hosted git repository.

dheres pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 8aa91e519 Make bool_or an alias for max_boolean (#6100)
8aa91e519 is described below

commit 8aa91e519aa25587b7c79e08b2bb69b905b23927
Author: Simon Vandel Sillesen <[email protected]>
AuthorDate: Tue Jul 23 18:24:40 2024 +0300

    Make bool_or an alias for max_boolean (#6100)
    
    Improves `cargo bench --bench aggregate_kernels -- "bool/or"` throughput by 
68%-22366% on my machine
---
 arrow-arith/src/aggregate.rs       |  5 +----
 arrow/benches/aggregate_kernels.rs | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/arrow-arith/src/aggregate.rs b/arrow-arith/src/aggregate.rs
index ae4a5b008..f526268bf 100644
--- a/arrow-arith/src/aggregate.rs
+++ b/arrow-arith/src/aggregate.rs
@@ -674,10 +674,7 @@ pub fn bool_and(array: &BooleanArray) -> Option<bool> {
 ///
 /// Returns `None` if the array is empty or only contains null values.
 pub fn bool_or(array: &BooleanArray) -> Option<bool> {
-    if array.null_count() == array.len() {
-        return None;
-    }
-    Some(array.true_count() != 0)
+    max_boolean(array)
 }
 
 /// Returns the sum of values in the primitive array.
diff --git a/arrow/benches/aggregate_kernels.rs 
b/arrow/benches/aggregate_kernels.rs
index 71cd24278..9bb866f36 100644
--- a/arrow/benches/aggregate_kernels.rs
+++ b/arrow/benches/aggregate_kernels.rs
@@ -82,35 +82,53 @@ fn add_benchmark(c: &mut Criterion) {
             .bench_function("max nonnull mixed", |b| {
                 b.iter(|| max_boolean(&nonnull_bools_mixed))
             })
+            .bench_function("or nonnull mixed", |b| {
+                b.iter(|| bool_or(&nonnull_bools_mixed))
+            })
             .bench_function("min nonnull false", |b| {
                 b.iter(|| min_boolean(&nonnull_bools_all_false))
             })
             .bench_function("max nonnull false", |b| {
                 b.iter(|| max_boolean(&nonnull_bools_all_false))
             })
+            .bench_function("or nonnull false", |b| {
+                b.iter(|| bool_or(&nonnull_bools_all_false))
+            })
             .bench_function("min nonnull true", |b| {
                 b.iter(|| min_boolean(&nonnull_bools_all_true))
             })
             .bench_function("max nonnull true", |b| {
                 b.iter(|| max_boolean(&nonnull_bools_all_true))
             })
+            .bench_function("or nonnull true", |b| {
+                b.iter(|| bool_or(&nonnull_bools_all_true))
+            })
             .bench_function("min nullable mixed", |b| {
                 b.iter(|| min_boolean(&nullable_bool_mixed))
             })
             .bench_function("max nullable mixed", |b| {
                 b.iter(|| max_boolean(&nullable_bool_mixed))
             })
+            .bench_function("or nullable mixed", |b| {
+                b.iter(|| bool_or(&nullable_bool_mixed))
+            })
             .bench_function("min nullable false", |b| {
                 b.iter(|| min_boolean(&nullable_bool_all_false))
             })
             .bench_function("max nullable false", |b| {
                 b.iter(|| max_boolean(&nullable_bool_all_false))
             })
+            .bench_function("or nullable false", |b| {
+                b.iter(|| bool_or(&nullable_bool_all_false))
+            })
             .bench_function("min nullable true", |b| {
                 b.iter(|| min_boolean(&nullable_bool_all_true))
             })
             .bench_function("max nullable true", |b| {
                 b.iter(|| max_boolean(&nullable_bool_all_true))
+            })
+            .bench_function("or nullable true", |b| {
+                b.iter(|| bool_or(&nullable_bool_all_true))
             });
     }
 }

Reply via email to