Crate qfilter

Source
Expand description

Approximate Membership Query Filter (AMQ-Filter) based on the Rank Select Quotient Filter (RSQF).

This is a small and flexible general-purpose AMQ-Filter, it not only supports approximate membership testing like a bloom filter but also deletions, merging, resizing and serde serialization.

§Example

let mut f = qfilter::Filter::new(1000000, 0.01).unwrap();
for i in 0..1000 {
    f.insert(i).unwrap();
}
for i in 0..1000 {
    assert!(f.contains(i));
}

§Hasher

The hashing algorithm used is xxhash3 which offers both high performance and stability across platforms.

§Filter size

For a given capacity and error probability the RSQF may require significantly less space than the equivalent bloom filter or other AMQ-Filters.

Bits per itemError probability when fullBits per item (cont.)Error (cont.)
3.1250.36219.1256.87e-06
4.1250.20120.1253.43e-06
5.1250.10621.1251.72e-06
6.1250.054722.1258.58e-07
7.1250.027723.1254.29e-07
8.1250.01424.1252.15e-07
9.1250.0070125.1251.07e-07
10.1250.0035126.1255.36e-08
11.1250.0017627.1252.68e-08
12.1250.00087928.1251.34e-08
13.1250.00043929.1256.71e-09
14.1250.0002230.1253.35e-09
15.1250.0001131.1251.68e-09
16.1255.49e-0532.1258.38e-10
17.1252.75e-05....
18.1251.37e-05....

§Legacy x86_64 CPUs support

The implementation assumes the popcnt instruction (equivalent to integer.count_ones()) is present when compiling for x86_64 targets. This is theoretically not guaranteed as the instruction in only available on AMD/Intel CPUs released after 2007/2008. If that’s not the case the Filter constructor will panic.

Support for such legacy x86_64 CPUs can be optionally enabled with the legacy_x86_64_support which incurs a ~10% performance penalty.

Structs§

Filter
Approximate Membership Query Filter (AMQ-Filter) based on the Rank Select Quotient Filter (RSQF).
FingerprintIter
An iterator over the fingerprints of a Filter.

Enums§

Error