rotating-bloom-filter 0.1.0

A probabilistic data structure that rotates out old items to maintain recent membership.
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented2 out of 5 items with examples
  • Size
  • Source code size: 10.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.38 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 24s Average build duration of successful builds.
  • all releases: 24s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • eaon

Rotating Bloom Filter

A probabilistic data structure that maintains recent items using a dual-buffer rotation mechanism.

RotatingBloomFilter provides membership testing for recently inserted items, with older items automatically rotating out. Items are guaranteed to be retained for at least a minimum retention period, typically remaining for up to twice that duration.

Features

  • Time-limited tracking: Only maintains membership information for recently inserted items
  • Type flexible: Works with any hashable type

How it works

The filter maintains two internal Bloom filters:

  1. Current buffer: Holds items from previous rotations plus ongoing insertions
  2. Next buffer: Accumulates new insertions until rotation

When the minimum retention threshold is reached, the next buffer becomes the new current buffer, and a new next buffer is created.

Example

use rotating_bloom_filter::RotatingBloomFilter;
use rand_core::OsRng;

let mut filter = RotatingBloomFilter::new(0.01, 1000, &mut OsRng);

filter.insert("hello");
assert!(filter.contains("hello"));

// "hello" will be retained for at least 1000 insertions, but sticks around to 2000 insertions if
// the filter continues to be used.