anton-vinogradov commented on code in PR #13319:
URL: https://github.com/apache/ignite/pull/13319#discussion_r3579708778
##########
modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java:
##########
@@ -4064,33 +4066,20 @@ private <T> T unmarshalZip(byte[] zipBytes) throws
Exception {
/**
* @param obj Object.
- * @return Bytes.
+ * @return Zip-compressed marshalled bytes.
* @throws IgniteCheckedException If failed.
*/
byte[] marshalZip(Object obj) throws IgniteCheckedException {
assert obj != null;
- return zip(U.marshal(marsh, obj));
- }
-
- /**
- * @param bytes Bytes to compress.
- * @return Zip-compressed bytes.
- */
- private static byte[] zip(byte[] bytes) {
- Deflater deflater = new Deflater();
-
- deflater.setInput(bytes);
- deflater.finish();
+ GridByteArrayOutputStream out = new GridByteArrayOutputStream();
- GridByteArrayOutputStream out = new
GridByteArrayOutputStream(bytes.length);
-
- final byte[] buf = new byte[bytes.length];
-
- while (!deflater.finished()) {
- int cnt = deflater.deflate(buf);
-
- out.write(buf, 0, cnt);
+ // Buffer coalesces ~1KB ObjectOutputStream blocks into fewer JNI
deflate calls.
Review Comment:
The `~1 KB` referred to JdkMarshaller's ObjectOutputStream block-data
granularity (MAX_BLOCK_SIZE = 1024), not the BufferedOutputStream buffer — the
default 8 KB buffer is exactly what coalesces those ~1 KB blocks into fewer
Deflater JNI calls. Reworded the comment to make that explicit.
--
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]