pub struct BloomFilter { /* private fields */ }Expand description
Concurrent Bloom filter with atomic rebuild support.
Inserts made while a rebuild is active are recorded and applied to the new filter immediately before it replaces the old filter.
Implementations§
Source§impl BloomFilter
impl BloomFilter
Sourcepub fn new(config: BloomConfig) -> Result<Self, BloomError>
pub fn new(config: BloomConfig) -> Result<Self, BloomError>
Creates a Bloom filter from the expected item count and false-positive rate.
§Errors
Returns BloomError::InvalidConfiguration when the item count or false-positive rate is
rejected by the underlying Bloom filter.
Sourcepub fn insert_many<'a>(&self, keys: impl IntoIterator<Item = &'a str>)
pub fn insert_many<'a>(&self, keys: impl IntoIterator<Item = &'a str>)
Inserts several keys into the current filter.
Sourcepub fn clear(&self, config: BloomConfig) -> Result<(), BloomError>
pub fn clear(&self, config: BloomConfig) -> Result<(), BloomError>
Replaces the current filter with an empty filter using new sizing.
§Errors
Returns BloomError::InvalidConfiguration for invalid sizing, or
BloomError::RebuildInProgress while an atomic rebuild is active.
Sourcepub fn start_rebuild(
self: &Arc<Self>,
config: BloomConfig,
) -> Result<BloomRebuild, BloomError>
pub fn start_rebuild( self: &Arc<Self>, config: BloomConfig, ) -> Result<BloomRebuild, BloomError>
Starts an atomic rebuild session.
Feed streamed batches into the returned session and call
BloomRebuild::commit after the source has completed. Dropping the
session leaves the previous filter active and stops buffering inserts.
§Errors
Returns BloomError::InvalidConfiguration for invalid sizing, or
BloomError::RebuildInProgress when another rebuild already owns the session.