chaokunyang commented on code in PR #1582:
URL: https://github.com/apache/incubator-fury/pull/1582#discussion_r1581725946
##########
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##########
@@ -1204,18 +1204,27 @@ public void writePrimitiveArray(Object arr, int offset,
int numBytes) {
/** For off-heap buffer, this will make a heap buffer internally. */
public void grow(int neededSize) {
- ensure(writerIndex + neededSize);
+ int length = writerIndex + neededSize;
+ if (length > size) {
+ growBuffer(length);
+ }
}
/** For off-heap buffer, this will make a heap buffer internally. */
public void ensure(int length) {
if (length > size) {
- byte[] data = new byte[length * 2];
- copyToUnsafe(0, data, Platform.BYTE_ARRAY_OFFSET, size());
- initHeapBuffer(data, 0, data.length);
+ growBuffer(length);
}
}
+ private void growBuffer(int length) {
+ int newSize =
+ length < 104857600 ? length << 2 : (int) Math.min(length * 1.5d,
Integer.MAX_VALUE);
Review Comment:
It' just 100 * 1024 * 1024
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]