liyafan82 commented on a change in pull request #7837:
URL: https://github.com/apache/arrow/pull/7837#discussion_r469660938
##########
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:
Nice catch. Thank you.
----------------------------------------------------------------
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:
[email protected]