Struct bloomfilter::Bloom

source ·
pub struct Bloom<T: ?Sized> { /* private fields */ }
Expand description

Bloom filter structure

Implementations§

source§

impl<T: ?Sized> Bloom<T>

source

pub fn new_with_seed( bitmap_size: usize, items_count: usize, seed: &[u8; 32] ) -> Self

Create a new bloom filter structure. bitmap_size is the size in bytes (not bits) that will be allocated in memory items_count is an estimation of the maximum number of items to store. seed is a random value used to generate the hash functions.

source

pub fn new(bitmap_size: usize, items_count: usize) -> Self

Create a new bloom filter structure. bitmap_size is the size in bytes (not bits) that will be allocated in memory items_count is an estimation of the maximum number of items to store.

source

pub fn new_for_fp_rate(items_count: usize, fp_p: f64) -> Self

Create a new bloom filter structure. items_count is an estimation of the maximum number of items to store. fp_p is the wanted rate of false positives, in ]0.0, 1.0[

source

pub fn new_for_fp_rate_with_seed( items_count: usize, fp_p: f64, seed: &[u8; 32] ) -> Self

Create a new bloom filter structure. items_count is an estimation of the maximum number of items to store. fp_p is the wanted rate of false positives, in ]0.0, 1.0[

source

pub fn from_bit_vec( bit_vec: BitVec, bitmap_bits: u64, k_num: u32, sip_keys: [(u64, u64); 2] ) -> Self

Create a bloom filter structure from a previous state given as a ByteVec structure. The state is assumed to be retrieved from an existing bloom filter.

source

pub fn from_existing( bytes: &[u8], bitmap_bits: u64, k_num: u32, sip_keys: [(u64, u64); 2] ) -> Self

Create a bloom filter structure with an existing state given as a byte array. The state is assumed to be retrieved from an existing bloom filter.

source

pub fn compute_bitmap_size(items_count: usize, fp_p: f64) -> usize

Compute a recommended bitmap size for items_count items and a fp_p rate of false positives. fp_p obviously has to be within the ]0.0, 1.0[ range.

source

pub fn set(&mut self, item: &T)
where T: Hash,

Record the presence of an item.

source

pub fn check(&self, item: &T) -> bool
where T: Hash,

Check if an item is present in the set. There can be false positives, but no false negatives.

source

pub fn check_and_set(&mut self, item: &T) -> bool
where T: Hash,

Record the presence of an item in the set, and return the previous state of this item.

source

pub fn bitmap(&self) -> Vec<u8>

Return the bitmap as a vector of bytes

source

pub fn bit_vec(&self) -> &BitVec

Return the bitmap as a “BitVec” structure

source

pub fn number_of_bits(&self) -> u64

Return the number of bits in the filter

source

pub fn number_of_hash_functions(&self) -> u32

Return the number of hash functions used for check and set

source

pub fn sip_keys(&self) -> [(u64, u64); 2]

Return the keys used by the sip hasher

source

pub fn clear(&mut self)

Clear all of the bits in the filter, removing all keys from the set

source

pub fn fill(&mut self)

Set all of the bits in the filter, making it appear like every key is in the set

source

pub fn is_empty(&self) -> bool

Test if there are no elements in the set

Trait Implementations§

source§

impl<T: Clone + ?Sized> Clone for Bloom<T>

source§

fn clone(&self) -> Bloom<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug + ?Sized> Debug for Bloom<T>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T: ?Sized> RefUnwindSafe for Bloom<T>
where T: RefUnwindSafe,

§

impl<T: ?Sized> Send for Bloom<T>
where T: Send,

§

impl<T: ?Sized> Sync for Bloom<T>
where T: Sync,

§

impl<T: ?Sized> Unpin for Bloom<T>
where T: Unpin,

§

impl<T: ?Sized> UnwindSafe for Bloom<T>
where T: UnwindSafe,

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.