ulysses-you commented on a change in pull request #32106:
URL: https://github.com/apache/spark/pull/32106#discussion_r611409677
##########
File path:
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java
##########
@@ -1009,7 +1009,8 @@ public static UTF8String concatWs(UTF8String separator,
UTF8String... inputs) {
// Allocate a new byte array, and copy the inputs one by one into it.
// The size of the new array is the size of all inputs, plus the
separators.
- final byte[] result = new byte[numInputBytes + (numInputs - 1) *
separator.numBytes];
+ int intNumInputBytes = Math.toIntExact(numInputBytes + (numInputs - 1) *
separator.numBytes);
+ final byte[] result = new byte[intNumInputBytes];
Review comment:
`numInputBytes` has changed to long. you mean `(numInputs - 1) *
separator.numBytes` can overflow ? yeah, maybe it can be. How about this ?
```
int intNumInputBytes = Math.toIntExact(
numInputBytes + (numInputs - 1) * (long)separator.numBytes);
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]