Giter Club home page Giter Club logo

qfilter's Introduction

Qfilter

Efficient bloom filter like datastructure, 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 (not implemented), resizing and serde serialization.

  • High performance
  • Supports removals
  • Extremely compact, more so than comparable filters
  • Can be created with a initial small capacity and grow as needed
  • (De)Serializable with serde
  • Portable Rust implementation

Example

let mut f = qfilter::Filter::new(1000000, 0.01);
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 item Error probability when full
3.125 0.362
4.125 0.201
5.125 0.106
6.125 0.0547
7.125 0.0277
8.125 0.014
9.125 0.00701
10.125 0.00351
11.125 0.00176
12.125 0.000879
13.125 0.000439
14.125 0.00022
15.125 0.00011
16.125 5.49e-05
17.125 2.75e-05
18.125 1.37e-05
19.125 6.87e-06
20.125 3.43e-06
21.125 1.72e-06
22.125 8.58e-07
23.125 4.29e-07
24.125 2.15e-07
25.125 1.07e-07
26.125 5.36e-08
27.125 2.68e-08
28.125 1.34e-08
29.125 6.71e-09
30.125 3.35e-09
31.125 1.68e-09
32.125 8.38e-10

Not implemented

  • Merging
  • Shrink to fit
  • Counting
  • Smoother resizing by chaining exponentially larger and more precise filters

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 is 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.

License

This project is licensed under the MIT license.

qfilter's People

Contributors

arthurprs avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

qfilter's Issues

`new_resizeable(...)` constructor panics if `max_capacity` arg is too big

I haven't looked closely at the math yet, but if the max_capacity arg is too big. Passing u64::MAX, for example, is an easy way to reproduce, but a panic also occurs for many values lower than u64::MAX. I'm running a test to empirically figure out exactly where the limit is on my computer. I'll update this issue when I have the results, but I wanted to get this issue created for tracking purposes.

Add fallible constructors

Add fallible constructors (e.g. try_new) to avoid panicking in the constructor. That'll require another Error enum or augmenting the existing one (which is a breaking change).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.