kszucs commented on a change in pull request #7478:
URL: https://github.com/apache/arrow/pull/7478#discussion_r446264863
##########
File path: cpp/src/arrow/compute/kernels/aggregate_basic.cc
##########
@@ -397,24 +452,26 @@ struct MinMaxImpl : public ScalarAggregator {
ArrayType arr(batch[0].array());
- local.has_nulls = arr.null_count() > 0;
+ const auto null_count = arr.null_count();
+ local.has_nulls = null_count > 0;
+ local.has_values = (arr.length() - null_count) > 0;
+
if (local.has_nulls && options.null_handling ==
MinMaxOptions::OUTPUT_NULL) {
this->state = local;
return;
}
- const auto values = arr.raw_values();
- if (arr.null_count() > 0) {
+ if (local.has_nulls) {
BitmapReader reader(arr.null_bitmap_data(), arr.offset(), arr.length());
for (int64_t i = 0; i < arr.length(); i++) {
if (reader.IsSet()) {
- local.MergeOne(values[i]);
+ local.MergeOne(arr.Value(i));
}
reader.Next();
}
} else {
for (int64_t i = 0; i < arr.length(); i++) {
- local.MergeOne(values[i]);
+ local.MergeOne(arr.Value(i));
}
Review comment:
We could optimize it further by early returning on the first occurrence
of true/false values. Going to create a jira once it's merged.
----------------------------------------------------------------
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:
[email protected]