in-memory bloom filter in ruby
Ruby
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 9 commits behind deepfryed:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ext
lib
test
.gitignore
CHANGELOG
README.md
Rakefile
bloom-filter.gemspec

README.md

BloomFilter

BloomFilter is a ruby library that implements an in-memory Bloom Filter

Dependencies

  • ruby 1.9.1 or later

Installation

  gem install bloom-filter

API

  BloomFilter
    .new
    .load
    #dump
    #insert
    #include?

Usage

  require 'bloom-filter'

  filter = BloomFilter.new

  # auto-calculate optimum bitmap size based on maximum number of items stored and desired max error rate.
  filter = BloomFilter.new size: 100_000, error_rate: 0.01

  # specify bitmap size & number of hash functions explicitly.
  filter = BloomFilter.new bits: 100_000_0, hashes: 4

  filter.insert "foo"
  filter.include? "foo" #=> true
  filter.include? "bar" #=> false

  filter.dump "/tmp/random.bloom"
  filter = BloomFilter.load "/tmp/random.bloom"

See Also

https://github.com/igrigorik/bloomfilter-rb

License

Creative Commons Attribution - CC BY

Home Page

https://github.com/deepfryed/bloom-filter