R-JunmingChen commented on code in PR #37100:
URL: https://github.com/apache/arrow/pull/37100#discussion_r1308419854
##########
cpp/src/arrow/compute/kernels/aggregate_basic_internal.h:
##########
@@ -891,6 +891,105 @@ struct NullMinMaxImpl : public ScalarAggregator {
}
};
+template <SimdLevel::type SimdLevel>
+struct DictionaryMinMaxImpl : public ScalarAggregator {
+ using ThisType = DictionaryMinMaxImpl<SimdLevel>;
+
+ DictionaryMinMaxImpl(std::shared_ptr<DataType> out_type,
ScalarAggregateOptions options)
+ : options(std::move(options)),
+ out_type(std::move(out_type)),
+ has_nulls(false),
+ count(0),
+ min(nullptr),
+ max(nullptr) {
+ this->options.min_count = std::max<uint32_t>(1, this->options.min_count);
+ }
+
+ Status Consume(KernelContext*, const ExecSpan& batch) override {
+ if (batch[0].is_scalar()) {
+ return Status::NotImplemented("No min/max implemented for
DictionaryScalar");
+ }
+
+ DictionaryArray arr(batch[0].array.ToArrayData());
+ this->has_nulls = arr.null_count() > 0;
+ this->count += arr.length() - arr.null_count();
+
+ Datum dict_values(arr.dictionary());
+ ARROW_ASSIGN_OR_RAISE(Datum result, MinMax(std::move(dict_values)));
Review Comment:
>
https://github.com/apache/arrow/blob/main/cpp/src/parquet/column_writer.cc#L1683-L1688
>
> (I just found that parquet uses a "Take" here)
We have two ways to implement the MinMax Kernel For a DicionaryArray.
1. Take/DictionaryDecode firstly and then reuse MinMax Function with the
input of the decoded Array.
2. DictionaryCompaction firstly and then reuse MinMax Function with the
input of the compacted dictionary.
Each Time Complexity is O(n).
I think we should still insist on the latter one. Since, for DicionaryArray
whose dictionary is already compacted, the latter implementation could be
faster a little.
--
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]