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/08/12 17:02:35 UTC

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

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



##########
File path: java/algorithm/src/main/java/org/apache/arrow/algorithm/sort/VariableWidthOutOfPlaceVectorSorter.java
##########
@@ -45,6 +46,22 @@ public void sortOutOfPlace(V srcVector, V dstVector, VectorValueComparator<V> co
     ArrowBuf dstValueBuffer = dstVector.getDataBuffer();
     ArrowBuf dstOffsetBuffer = dstVector.getOffsetBuffer();
 
+    // check buffer size
+    Preconditions.checkArgument(dstValidityBuffer.capacity() * 8 >= srcVector.getValueCount(),
+        "Not enough capacity for the validity buffer of the dst vector. " +
+            "Expected capacity %s, actual capacity %s",
+        (srcVector.getValueCount() + 7) / 8, dstValidityBuffer.capacity());
+    Preconditions.checkArgument(
+        dstOffsetBuffer.capacity() >= srcVector.getValueCount() * BaseVariableWidthVector.OFFSET_WIDTH,
+        "Not enough capacity for the offset buffer of the dst vector. " +
+            "Expected capacity %s, actual capacity %s",
+        srcVector.getValueCount() * BaseVariableWidthVector.OFFSET_WIDTH, dstValueBuffer.capacity());

Review comment:
       nit: `dstValueBuffer` -> `dstOffsetBuffer`




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