Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address
  • Loading branch information
ulysses-you committed Apr 13, 2021
commit d54262706600e40e94a80e7ace1ad47ab2a353ce
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.esotericsoftware.kryo.KryoSerializable;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.google.common.primitives.Ints;

import org.apache.spark.unsafe.Platform;
import org.apache.spark.unsafe.UTF8StringBuilder;
Expand Down Expand Up @@ -764,7 +763,8 @@ public UTF8String repeat(int times) {
return EMPTY_UTF8;
}

byte[] newBytes = new byte[numBytes * times];
int resultSize = Math.toIntExact((long)numBytes * times);
byte[] newBytes = new byte[resultSize];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int resultSize = Math.toIntExact((long)numBytes * times);
byte[] newBytes = new byte[resultSize];
byte[] newBytes = new byte[Math.multiplyExact(numBytes, times)];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the carefully review !

copyMemory(this.base, this.offset, newBytes, BYTE_ARRAY_OFFSET, numBytes);

int copied = 1;
Expand Down Expand Up @@ -973,7 +973,7 @@ public static UTF8String concat(UTF8String... inputs) {
}

// Allocate a new byte array, and copy the inputs one by one into it.
final byte[] result = new byte[Ints.checkedCast(totalLength)];
final byte[] result = new byte[Math.toIntExact(totalLength)];
int offset = 0;
for (int i = 0; i < inputs.length; i++) {
int len = inputs[i].numBytes;
Expand Down