You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also the Java impl always assumes there is no buffer serialized. This can lead to serde incompatible for any C++ TDigest has buffered data serialized with with_buffer, like:
Apparently, at some point we implemented serializing the buffer in C++, but did not do that in Java.
The default is to compress first, which is an undesirable side effect of serialization, so that we don't have to serialize the buffer (which takes more space). I don't remember why did we decide to provide this option to avoid compression and serializing the buffer.
@AlexanderSaydakov,
As @tisonkun points out, this leads to an immediate incompatibility between C++ and Java serialized TDigest sketches.
How do you suggest we fix this?
Can we agree that the path for Rust is to compress before serializing, which means follow the Java version for this behavior.
This is correct.
If so, can we close?
The issue here is that C++ can serialize a TDigest sketch with_buffer. So Java's deserialization (heapify) should not assume no buffer in the bytes, which causes the incompatibility. I can submit a patch to demonstrate it and fix it.
There are even prepared test data where we test only those that compress before serializing, not the tdigest_double_buf_n{scale}_cpp.sk ones.
Activity
leerho commentedon Dec 17, 2025
Thank you for pointing this out. We are looking into it.
AlexanderSaydakov commentedon Dec 17, 2025
Apparently, at some point we implemented serializing the buffer in C++, but did not do that in Java.
The default is to compress first, which is an undesirable side effect of serialization, so that we don't have to serialize the buffer (which takes more space). I don't remember why did we decide to provide this option to avoid compression and serializing the buffer.
leerho commentedon Dec 17, 2025
@AlexanderSaydakov,
As @tisonkun points out, this leads to an immediate incompatibility between C++ and Java serialized TDigest sketches.
How do you suggest we fix this?
AlexanderSaydakov commentedon Dec 17, 2025
In the default mode they must be compatible.
I suggest fixing this by implementing the same approach in Java.
tisonkun commentedon Dec 17, 2025
Maybe keep it compatible only with the deserializing part? (As I did in apache/datasketches-rust#23).
Yes, IMO always compress before serializing in this case helps.
leerho commentedon Dec 19, 2025
Can we agree that the path for Rust is to compress before serializing, which means follow the Java version for this behavior.
If so, can we close?
tisonkun commentedon Dec 19, 2025
This is correct.
The issue here is that C++ can serialize a TDigest sketch
with_buffer. So Java's deserialization (heapify) should not assume no buffer in the bytes, which causes the incompatibility. I can submit a patch to demonstrate it and fix it.There are even prepared test data where we test only those that compress before serializing, not the
tdigest_double_buf_n{scale}_cpp.skones.datasketches-java/src/test/java/org/apache/datasketches/tdigest/TDigestCrossLanguageTest.java
Lines 37 to 79 in 37edd8c
tisonkun commentedon Dec 19, 2025
Here is the patch: #704