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 2021/08/25 16:08:11 UTC

[GitHub] [arrow] pitrou commented on a change in pull request #10876: ARROW-12728: [C++] Implement count_distinct/distinct hash aggregate kernels

pitrou commented on a change in pull request #10876:
URL: https://github.com/apache/arrow/pull/10876#discussion_r695902005



##########
File path: cpp/src/arrow/compute/kernels/hash_aggregate.cc
##########
@@ -1900,6 +1900,97 @@ struct GroupedAllImpl : public GroupedBooleanAggregator<GroupedAllImpl> {
                                  num_groups, /*out_offset=*/0, no_nulls);
   }
 };
+
+// ----------------------------------------------------------------------
+// CountDistinct/Distinct implementation
+
+struct GroupedCountDistinctImpl : public GroupedAggregator {
+  Status Init(ExecContext* ctx, const FunctionOptions* options) override {
+    ctx_ = ctx;
+    pool_ = ctx->memory_pool();
+    return Status::OK();
+  }
+
+  Status Resize(int64_t new_num_groups) override {
+    num_groups_ = new_num_groups;
+    return Status::OK();
+  }
+
+  Status Consume(const ExecBatch& batch) override {
+    return grouper_->Consume(batch).status();
+  }
+
+  Status Merge(GroupedAggregator&& raw_other,
+               const ArrayData& group_id_mapping) override {
+    auto other = checked_cast<GroupedCountDistinctImpl*>(&raw_other);
+
+    // Get (group_id, value) pairs, then translate the group IDs and consume them

Review comment:
       Nit: `(value, group_id)` pairs?




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org