leerho opened a new pull request, #798:
URL: https://github.com/apache/datasketches-java/pull/798

   This implements the cross-language Count-Min serialization format, version 
2, specified in apache/datasketches-tck#21 (`docs/count-min-format.md`) and 
agreed in apache/datasketches-tck#18.
   
   **Please don't merge this until apache/datasketches-tck#21 has merged**, 
because the class javadoc links to the spec there. It's open now so the other 
implementations can compare against it.
   
   ### Version 2
   - **Row seeds:** `rowSeed[i] = XXH64(LE64(i), seed)`.
   - **Item hashing:** items are hashed with XxHash64.
     - 64-bit integers are hashed as 8 little-endian bytes, strings as UTF-8, 
and byte arrays as given.
   - **Bucket:** `(hash >>> 1) % numBuckets`.
   - **Serial version:** byte 2. The byte layout is unchanged.
   - **Version 1 images:** they still load. Such a sketch keeps the version 1 
hashing (seeds from `Random`, MurmurHash3, `floorMod`) and is written back as 
version 1.
   - **Merging:** version 1 with version 2 throws.
   - **Other serial versions:** rejected.
   - **Null items:** a `null` byte array is ignored like an empty one, as the 
spec requires. Before, it threw a `NullPointerException`.
   
   ### Public constructors
   Until now, `CountMinSketch` had no public way to create a sketch; only 
`deserialize` was public. This adds:
   - `CountMinSketch(byte numHashes, int numBuckets)`, with the default seed 
9001;
   - `CountMinSketch(byte numHashes, int numBuckets, long seed)`.
   
   Both take the values returned by `suggestNumHashes` and `suggestNumBuckets` 
directly.
   
   ### Tests
   - **`CountMinSketchTest`** checks every test vector in section 7 of the spec:
     - XXH64 values and row seeds;
     - item-to-bucket mappings, including a non-ASCII string and hashes with 
the top bit set;
     - both images, byte for byte.
   
     It also checks:
     - that the long overloads hash the item's little-endian bytes;
     - version 1 behavior, against a separate implementation of the legacy 
hashing;
     - merging across versions, unknown versions, null and empty items, and the 
public constructors.
   - **`CountMinSketchCrossLanguageTest`** generates and checks the version 2 
CL files from section 8 of the spec:
     - names are `count_min_v2_<case>_<language>.sk`;
     - the checker covers Java, C++, Go and Rust files;
     - a file from another language must also be byte-identical to Java's;
     - the existing C++ version 1 files are checked to load as version 1 
sketches.
   
   The full suite passes (2,393 tests).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to