tisonkun opened a new pull request, #189:
URL: https://github.com/apache/datasketches-rust/pull/189

   ## Summary
   
   Fix legacy Theta serialization version 2 exact images being deserialized as 
logically empty when they contain retained entries.
   
   The v2 exact branch now derives logical emptiness from `num_entries == 0` 
instead of setting it unconditionally.
   
   Closes #186.
   
   ## Regression coverage
   
   The new serialization compatibility tests construct valid v2 exact images 
using the current Theta family ID and default seed hash, then verify:
   
   - a non-empty image retains all entries,
   - `is_empty()` is false,
   - exact estimate and bounds equal the retained count,
   - entry iteration is unchanged,
   - a current-format round trip preserves the state, and
   - a zero-entry v2 exact image remains empty.
   
   ## Relationship to other implementations
   
   This restores agreement with the current C++ and Go legacy readers. Both 
treat a v2 exact image (`preamble_longs == 2`) as empty only when `num_entries 
== 0`:
   
   - C++: 
https://github.com/apache/datasketches-cpp/blob/c22888581964fc490feee835766cc8c3adb722e0/theta/include/theta_sketch_impl.hpp#L605-L631
   - Go: 
https://github.com/apache/datasketches-go/blob/c558cc2d64f9a307c196a7adb0067eadd1b776f7/theta/decoder.go#L295-L343
   
   Go retains compatibility fixtures identified as Java-generated v2 images. 
Current Java reads compact versions 3 and 4 rather than v2 directly, so the 
active legacy-reader behavior is represented by C++ and Go:
   
   - Go Java-v2 fixture test: 
https://github.com/apache/datasketches-go/blob/c558cc2d64f9a307c196a7adb0067eadd1b776f7/theta/sketch_serialization_test.go#L210-L228
   - Current Java version dispatch: 
https://github.com/apache/datasketches-java/blob/4067ffefabbcd03944dc3617ff2948ab760f3b75/src/main/java/org/apache/datasketches/theta/CompactThetaSketch.java#L97-L115
   
   The fix changes no serialization bytes emitted by Rust; it only corrects the 
state reconstructed from legacy input.
   
   ## Validation
   
   - `cargo x prepare-testdata`
   - `cargo x check`
   - `cargo x test`
   - `cargo x lint`
   


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