Repository navigation
refactor: simplify xor construction and local naming - #326
Merged
Merged
Conversation
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.
Simplify the unreleased XOR API to
XorFilter::from_values,XorFilter::from_hashes, andXorFilter::from_parts.from_valueshashes and deduplicates ordinary values;from_hashesaccepts distinct hashes as&[u64]and returns an error for duplicates. Fingerprint width and construction seed are explicit arguments.Keep serialization beside the filter implementation so fields and serialization helpers remain private. Remove the builder, raw-parts wrapper, and ownership-transfer method; application-defined codecs import raw fields and encode through borrowed accessors. Use concise local names where the surrounding operation already supplies the context.
Update documentation and existing coverage for value deduplication, invalid hash inputs, bounded retries, Java serialization, and xorf interoperability. Repeated-hash benchmarks now include explicit caller-side deduplication for both implementations.
Validation:
cargo x check,cargo x test(814 tests including doctests),cargo x lint, and the optimized XOR benchmark smoke suite with ThinLTO.Batch construction at
e3b508e, Apple M4 Max / macOS ARM64,nightly-2026-08-28, ThinLTO, three repetitions. Each round builds 32 independent Xor8 filters from identical distinct inputs with initial seed 1. Times include setup and cleanup, reported as median [min–max] milliseconds:Command:
CARGO_PROFILE_BENCH_LTO=thin cargo +nightly-2026-08-28 bench -p benchmarks --bench benchmarks -- xor::build_batches --repeat 3 --raw. These compare the current implementations; the API simplification does not change the construction algorithm.