GitHub user tisonkun added a comment to the discussion: Cross-language hashing: inconsistent empty-byte and signed-zero handling
Thanks @leerho! I agree with defining the shared hashed-input rules once in `docs/input-hashing.md` (disambiguated from encoding for codec) and having each family's format spec reference them. I suggest defining the target contract and compiling an inventory of current implementations at pinned revisions first, then working out legacy-image migration for each affected family. `docs/input-hashing.md` would cover: 1. **Supported inputs and byte encoding:** integer widening and byte order, UTF-8 strings without a length prefix or terminator, and raw byte sequences. Each family spec declares its supported types and defines its hash algorithm, seed derivation, and hash-to-state mapping. 2. **Floating-point normalization:** map `-0.0` and `+0.0` to `+0.0`, map all NaNs to one canonical bit pattern such as `0x7FF8000000000000`, and specify byte order and `float`/`f32` widening. 3. **Null and empty inputs:** I propose ignoring empty strings and zero-length byte sequences: updates are no-ops, membership and query-and-update calls return `false`, and Count-Min estimate and both bounds return `0`. APIs with nullable inputs such as `null`, `nil`, or `nullptr` would follow the same rule, without requiring non-nullable APIs to accept nulls. 4. **Conformance tests:** encoding and hash vectors, plus cross-language behavioral checks after deserialization. Empty-input cases should also run against non-empty sketches. Conformance should be based on an implementation's documented cross-language usage contract. For example, Rust's generic `Hash` API can document encoding wrappers and caller-side empty-input checks, while typed APIs in other languages perform those checks inside `update` and `query`. Both are fine if the contract is explicit and tested. The inventory should cover Java, C++, Go, Rust, and Python by family, overload, and operation. For each case, it should record both raw API behavior and any caller-side steps required by the contract. Once the target contract and implementation differences are clear, perhaps @leerho you could help assess the compatibility options for each affected family? That includes where a `SerVer` change makes sense, what guarantees we can provide for existing images, and whether some fixes should be explicitly breaking. If this sounds good, I can start drafting `docs/input-hashing.md` with open choices marked and build out the implementation inventory for review. GitHub link: https://github.com/apache/datasketches-tck/discussions/20#discussioncomment-19585778 ---- 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]
