jaideeppyne opened a new pull request, #768: URL: https://github.com/apache/datasketches-java/pull/768
Fixes #766. ## Summary `BloomFilter.invert()` flips the backing bit array but has no sound set-membership interpretation (see the issue). The only boolean composition involving inversion with a clean per-item meaning is **A AND NOT B**. This PR: 1. **Deprecates** `BloomFilter.invert()` with a pointer to the replacement. 2. **Adds** `BloomFilter.difference(BloomFilter other)` — bitwise AND-NOT (`this &= ~other`) with documented exact-exclusion / possible left-item-drop semantics. 3. Adds package-private `BitArray.andNot` (Heap + Direct implementations; read-only throws), matching `BitSet.andNot`. Aligns with the already-merged Rust change: [apache/datasketches-rust#278](https://github.com/apache/datasketches-rust/pull/278). Wire format unchanged. ## `difference` semantics - Items inserted into `other` always query `false`: excluded exactly. - Items inserted only into this filter are kept unless a hash position collides with `other` (unlike `union` / `intersect`, items can drop). - False positives for never-inserted items stay bounded by this filter's prior FPP. - `null` other is a no-op; incompatible filters throw (same as union/intersect). ## Tests - `BloomFilterTest`: basic difference, self-difference clears, empty right is identity, incompatible `difference`; tightened deprecated `inversionTest` (inserted items are always absent after invert). - `HeapBitArrayTest` / `DirectBitArrayTest`: `andNot` happy path + length mismatch. - `DirectBitArrayRTest`: read-only `andNot` throws. ## AI disclosure I used Cursor / Grok to help draft the patch and open this PR via the GitHub API (no local clone). Semantics follow #766 and the merged Rust `difference` API. -- 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]
