VariantBloomFilter

Struct VariantBloomFilter 

Source
pub struct VariantBloomFilter { /* private fields */ }
Expand description

A variant bloom filter, the best choice for bigger data set. In this structure, k hash functions all has it’s own slice of bitmap, whose max size is u64::MAX. Usage:

use roaring_bloom_filter::*;

let mut bf = VariantBloomFilter::new(100, 0.001_f64);

bf.add(&10);
bf.add(&'a');
bf.add(&"a string");

bf.contains(&12);

Variant Bloom Filter(VBF)

Every hash function has it’s own slice instead of sharing the whole bitmap. This introduce the possibility of concurrency of manipulating multiply hash function at the same time.

Implementations§

Source§

impl VariantBloomFilter

Source

pub fn from_scratch( slices_length: u32, slice_size: u64, target_false_positive_rate: f64, ) -> VariantBloomFilter

Create an empty variant bloom filter from scratch.

Generally, user should not use this initializer directly. Promise the limitation on yourself:

  • 0 < k <= u32::MAX
  • 0 < m <= u32::MAX
  • 0 < f < 1
Source

pub fn new(max_size: u64, target_false_positive: f64) -> impl BloomFilter

Create an empty bloom filter with max element’s size and false positive rate. The crate would calculate the best buckets length and bucket size.

Trait Implementations§

Source§

impl BloomFilter for VariantBloomFilter

Source§

fn add<T>(&mut self, value: &T) -> bool
where T: Hash,

Add new element into the bloom filter. Return true when any key are inserted in a slice.
Source§

fn contains<T>(&self, value: &T) -> bool
where T: Hash,

Check if the bloom filter contains the specific key. Return true when all key are present in all slices, which may contains false positive situation.
Source§

fn target_false_positive_rate(&self) -> f64

Get target false positive rate.
Source§

fn current_false_positive_rate(&self) -> f64

Get current false positive rate.
Source§

fn is_empty(&self) -> bool

If this bloom filter is empty.
Source§

fn is_full(&self) -> bool

If this bloom filter is full.
Source§

fn size(&self) -> u64

Get the number of inserted elements in this bloom filter.
Source§

fn len(&self) -> u64

Get the number of inserted bits in all slices.
Source§

impl Display for VariantBloomFilter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.