M5.BitArraySerialization.ProtoBuf 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package M5.BitArraySerialization.ProtoBuf --version 2.0.0
                    
NuGet\Install-Package M5.BitArraySerialization.ProtoBuf -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="M5.BitArraySerialization.ProtoBuf" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="M5.BitArraySerialization.ProtoBuf" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="M5.BitArraySerialization.ProtoBuf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add M5.BitArraySerialization.ProtoBuf --version 2.0.0
                    
#r "nuget: M5.BitArraySerialization.ProtoBuf, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package M5.BitArraySerialization.ProtoBuf@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=M5.BitArraySerialization.ProtoBuf&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=M5.BitArraySerialization.ProtoBuf&version=2.0.0
                    
Install as a Cake Tool

M5.BloomFilter

A Bloom filter for .NET 10, maintained by MILL5 and Richard Crane, Microsoft MVP.

A lookup returns definitely absent or possibly present. Confirm positive results against the original data. Inserted keys remain present; false positives are allowed. There is no delete operation.

Website · Usage · Serialization and migration · Design and review

Get started

This repository targets .NET 10 and pins SDK 10.0.403 in global.json. The version 2.0.0 source introduces breaking changes; previously published 1.x packages use the older .NET 5 implementation. Check the NuGet package for publication status.

using M5.BloomFilter;

var filter = FilterBuilder.Build(expectedElements: 100_000, errorRate: 0.01);
filter.Add("customer:42");
bool maybe = filter.Contains("customer:42"); // true: possibly present

filter.Add(new[] { 12, 34, 56 });
bool all = filter.All(new[] { 12, 34, 56 });
var snapshot = filter.ToImmutable();

The default hash strategy is Murmur3KirschMitzenmacher; sixteen strategies are available through HashMethod. Strings use UTF-8; primitive numbers use little-endian bytes. Use the same value representation for insertion and lookup. Empty byte arrays are valid keys; null keys are rejected.

Guarantees and limits

  • Add only sets bits; repeating an insertion has no effect.
  • Built-in mutation, queries and snapshot exports synchronize access to bits. ToImmutable() returns a detached snapshot. HashBits returns a defensive copy.
  • Statistics.M, K, N, and P describe bits, hashes, expected elements and the ideal independent-hash false-positive estimate at that capacity. Actual rates depend on the hash strategy and input distribution; overfilling increases them. A requested error rate is not an adversarial-data guarantee.
  • Async methods wrap synchronous in-memory work in completed tasks.
  • Filters are not an exact set, authorization check, or replacement for stored keys.

Build and test

dotnet restore M5.BloomFilter.slnx
dotnet test M5.BloomFilter.slnx
dotnet build M5.BloomFilter.slnx -c Release
dotnet pack M5.BloomFilter.slnx -c Release --no-build

The SDK migration preserves all ten solution projects (including the shared project), both solution folders, and Debug/Release with Any CPU. The unused M5.BloomFilter.Serialization skeleton remains outside the solution as before. Regression tests cover all hash strategies, independent Murmur vectors, frozen format vectors, false-positive rates, concurrent writers, snapshots, collection encoding, populated persistence, and malformed bit streams.

Version 2 migration

Hash and numeric encoding corrections change bit positions. JSON/protobuf readers require format version 2 and reject older or unversioned filter payloads. Rebuild from original keys. Never relabel an old bitset as version 2. Upgrade all readers together and store old/new payloads separately during migration. Old binaries ignore new fields and cannot be trusted to read version 2 data.

Generic scalar extensions now accept object; generic IEnumerable<T> overloads handle batches. Replace explicit scalar calls such as Add<int>(42) with Add(42). See the migration guide for serializer examples.

Development workflow

The complete Google Elephant–Goldfish Model runtime is installed under .agents/, pinned in .agents/egm-source.json. Read AGENTS.md; draft in docs/designs/, review in a fresh Goldfish context, resolve material findings, implement, and run tests. The workflow skills are egm-brainstorm, egm-draft, egm-review, egm-resolve, egm-review-loop, egm-drift-report, and egm-bootstrap.

GitHub Actions tests the solution on Linux and Windows and deploys only docs/site to GitHub Pages. Design/review artifacts are excluded from the website deployment. Package release steps are in the release guide.

Apache-2.0 license.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on M5.BitArraySerialization.ProtoBuf:

Package Downloads
M5.BloomFilter.Serialization.ProtoBuf

Help serialize bloom filters using Google Protocol Buffers

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 53 11/3/2026
2.0.0 56 11/3/2026
1.0.8 951 3/16/2022
1.0.7 673 9/3/2021
1.0.6 675 9/3/2021
1.0.5 681 9/3/2021
1.0.4 631 9/2/2021
1.0.3 658 9/1/2021
1.0.2 657 9/1/2021

Version 2 requires .NET 10. Hashing and primitive encodings changed; rebuild persisted filters from original keys. Version 1 filter payloads are rejected. See README.md for migration.