Skip to content

Commit 2136f45

Browse files
committed
Enh 36420687 - [36420651->24.09] Improve deserialization performance of very large byte arrays
[git-p4: depot-paths = "//dev/coherence-ce/main/": change = 107697]
1 parent dc42bee commit 2136f45

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

prj/coherence-core/src/main/java/com/tangosol/util/ExternalizableHelper.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
package com.tangosol.util;
99

1010
import com.oracle.coherence.common.base.Logger;
11+
import com.oracle.coherence.common.io.BufferManagers;
1112

1213
import com.tangosol.coherence.config.Config;
1314

15+
import com.tangosol.internal.io.BufferManagerWriteBufferPool;
1416
import com.tangosol.internal.util.invoke.Lambdas;
1517
import com.tangosol.internal.util.invoke.RemotableSupport;
1618

@@ -6625,20 +6627,21 @@ protected static char[] readLargeCharArray(Utf8Reader reader, int cLength)
66256627
protected static byte[] readLargeByteArray(DataInput in, int cb)
66266628
throws IOException
66276629
{
6628-
int cBatchMax = CHUNK_SIZE;
6629-
int cBatch = cb / cBatchMax + 1;
6630-
byte[] ab = new byte[cBatchMax];
6631-
byte[] aMerged = null;
6632-
int cbRead = 0;
6633-
for (int i = 0; i < cBatch && cbRead < cb; i++)
6630+
int cbBatchMax = CHUNK_SIZE;
6631+
int cBatch = cb / cbBatchMax + 1;
6632+
6633+
try (MultiBufferWriteBuffer buf = new MultiBufferWriteBuffer(new BufferManagerWriteBufferPool(BufferManagers.getHeapManager()), cbBatchMax))
66346634
{
6635-
in.readFully(ab);
6636-
aMerged = mergeByteArray(aMerged, ab);
6637-
cbRead += ab.length;
6638-
ab = new byte[Math.min(cb - cbRead, cBatchMax)];
6635+
InputStreaming input = new WrapperDataInputStream(in);
6636+
int cbRead = 0;
6637+
for (int i = 0; i < cBatch && cbRead < cb; i++)
6638+
{
6639+
int cbBatch = Math.min(cb - cbRead, cbBatchMax);
6640+
buf.write(cbRead, input, cbBatch);
6641+
cbRead += cbBatch;
6642+
}
6643+
return buf.toByteArray();
66396644
}
6640-
6641-
return aMerged;
66426645
}
66436646

66446647
/**

0 commit comments

Comments
 (0)