pub struct CuckooConfiguration { /* private fields */ }Expand description
Configuration for the crate::CuckooFilter.
Used to define main cuckoo filter parameters (capacity, bucket size, fingeprint size, max kicks), as well as additional features (TTL, LRU, generic counter).
Create a new instance using CuckooConfiguration::builder.
§Examples
use cuckoo_clock::config::CuckooConfiguration;
let config = CuckooConfiguration::builder(100_000)
.fingerprint_bits(14.try_into()?)
.bucket_size(4.try_into()?)
.max_kicks(8)
.build()?;use cuckoo_clock::config::{CuckooConfiguration, TtlConfig, LruConfig};
let config = CuckooConfiguration::builder(100_000)
.fingerprint_bits(14.try_into()?)
.with_ttl(TtlConfig {
ttl: 10.try_into()?,
ttl_bits: 4.try_into()?
})
.with_lru(LruConfig {
counter_bits: 6.try_into()?,
..Default::default()
})
.bucket_size(4.try_into()?)
.max_kicks(8)
.build()?;Implementations§
Source§impl CuckooConfiguration
impl CuckooConfiguration
Sourcepub const fn builder(max_entries: usize) -> CuckooConfigurationBuilder
pub const fn builder(max_entries: usize) -> CuckooConfigurationBuilder
Creates a new instance of CuckooConfigurationBuilder with provided maximum number of
entries.
Sourcepub const fn get_configured_memory_usage(&self) -> usize
pub const fn get_configured_memory_usage(&self) -> usize
Returns the memory usage of filter that would be created from this configuration in bytes.
Sourcepub fn compatible_layout(&self, other: &Self) -> bool
pub fn compatible_layout(&self, other: &Self) -> bool
Checks whether this and other configuration have a compatible layout.
If this is true, filter exported by the other configuration can be imported and used with this configuration. The only compatible configuration changes are generally ones that don’t affect size or count of the buckets and items.
Sourcepub const fn bucket_size(&self) -> usize
pub const fn bucket_size(&self) -> usize
Returns the configured bucket size.
Sourcepub fn lru_config(&self) -> Option<LruConfig>
pub fn lru_config(&self) -> Option<LruConfig>
Returns the LRU configuration, if available.
Sourcepub fn ttl_config(&self) -> Option<TtlConfig>
pub fn ttl_config(&self) -> Option<TtlConfig>
Returns the TTL configuration, if available.
Sourcepub fn counter_config(&self) -> Option<CounterConfig>
pub fn counter_config(&self) -> Option<CounterConfig>
Returns the counter configuration, if available.
Sourcepub const fn get_bucket_count(&self) -> usize
pub const fn get_bucket_count(&self) -> usize
Returns the actual bucket count for this CuckooConfiguration.
Bucket count is calculated as first next power of two of capacity / bucket_size. This means that the actual capacity of the filter is usually bigger than the requested capacity.
Trait Implementations§
Source§impl Clone for CuckooConfiguration
impl Clone for CuckooConfiguration
Source§fn clone(&self) -> CuckooConfiguration
fn clone(&self) -> CuckooConfiguration
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CuckooConfiguration
impl Debug for CuckooConfiguration
impl Eq for CuckooConfiguration
Source§impl PartialEq for CuckooConfiguration
impl PartialEq for CuckooConfiguration
Source§fn eq(&self, other: &CuckooConfiguration) -> bool
fn eq(&self, other: &CuckooConfiguration) -> bool
self and other values to be equal, and is used by ==.