tisonkun opened a new pull request, #376: URL: https://github.com/apache/datasketches-rust/pull/376
Closes #367 ## Summary Unifies mutation error and overflow contracts across weighted updates, cross-sketch merges, and decay operations so caller-supplied runtime errors and arithmetic overflows return structured `Result<(), Error>` (`InvalidArgument`) before modifying `self`, while streaming unit-weight `update` and `FromIterator` remain infallible with `# Panics` contracts. ## Changes - **`FrequentItemsSketch`**: Return `Result<(), Error>` from `update_with_weight`, `update_with_weight_ref`, and `merge`, validating total stream weight and maximum error offset upfront so overflows return `InvalidArgument` without mutating `self`; retain unit-weight `update` and `update_ref` with documented overflow panics; harden deserialization (`deserialize_inner`) to reject zero active item weights and `sum(active_weights) + offset > stream_weight` with `InvalidData`. - **`TDigestMut`**: Return `Result<(), Error>` from `merge` on combined `u64` total weight overflow before updating extrema or internal buffers; retain `FromIterator<TDigestMut>` with its documented overflow panic contract. - **`CountMinSketch`**: Return `Result<(), Error>` from `update_with_weight` (validating `checked_abs` and total absolute weight overflow upfront) and `decay` (rejecting factors outside `(0.0, 1.0]` before scaling); retain `update` with documented overflow panics and keep `halve` infallible. - **Docs, benchmarks, and tests**: Document mutation and overflow rules in `CONTRIBUTING.md` under `## Mutation and overflow semantics`, update `CHANGELOG.md` under `## Unreleased`, update doctests and benchmarks for `Result` returns, and add regression coverage for error variants and unchanged sketch state on failure. ## Verification - `cargo x lint` - `cargo x check` - `cargo x test` - `cargo x bench -- --test` - `cargo +1.86.0 check --workspace --all-targets` -- 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]
