BloomFilterEx

A high-performance Elixir implementation of Bloom filters using the blazingly fast fastbloom Rust library via Rustler NIFs.

Features

What is a Bloom Filter?

A Bloom filter is a space-efficient probabilistic data structure for membership testing:

Quick Start

# Create a Bloom filter for 1M items with 1% false positive rate
bloom = BloomFilterEx.new(1_000_000, 0.01)

# Add items
bloom = BloomFilterEx.add(bloom, "user@example.com")
bloom = BloomFilterEx.add(bloom, "192.168.1.1")

# Check membership
BloomFilterEx.member?(bloom, "user@example.com")  # => true
BloomFilterEx.member?(bloom, "not-added@example.com")  # => false

# Get statistics
stats = BloomFilterEx.stats(bloom)
# => %{capacity: 1000000, false_positive_rate: 0.01, ...}

Installation

If available in Hex, the package can be installed by adding bloom_filter to your list of dependencies in mix.exs:

def deps do
  [
    {:bloom_filter_ex, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/bloom_filter.