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 2020/11/09 06:03:16 UTC

[GitHub] [arrow] mrkn commented on a change in pull request #8612: ARROW-8199: [C++] Add support for multi-column sort indices on Table

mrkn commented on a change in pull request #8612:
URL: https://github.com/apache/arrow/pull/8612#discussion_r519569356



##########
File path: cpp/src/arrow/compute/kernels/vector_sort.cc
##########
@@ -125,35 +128,43 @@ class CompareSorter {
           std::stable_partition(indices_begin, indices_end,
                                 [&values](uint64_t ind) { return !values.IsNull(ind); });
     }
-    std::stable_sort(indices_begin, nulls_begin,
-                     [&values](uint64_t left, uint64_t right) {
-                       return values.GetView(left) < values.GetView(right);
-                     });
+    if (options.order == SortOrder::ASCENDING) {
+      std::stable_sort(indices_begin, nulls_begin,
+                       [&values](uint64_t left, uint64_t right) {
+                         return values.GetView(left) < values.GetView(right);
+                       });
+    } else {
+      std::stable_sort(indices_begin, nulls_begin,
+                       [&values](uint64_t left, uint64_t right) {
+                         return values.GetView(left) > values.GetView(right);

Review comment:
       This requires that all of `==`, `<`, and `>` are implemented in the value type.
   Instead, writing `right < left` here only requires `==` and `<`.
   IMHO, requiring only `==` and `<` is better to support extension types in the future.




----------------------------------------------------------------
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:
users@infra.apache.org