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 2022/07/19 08:48:56 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #13646: ARROW-17096: [C++][Compute] Fix mode kernel error on boolean array

pitrou commented on code in PR #13646:
URL: https://github.com/apache/arrow/pull/13646#discussion_r924232114


##########
cpp/src/arrow/compute/kernels/aggregate_mode.cc:
##########
@@ -201,18 +203,21 @@ struct CountModer<BooleanType> {
     const int64_t distinct_values = (this->counts[0] != 0) + (this->counts[1] != 0);
     const int64_t n = std::min(options.n, distinct_values);
 
-    bool* mode_buffer;
+    uint8_t* mode_buffer;
     int64_t* count_buffer;
     ARROW_ASSIGN_OR_RAISE(std::tie(mode_buffer, count_buffer),
-                          PrepareOutput<BooleanType>(n, ctx, type, out));
+                          (PrepareOutput<BooleanType, uint8_t>(n, ctx, type, out)));
 
     if (n >= 1) {
-      const bool index = counts[1] > counts[0];
-      mode_buffer[0] = index;
-      count_buffer[0] = counts[index];
+      // at most two bits are useful in mode buffer
+      bit_util::ClearBitmap(mode_buffer, 0, 8);

Review Comment:
   Simply `mode_buffer[0] = 0`?



-- 
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