faruken / rust-bloom

Bloom filter in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

rust-bloom

rust-bloom is a bloom filter implementation in rust that uses farmhash.

Example Usage

extern crate bloom;

use bloom::BloomFilter;

fn main() {
    let mut bf = BloomFilter::new(10_000, 0.02);
    bf.insert(&"hello");
    bf.insert(&"abcd");

    match bf.has(&"hello") {
        true => println!("exists"),
        _ => println!("not exists"),
    }
}

Use Cases

  • If you're writing a spider, you can do "have I discovered this URL" efficiently.
  • It's also how "this username is already taken" works on high traffic websites.

Note that there can be false positives.

About

Bloom filter in Rust

License:MIT License


Languages

Language:Rust 100.0%