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/07/29 07:41:16 UTC

[GitHub] [arrow] liyafan82 commented on a change in pull request #7837: ARROW-9554: [Java] FixedWidthInPlaceVectorSorter sometimes produces wrong result

liyafan82 commented on a change in pull request #7837:
URL: https://github.com/apache/arrow/pull/7837#discussion_r461405705



##########
File path: java/algorithm/src/test/java/org/apache/arrow/algorithm/sort/TestFixedWidthInPlaceVectorSorter.java
##########
@@ -209,4 +212,29 @@ public void testChoosePivotAllPermutes() {
       }
     }
   }
+
+  @Test
+  public void testSortInt2() {
+    try (IntVector vector = new IntVector("vector", allocator)) {
+      ValueVectorDataPopulator.setVector(vector,
+          0, 1, 2, 3, 4, 5, 30, 31, 32, 33,
+          34, 35, 60, 61, 62, 63, 64, 65, 6, 7,
+          8, 9, 10, 11, 36, 37, 38, 39, 40, 41,
+          66, 67, 68, 69, 70, 71);
+
+      FixedWidthInPlaceVectorSorter sorter = new FixedWidthInPlaceVectorSorter();
+      VectorValueComparator<IntVector> comparator = DefaultVectorComparators.createDefaultComparator(vector);
+
+      sorter.sortInPlace(vector, comparator);
+
+      String actual = "[" + String.join(
+          ", ", IntStream.range(0, vector.getValueCount()).mapToObj(
+              i -> String.valueOf(vector.get(i))).collect(Collectors.toList())) + "]";
+
+      assertEquals(
+          "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, " +

Review comment:
       Revised the code accordingly. Thanks for the good suggestion. 




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