pub struct ModuleDensity { /* private fields */ }Expand description
How many bits are set in each module of a filter.
Recorded when the filter is built so that a later reader can work out what accuracy a given number of modules buys without holding any of them. That is what lets a caller decide how much of a stored filter to read before reading any of it.
Implementations§
Source§impl ModuleDensity
impl ModuleDensity
Sourcepub fn measure(layout: &ModuleLayout, words: &[u64]) -> Self
pub fn measure(layout: &ModuleLayout, words: &[u64]) -> Self
Counts the bits set in each module of words, which must hold whole
modules of layout laid out in order.
Sourcepub fn modules(&self) -> u32
pub fn modules(&self) -> u32
Modules this covers, which may be fewer than the layout describes.
Sourcepub fn fill_ratio(&self, layout: &ModuleLayout, modules: u32) -> f64
pub fn fill_ratio(&self, layout: &ModuleLayout, modules: u32) -> f64
Fraction of bits set across the first modules modules.
Returns 0.0 when nothing is covered.
Sourcepub fn false_positive_rate(&self, layout: &ModuleLayout, modules: u32) -> f64
pub fn false_positive_rate(&self, layout: &ModuleLayout, modules: u32) -> f64
False positive rate of a filter holding the first modules modules.
modules above layout.total_modules() is clamped. Modules this does
not cover are charged the mean fill of the ones it does, which is what a
filter measured from a prefix falls back on; zero coverage gives 1.0,
since nothing is known to reject anything.
Sourcepub fn modules_for(&self, layout: &ModuleLayout, target: f64) -> u32
pub fn modules_for(&self, layout: &ModuleLayout, target: f64) -> u32
Smallest number of modules whose rate is at or below target.
Returns layout.total_modules() when even the whole filter misses target,
and 0 when target is 1.0 or above.
Trait Implementations§
Source§impl Clone for ModuleDensity
impl Clone for ModuleDensity
Source§fn clone(&self) -> ModuleDensity
fn clone(&self) -> ModuleDensity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more