Compact static Binary Fuse filter for high-throughput 64-bit membership lookups.
SBX Binary Fuse16 is a project-owned static probabilistic membership filter for 64-bit keys. It is designed for workloads that build a set once and perform a large number of read-only lookups afterward.
The implementation uses 16-bit fingerprints and three positions per key. A
successful lookup means "possibly present"; a negative lookup is definitive.
The expected false-positive probability is approximately 1 / 65,536 under a
well-distributed 64-bit input hash.
- Each key is mixed with a deterministic construction seed.
- The resulting hash selects three vertices in a segmented 3-wise graph.
- Degree-one vertices are peeled into a stack.
- Fingerprints are assigned in reverse peel order.
- Lookup reads three 16-bit slots and XORs them with the key fingerprint.
The construction retries with another deterministic seed when the graph cannot be completely peeled. Duplicate input keys are detected through a fallback deduplication pass.
- 64-bit input keys.
- 16-bit fingerprints.
- Three table positions per lookup.
- Segmented Binary Fuse layout.
- Deterministic seed sequence and bounded construction retries.
- Inline lookup path in the public header.
- Small-set and duplicate-key handling.
- No external runtime dependencies.
makeThis builds:
libsbx-binary-fuse.a
Manual build:
g++ -O3 -std=c++11 -c binary_fuse.cpp -o binary_fuse.o
ar rcs libsbx-binary-fuse.a binary_fuse.oClean generated files:
make cleanint sbx_binary_fuse16_build(SbxBinaryFuse16 *filter,
uint64_t *keys,
uint32_t count);
int sbx_binary_fuse16_contains(const SbxBinaryFuse16 *filter,
uint64_t key);
uint64_t sbx_binary_fuse16_estimate_bytes(uint32_t count);
void sbx_binary_fuse16_free(SbxBinaryFuse16 *filter);sbx_binary_fuse16_build() returns 1 on success and 0 on allocation or
construction failure. The input array is mutable: a duplicate-key fallback may
sort and compact it during construction.
#include "binary_fuse.h"
#include <cstdint>
#include <cstdio>
int main() {
uint64_t keys[] = {
UINT64_C(0x0123456789abcdef),
UINT64_C(0xfedcba9876543210),
UINT64_C(0x1122334455667788)
};
SbxBinaryFuse16 filter = {};
if(!sbx_binary_fuse16_build(&filter, keys, 3)) {
return 1;
}
uint64_t query = UINT64_C(0x0123456789abcdef);
std::puts(sbx_binary_fuse16_contains(&filter, query)
? "possibly present"
: "not present");
sbx_binary_fuse16_free(&filter);
return 0;
}Build the example:
g++ -O3 -std=c++11 example.cpp binary_fuse.cpp -o exampleThe finalized filter stores one contiguous uint16_t fingerprint array plus a
small metadata structure. Use the estimator before construction:
uint64_t bytes = sbx_binary_fuse16_estimate_bytes(key_count);The estimate covers the finalized fingerprint array. Construction also uses
temporary degree, XOR, queue, and peel-stack buffers, which are released before
sbx_binary_fuse16_build() returns.
After a successful build, concurrent contains() calls are safe as long as the
filter remains read-only. Building or freeing the same filter concurrently is
not supported.
- Static filter: insertions and deletions require rebuilding.
- Probabilistic membership: false positives are possible.
- Input count is represented by
uint32_t. - The filter owns its fingerprint allocation and must be released with
sbx_binary_fuse16_free(). - Copying a built
SbxBinaryFuse16by value does not duplicate its allocation.
The design follows the Binary Fuse construction described by Thomas Mueller Graf and Daniel Lemire in Binary Fuse Filters: Fast and Smaller Than Xor Filters. This repository contains its own MIT implementation and does not vendor the authors' reference source code.
If SBX Binary Fuse16 is useful to your work, you can support the project here:
Bitcoin (BTC): 1ECDSA1b4d5TcZHtqNpcxmY8pBH1GgHntN
USDT (TRC20): TUF4vPdB6QkjCvZq18rBL4Qj4dK5ihCN75
MIT License. See LICENSE.