tisonkun opened a new pull request, #238: URL: https://github.com/apache/datasketches-rust/pull/238
## Summary Use one naming rule for construction APIs: if caller-supplied configuration can fail, the ordinary method returns `Result`; infallible entry points continue to return the value directly. This removes the parallel `new`/`try_new` vocabulary and lets callers propagate construction failures without guessing which spelling is fallible. ## Resulting API shape | Family / public type | Canonical entry point | Failure boundary | Notes | | --- | --- | --- | --- | | `BloomFilter` | `BloomFilterBuilder::with_accuracy(...)` or `with_size(...)` | `build() -> Result<_, Error>` | Builder acquisition and setters remain infallible; validation stays deferred to `build`. | | `CountMinSketch` | `new(...)` or `with_seed(...)` | Both return `Result` | `suggest_num_buckets` and `suggest_num_hashes` also return `Result`. | | `CpcSketch` / `CpcUnion` | `new(...)` or `with_seed(...)` | All return `Result` | `CpcWrapper::new(bytes)` was already fallible and remains unchanged. | | `FrequentItemsSketch` | `new(max_map_size)` | Returns `Result` | Invalid or oversized map sizes no longer panic. | | `HllSketch` / `HllUnion` | `new(...)` | Returns `Result` | Invalid `lg_k` values no longer panic. | | `ReqSketch` / `ReqUnion` | `new(...)` | Returns `Result` | Removes `try_new`; `Default` remains infallible. | | `TDigestMut` | `new(k)` | Returns `Result` | Removes `try_new`; immutable `TDigest` is still obtained via `freeze`. | | `ThetaSketch` / `ThetaUnion` | `ThetaSketchBuilder::new()` / `ThetaUnionBuilder::new()` | `build() -> Result<_, Error>` | No `Sketch::builder()` shortcut; `Default` remains an alias for the no-argument builder constructor. | | Theta set operators | `Default::default()` for the default seed, `with_seed(...)` otherwise | `with_seed` returns `Result` | Applies to intersection, A-not-B, and Jaccard similarity. | | `TupleSketch` / `TupleUnion` | `Builder::new(policy)` | `build() -> Result<_, Error>` | Policy acquisition is infallible; all configuration validation remains at `build`. | | Tuple set operators | `new(policy)` / `Default` for the default seed, `with_seed(...)` otherwise | Custom-seed construction returns `Result` | Applies to intersection, A-not-B, and Jaccard similarity. | ## Seed errors The internal seed-hash helper now takes the error kind from its caller: - construction and builder validation report a reserved zero seed hash as `InvalidArgument`; - deserialization reports the same condition as `InvalidData`, matching other serialized seed-compatibility failures; - known-valid defaults and reconstruction from already validated state remain infallible internal invariants. This keeps `with_seed(...) -> Result` as the only custom-seed spelling and avoids a growing family of `try_with_*` names as more parameters are added. ## Validation - `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]
