GitHub user leerho added a comment to the discussion: Cross-language hashing:
inconsistent empty-byte and signed-zero handling
Thank you, Tison, this is an excellent and thoughtful summary of a very
important issue!
There are a number of compatibility cases that need to be handled explicitly:
**Hashing Floating Point:**
- canonicalize +/- 0.0 (as you mentioned)
- canonicalize NaNs (Java has a built in canonicalized NaN, but you have to
specify it, I'm not sure if other languages have this)
**Handling NULL and empty objects**
These cases may just mean better documentation, but needs some thought.
- Standardize on how to interpret NULL as well as guidelines on situations
where it is OK emit a NULL.
- Standardize oh how to interpret empty Objects (arrays), as well guidelines on
situations where it is OK emit an empty Object (as you mentioned).
**String encoding**
In Java, anyway, we assume UTF-8 everywhere, with one historical exception.
**Possible next steps:**
1. I agree and wish to add the above cases as well.
2. I agree, but will require careful orchestration. Existing code attempting to
test newer images will always fail. And since the various languages will create
their fixes asynchronously, the CL tests will have to pay attention to the
SerVer bytes and code versions and existing CL tests will need to be updated.
3. I would like to put a nuance on this, specifically WRT the hashing
assumptions. I certainly agree that we have a plan before we start changing
any code. But these incompatibilities impact historically serialized images.
The way we have handled incompatible serialization formats in the past was to
change the Serialization Version (SerVer) byte in the preamble. The
deserialization code then needs to be updated to be able to properly read the
older SerVer as well as the latest one.
However, in the past the changes we faced were simple, like the offset of the
Flags byte. We have not had to deal with this situation of incompatible hash
assumptions. I'm not sure there is a graceful way forward. Certainly we
should change the SerVer, for detection purposes, but then what, throw an
exception telling the user to revert to an earlier code version? I don't know
the answer.
**Questions:**
- As far as I am aware, these inconsistencies are an oversight and certainly
not intentional.
- I'm not familiar with what you mean by "empty byte sequences" do you mean
byte[] = {0,0,0...} or byte[0]?
Bloom and XOR should definitely canonicalize signed zero and NaNs like HLL,
CPC, Theta, and Tuple.
- We need one policy, which could be kept in TCK as well as copied to our
Website.
- Yes, I certainly hope we can capture our policy here first.
GitHub link:
https://github.com/apache/datasketches-tck/discussions/20#discussioncomment-19530843
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]