[WIP] Add Xor Filter to the filters package#740
Draft
freakyzoidberg wants to merge 2 commits into
Draft
Conversation
Hoist the construction-failure throw out of the peeling loop so the loop can terminate through its own bound. Previously the last iteration always exited via break or throw, making the 'attempt < MAX_ITERATIONS' condition provably always-true (CodeQL java/constant-comparison). Behavior is unchanged; the success check now runs after the loop. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an immutable Xor Filter for probabilistic set membership to a new
org.apache.datasketches.filters.xorfilterpackage, as a smaller/faster alternative to the existing Bloom filter. The API, naming, Javadoc, exception handling, serialization layout, andMemorySegmentsupport mirrorBloomFilter.Implements the algorithm from Graf & Lemire, "Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters," ACM JEA 2020, with 8-bit and 16-bit fingerprints.
What's included
XorFilter— immutable filter: peeling construction, 3-hash membership query, the full typedquery(...)suite (long/double/String/byte[]/char[]/short[]/int[]/long[]/MemorySegment),heapify/wrap,toByteArray/toLongArray, and a BloomFilter-styletoString.XorFilterBuilder— accumulates items via a matching typedupdate(...)suite, de-duplicates, and builds; plus staticcreate(long[]...)factories.package-info.java,XorFilterTest(24 tests), and a standaloneXorFilterBenchmark.Family: newXORFILTER(22, "XORFILTER", 3, 3)entry.Design notes
floor(1.23*n) + 32, rounded down to a multiple of 3.XorFilter.Testing
Familytests pass on JDK 25 (no false negatives; typed items; duplicates; empty; determinism; heapify/wrap/toLongArray round-trips for 8- and 16-bit; corruption guards).apache-ratlicense check passes (0 unapproved).Follow-ups (not in this PR)
BloomFilterCrossLanguageTest.