Giter Club home page Giter Club logo

ploomy's Introduction

Ploomy

Ploomy implements a very simple python bloom filter.

What is a bloom filter?

A bloom filter is a fast and memory efficient way to check if an element has not been added to it (the reverse is not true). This makes it a good choice as a front to data store or when you need unique random data.

It works by hashing your input multiple times using a hashing algorithm that returns a number between 0 and n. These numbers represent indexes in a bit array. When an element is added to the filter, its hash indexes are set to 1. When you query for an element it is once again hashed and the bloom filter will return false iff any of the buckets are not 1.

More info ...

Usage

Any hash function has collisions, so correctly sizing your bloom filter is important to get the best possible performance from it. You must specify both the number of buckets and the amount of hashing that should be done.

buckets = 500
hashes = 5
bfilter = Bloom(buckets, hashes)

With that in place, you can add data and check if it exists:

bfilter.add('pony')
'pony' in bfilter # true
'frog' in bfilter # false

ploomy's People

Contributors

pkriete avatar

Stargazers

 avatar

Watchers

 avatar

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.