How jonmat/fastindex works
Project Type and Purpose
• This is a C# class library solution (“FastIndex”) that implements an XOR‐filter based index (a perfect-hash–like structure) plus two auxiliary projects:
– A console application for performance benchmarking (BenchMark)
– A unit‐test suite demonstrating usage and validating correctness (FastIndex.Tests)
Main Components
1. Core Library (FastIndex)
• FastFilter module: builds the three‐segment XOR filter from 64-bit hashes
• Index generator: computes and stores the primary‐segment index in a lookaside byte array
• Public API: BuildFilter(), GetIndex(), Contains()
2. Test Harness (FastIndex.Tests)
• TestData & XXHash utility: generates fake phone‐number inputs and computes their hashes
• FastIndexTestHelper: example wiring of filter construction → index lookup → array population → collision validation
3. Benchmark App (BenchMark)
• Program.cs: console entry point, invokes BenchmarkDotNet jobs to measure Construct_FastFilter, Contains, Index lookups
• Dependency on BenchmarkDotNet library and on the FastIndex core library
Component Relationships and Data Flows
• Both BenchMark and FastIndex.Tests projects reference and invoke the core FastIndex library API.
• Client data flow:
[Raw Items (e.g. phone numbers)]
→ (XXHash) → [64-bit Hash Keys]
→ (FastFilter.Build) → [3× segment fingerprint arrays] + [lookaside byte array]
→ (optional serialize/persist) → [Stored Filter]
→ (Filter Load) → (GetIndex or Contains) → [Index or Boolean]
• Unit tests validate the flow end-to-end and measure false positives.
• Benchmark app measures timings of Build, Contains, Index operations.
Key Architectural Patterns & Principles
• Layered separation:
– Hash generation layer (XXHash)
– Core algorithm layer (XOR filter & index generation)
– Consumer layers (unit tests, benchmarks)
• Single responsibility: each project has a clear role (library vs. test vs. benchmark)
• Probabilistic data‐structure pattern: XOR filter internals with three fixed arrays and bit‐multiplexed lookaside storage
Technologies & Frameworks
• C#/.NET 6.0+ class library projects (.csproj)
• BenchmarkDotNet (for BenchMark)
• xUnit or NUnit (depending on FastIndex.Tests csproj)
• XXHash implementation in TestData
Essential Elements
– Brief notes on internal algorithm segments (3 arrays + lookaside byte array)