tisonkun opened a new pull request, #354: URL: https://github.com/apache/datasketches-rust/pull/354
## Summary Unify in-memory item counts and capacities in `ReqSketch` and `Compactor` on `usize`, while keeping explicit `try_from` checks at the 32-bit wire format boundary and fixing two REQ compaction/deserialization invariants. ## Changes - Change `ReqSketch::num_retained` (public return type and field), `ReqSketch::max_nom_size`, `Compactor::section_size`, `Compactor::num_items`, `Compactor::nominal_capacity`, and `nearest_even_section_size` from `u32` to `usize`, matching `KllSketch`, `ThetaSketch`, and `TupleSketch`. - Keep the REQ compactor wire format's 32-bit `num_items` field unchanged and convert explicitly via `u32::try_from` in `Compactor::serialize_into` and `usize::try_from` in `Compactor::deserialize`. - Fix `ReqSketch::compress` to re-evaluate `self.compactors.len()` on each iteration (`while h < self.compactors.len()`), matching `datasketches-cpp` and `datasketches-java`, so merging a larger-`k` sketch into a smaller-`k` sketch cascades compaction across newly grown upper levels instead of stopping at the initial level count. - Bound `section_size_raw` within `0.0..=f32::from(k) + 2.0` before calling `nearest_even_section_size` in `validate_compactor_state`, preventing debug shift-overflow panics and release-mode wraparound bypasses on malformed compactor headers. - Add regression tests for cascading compaction on cross-`k` merges and malformed `section_size_raw` deserialization inputs. ## Validation - `cargo x check` - `cargo x test` (including `cargo test --release --test req_test --test serde_tests`) - `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]
