pub struct HyperLogLogPF<H, B>{ /* private fields */ }Expand description
Implements the original HyperLogLog algorithm for cardinality estimation.
This implementation is based on the original paper of P. Flajolet et al:
HyperLogLog: the analysis of a near-optimal cardinality estimation algorithm.
- Uses 5-bit registers, packed in a 32-bit unsigned integer. Thus, every six registers 2 bits are not used.
- Supports serialization/deserialization through
serde. - Compiles in a
no_stdenvironment using a global allocator.
§Examples
use std::collections::hash_map::RandomState;
use hyperloglogplus::{HyperLogLog, HyperLogLogPF};
let mut hll: HyperLogLogPF<u32, _> =
HyperLogLogPF::new(16, RandomState::new()).unwrap();
hll.insert(&12345);
hll.insert(&23456);
assert_eq!(hll.count().trunc() as u32, 2);§References
Implementations§
Source§impl<H, B> HyperLogLogPF<H, B>
impl<H, B> HyperLogLogPF<H, B>
Sourcepub fn new(precision: u8, builder: B) -> Result<Self, HyperLogLogError>
pub fn new(precision: u8, builder: B) -> Result<Self, HyperLogLogError>
Creates a new HyperLogLogPF instance.
Sourcepub fn merge<S, T>(
&mut self,
other: &HyperLogLogPF<S, T>,
) -> Result<(), HyperLogLogError>
pub fn merge<S, T>( &mut self, other: &HyperLogLogPF<S, T>, ) -> Result<(), HyperLogLogError>
Merges the other HyperLogLogPF instance into self.
Both sketches must have the same precision.
Sourcepub fn insert_any<R>(&mut self, value: &R)
pub fn insert_any<R>(&mut self, value: &R)
Inserts a new value, of any type, to the multiset.
Trait Implementations§
Source§impl<H, B> Clone for HyperLogLogPF<H, B>
impl<H, B> Clone for HyperLogLogPF<H, B>
Source§fn clone(&self) -> HyperLogLogPF<H, B>
fn clone(&self) -> HyperLogLogPF<H, B>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<H, B> Debug for HyperLogLogPF<H, B>
impl<H, B> Debug for HyperLogLogPF<H, B>
Source§impl<'de, H, B> Deserialize<'de> for HyperLogLogPF<H, B>
impl<'de, H, B> Deserialize<'de> for HyperLogLogPF<H, B>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<H, B> Freeze for HyperLogLogPF<H, B>
impl<H, B> RefUnwindSafe for HyperLogLogPF<H, B>
impl<H, B> Send for HyperLogLogPF<H, B>
impl<H, B> Sync for HyperLogLogPF<H, B>
impl<H, B> Unpin for HyperLogLogPF<H, B>
impl<H, B> UnwindSafe for HyperLogLogPF<H, B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more