lidavidm commented on a change in pull request #10994:
URL: https://github.com/apache/arrow/pull/10994#discussion_r695892300
##########
File path: cpp/src/arrow/compute/kernels/hash_aggregate.cc
##########
@@ -1700,14 +1802,30 @@ struct GroupedMinMaxImpl : public GroupedAggregator {
auto raw_mins = reinterpret_cast<CType*>(mins_.mutable_data());
auto raw_maxes = reinterpret_cast<CType*>(maxes_.mutable_data());
- VisitArrayValuesInline<Type>(
- *batch[0].array(),
- [&](CType val) {
+ if (batch[0].is_array()) {
+ VisitArrayValuesInline<Type>(
+ *batch[0].array(),
+ [&](CType val) {
+ raw_maxes[*g] = std::max(raw_maxes[*g], val);
+ raw_mins[*g] = std::min(raw_mins[*g], val);
+ BitUtil::SetBit(has_values_.mutable_data(), *g++);
+ },
+ [&] { BitUtil::SetBit(has_nulls_.mutable_data(), *g++); });
+ } else {
+ const auto& input = *batch[0].scalar();
+ if (input.is_valid) {
+ const auto val = UnboxScalar<Type>::Unbox(input);
+ for (int64_t i = 0; i < batch.length; i++) {
raw_maxes[*g] = std::max(raw_maxes[*g], val);
raw_mins[*g] = std::min(raw_mins[*g], val);
BitUtil::SetBit(has_values_.mutable_data(), *g++);
- },
- [&] { BitUtil::SetBit(has_nulls_.mutable_data(), *g++); });
+ }
+ } else {
+ for (int64_t i = 0; i < batch.length; i++) {
+ BitUtil::SetBit(has_nulls_.mutable_data(), *g++);
+ }
+ }
+ }
Review comment:
You gave me hope that a helper like this already existed :( But that is
a good idea, it would clean things up quite a bit.
--
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]