Skip to main content

SharedBloomFilter

Struct SharedBloomFilter 

Source
pub struct SharedBloomFilter { /* private fields */ }

Implementations§

Source§

impl SharedBloomFilter

Source

pub fn suggest_config(n_items: usize, p: f64) -> (usize, u32)

Suggest n_bits and n_hashes for a target false-positive rate p and expected item count n. Both rounded up.

Source

pub fn create( base_path: impl AsRef<Path>, n_bits: usize, n_hashes: u32, ) -> Result<Self, BloomError>

Source

pub fn open( base_path: impl AsRef<Path>, n_bits: usize, n_hashes: u32, ) -> Result<Self, BloomError>

Source

pub fn n_bits(&self) -> u64

Source

pub fn n_hashes(&self) -> u32

Source

pub fn insert(&self, item: &[u8]) -> Result<(), BloomError>

Source

pub fn contains(&self, item: &[u8]) -> Result<bool, BloomError>

True if item MIGHT be in the set; false if definitely not. False positives are possible; false negatives are NOT.

Source

pub fn clear(&self)

Clear all bits (resets the filter to empty).

Source

pub fn estimated_false_positive_rate(&self) -> f64

Estimate the current false-positive rate from the bit-set density. Returns 0.0 for an empty filter; approaches 1.0 as the filter saturates.

Source

pub fn estimated_insert_count(&self) -> u64

Estimate the number of distinct inserted items based on bit density. Formula: -n_bits / n_hashes * ln(1 - fill / n_bits).

Source

pub fn flush(&self) -> Result<(), BloomError>

Source

pub fn flush_async(&self) -> Result<(), BloomError>

Trait Implementations§

Source§

impl AdaptiveInstance for SharedBloomFilter

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.
Source§

impl Send for SharedBloomFilter

Source§

impl Sync for SharedBloomFilter

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