tisonkun commented on PR #370: URL: https://github.com/apache/datasketches-rust/pull/370#issuecomment-6894144925
Removed `PartialEq` and `Eq` from all sketches and membership filters in commit `9d93997` (`refactor!: remove PartialEq and Eq from sketches and filters`), completing the equality audit across the crate. ### What Changed * **Removed `PartialEq` / `Eq` from filters and sketches**: Dropped `PartialEq` + `Eq` from `BloomFilter` and `XorFilter` (and private `BitArray` / `Fingerprints`), and dropped `PartialEq` from `CountMinSketch`, `HllSketch`, `KllSketch`, and their internal-only representation helpers (`BucketCount`, `Mode`, `List`, `HashSet`, `Container`, `Array4`, `Array6`, `Array8`, `Estimation`, `AuxMap`, `EstimateState`, `Estimator`). * **Kept `PartialEq` / `Eq` where equality is well-defined**: Retained `PartialEq + Eq` on configuration and error enums (`ErrorKind`, `ResizeFactor`, `NumStdDev`, `SearchCriteria`, `ErrorType`, `RankAccuracy`, `XorFilterType`, `HllType`), `frequencies::Row`, input adapter wrappers (`KllFloat`, `ReqFloat`, `hash::value::Value`), and internal tag/value types (`cpc::Flavor`, `IntersectionResultState`, `countmin::SerialVersion`, `hll::Coupon`), plus `PartialEq` on float-bearing value structs (`common::JaccardSimilarity` and `tdigest::Centroid`). * **Updated tests, examples, and changelog**: Updated doctests, `bloom_difference` example, unit tests, and integration/serde tests to assert on `serialize()`, canonicalized HLL images (clearing `lg_arr` and sorting open-addressing `Set`/`Hll4` coupon arrays), and observable metadata/queries; recorded the breaking `PartialEq` removals in `CHANGELOG.md`. ### Rationale & Ecosystem Survey Probabilistic sketches reflect stream history, compaction cadence, randomized sampling (`KllSketch`), HIP vs. composite estimation state and hash-table probe order (`HllSketch`), or unserialized runtime seeds (`CountMinSketch`, which stores only a 16-bit `seed_hash` in binary images). Even on deterministic filters (`BloomFilter`, `XorFilter`), comparing two filters has no clear domain use case beyond byte-level snapshot checks already served directly by `serialize()`. This matches upstream Apache DataSketches and the majority of competing Rust crates: | Implementation | Scope checked | Equality support & semantics | | :--- | :--- | :--- | | Upstream `datasketches-java` (`v9.1.0`) | `BloomFilter`, `XorFilter`, `HllSketch`, `CountMinSketch`, `Kll*`, `Cpc*`, `Req*`, `Frequent*`, `Theta*`, `Tuple*`, `TDigest*` | None override `Object.equals` (reserved for `Row`/`Group`/summary records; probabilistic comparison is separate via `JaccardSimilarity`) | | Upstream `datasketches-cpp` (`v5.3.1`) & `datasketches-go` (`v0.3.0`) | All core sketches and `BloomFilter` | None define `operator==` or exported `Equal` comparators on sketches/filters | | Bloom filters (`bloomfilter` `3.0.2`, `sbbf-rs-safe` `0.3.2`, `bloom` `0.3.2`, `pdatastructs` `0.7.0`) | `Bloom`, `Filter`, `BloomFilter`, `CountingBloomFilter` | Omit `PartialEq` / `Eq` | | Bloom filters (`fastbloom` `0.17.0`, `probabilistic-collections` `0.7.0`) | `BloomFilter` | Derive/implement structural equality with caveats: `fastbloom` ignores `hasher` state completely (different seeds can compare `==`; default `RandomState` makes identical inserts compare `!=`), and `probabilistic-collections` couples an unintended `T: PartialEq` bound via `DoubleHasher` | | Xor / Binary Fuse (`xorf` `0.13.0`, `xorfilter-rs` `0.5.1`) | `Xor*`, `BinaryFuse*`, `Fuse*` | `xorf` omits `PartialEq` / `Eq` across all filters; `xorfilter-rs` implements `PartialEq` only on `Xor8` (ignoring `hash_builder`, used for serde tests) and omits it on `Fuse8`/`Fuse16` | | HLL & Count-Min (`hyperloglogplus` `0.4.1`, `pdatastructs` `0.7.0`, `amadeus-streaming` `0.4.3`, `probabilistic-collections` `0.7.0`) | `HyperLogLog*`, `CountMinSketch` | All omit `PartialEq` / `Eq` (`amadeus-streaming` explicitly separates estimate comparison into `HyperLogLogMagnitude`) | | Quantiles & t-digest (`quantiles` `0.7.1`, `tdigest` `1.0.1`) | `greenwald_khanna::Stream`, `ckms::CKMS`, `TDigest` | `greenwald_khanna::Stream` omits `PartialEq`; `ckms::CKMS` and `tdigest::TDigest` derive `PartialEq` over order-dependent internals and skipped/unflushed buffers (breaking round-trip equality) | Re-ran full validation on `9d93997`: `cargo x check`, `cargo x lint`, `cargo +1.86.0 check -p datasketches --all-features`, and `cargo x test` (`752 passed; 0 failed; 0 ignored`). -- 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]
