Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20636#discussion_r195110654
  
    --- Diff: 
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/codegen/BufferHolder.java
 ---
    @@ -61,12 +61,15 @@
        * Grows the buffer by at least neededSize and points the row to the 
buffer.
        */
       void grow(int neededSize) {
    -    if (neededSize > ARRAY_MAX - totalSize()) {
    +    assert neededSize < 0 :
    +      "Cannot grow BufferHolder by size " + neededSize + " because the 
size is negative";
    +    int roundedSize = 
ByteArrayMethods.roundNumberOfBytesToNearestWord(neededSize);
    +    if (roundedSize > ARRAY_MAX - totalSize()) {
           throw new UnsupportedOperationException(
    -        "Cannot grow BufferHolder by size " + neededSize + " because the 
size after growing " +
    +        "Cannot grow BufferHolder by size " + roundedSize + " because the 
size after growing " +
               "exceeds size limitation " + ARRAY_MAX);
         }
    -    final int length = totalSize() + neededSize;
    +    final int length = totalSize() + roundedSize;
    --- End diff --
    
    we only need to make `length * 2` word-aligned.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to