Code Monkey home page Code Monkey logo

growable-bloom-filters's Introduction

img

Growable Bloom Filters

CRATES.IO | DOCUMENTATION

Overview

Implementation of Scalable Bloom Filters which also provides serde serialization and deserialize.

A bloom filter lets you insert items, and then test association with contains. It's space and time efficient, at the cost of false positives. In particular, if contains returns true, it may be in filter. But if contains returns false, it's definitely not in the bloom filter.

You can control the failure rate by setting desired_error_prob and est_insertions appropriately.

use growable_bloom_filter::GrowableBloom;

// Create and insert into the bloom filter
let mut gbloom = GrowableBloom::new(0.05, 1000);
gbloom.insert(&0);
assert!(gbloom.contains(&0));

// Serialize and Deserialize the bloom filter
use serde_json;

let s = serde_json::to_string(&gbloom).unwrap();
let des_gbloom: GrowableBloom = serde_json::from_str(&s).unwrap();
assert!(des_gbloom.contains(&0));

// Builder API
use growable_bloom_filter::GrowableBloomBuilder;
let mut gbloom = GrowableBloomBuilder::new()
    .estimated_insertions(100)
    .desired_error_ratio(0.05)
    .build();
gbloom.insert(&0);
assert!(gbloom.contains(&0));

Applications

Bloom filters are typically used as a pre-cache to avoid expensive operations. For example, if you need to ask ten thousand servers if they have data XYZ, you could use GrowableBloom to figure out which ones do NOT have XYZ.

Stability

The (de)serialized bloom filter can be transferred and used across different platforms, independent of endianness, architecture or word size.

Note that stability is only guaranteed within the same major version of the crate.

Upgrading from 1.x to 2.x

  • Any 1.x serialized bloom filters will no longer be loadable in 2.x.
  • Minor API changes otherwise.

growable-bloom-filters's People

Contributors

arthurprs avatar cjrh avatar dpbriggs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

growable-bloom-filters's Issues

Build fails on stable

Hello,
Thanks for your work on this crate! Could you please make it compatible with rust stable ?

save and load

how to save the created filter to a file for reuse?
and how to download it later?

Tunable growth factor and tightening ratio

The comments above the code here seem to imply they were meant as defaults, but there's no way to provide them for custom values. Was this just something that fell behind, or was it intentionally left out? If the latter, would a contribution be accepted?

I'm trying to migrate to this library, but the library I'm using had hardcoded values of 2 and 0.5, whereas this library is hardcoded to 2 and 0.85. I'd like to move over as this implementation is faster, but not being able to tune the values to match means I have to bump major (as the results are obviously changing).

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.