Skip to content

jstrutz/bloom-filter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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?
    #bits
    #binary

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"

  bits   = filter.bits   #=> "10010100100111..."
  binary = filter.binary #=> "\x83Ö\xAC\xEA\u00..."

  filter2 = BloomFilter.new bits: 100_000_0, hashes: 4
  filter2.binary = binary
  filter2.include? "foo" #=> true

See Also

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

Home Page

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

License

MIT

About

in-memory bloom filter in ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 83.8%
  • Ruby 16.2%