Skip to main content

CuckooConfiguration

Struct CuckooConfiguration 

Source
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

Source

pub const fn builder(max_entries: usize) -> CuckooConfigurationBuilder

Creates a new instance of CuckooConfigurationBuilder with provided maximum number of entries.

Source

pub const fn get_configured_memory_usage(&self) -> usize

Returns the memory usage of filter that would be created from this configuration in bytes.

Source

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.

Source

pub const fn bucket_size(&self) -> usize

Returns the configured bucket size.

Source

pub const fn max_kicks(&self) -> usize

Returns the configured max kicks.

Source

pub fn lru_config(&self) -> Option<LruConfig>

Returns the LRU configuration, if available.

Source

pub fn ttl_config(&self) -> Option<TtlConfig>

Returns the TTL configuration, if available.

Source

pub fn counter_config(&self) -> Option<CounterConfig>

Returns the counter configuration, if available.

Source

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

Source§

fn clone(&self) -> CuckooConfiguration

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CuckooConfiguration

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for CuckooConfiguration

Source§

impl PartialEq for CuckooConfiguration

Source§

fn eq(&self, other: &CuckooConfiguration) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for CuckooConfiguration

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V