Struct hyperloglogplus::HyperLogLogPF[][src]

pub struct HyperLogLogPF<H: ?Sized, B> where
    H: Hash,
    B: BuildHasher
{ /* fields omitted */ }

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_std environment 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

impl<H: ?Sized, B> HyperLogLogPF<H, B> where
    H: Hash,
    B: BuildHasher
[src]

pub fn new(precision: u8, builder: B) -> Result<Self, HyperLogLogError>[src]

Creates a new HyperLogLogPF instance.

pub fn merge<S: ?Sized, T>(
    &mut self,
    other: &HyperLogLogPF<S, T>
) -> Result<(), HyperLogLogError> where
    S: Hash,
    T: BuildHasher
[src]

Merges the other HyperLogLogPF instance into self.

Both sketches must have the same precision.

pub fn insert_any<R: ?Sized>(&mut self, value: &R) where
    R: Hash
[src]

Inserts a new value, of any type, to the multiset.

Trait Implementations

impl<H: Clone + ?Sized, B: Clone> Clone for HyperLogLogPF<H, B> where
    H: Hash,
    B: BuildHasher
[src]

impl<H: Debug + ?Sized, B: Debug> Debug for HyperLogLogPF<H, B> where
    H: Hash,
    B: BuildHasher
[src]

impl<'de, H: ?Sized, B> Deserialize<'de> for HyperLogLogPF<H, B> where
    H: Hash,
    B: BuildHasher,
    B: Deserialize<'de>, 
[src]

impl<H: ?Sized, B> HyperLogLog<H> for HyperLogLogPF<H, B> where
    H: Hash,
    B: BuildHasher
[src]

fn add(&mut self, value: &H)[src]

👎 Deprecated since 0.3.0:

use insert() function instead.

Adds a new value to the multiset.

fn insert<Q: ?Sized>(&mut self, value: &Q) where
    H: Borrow<Q>,
    Q: Hash
[src]

Inserts a new value to the multiset.

fn count(&mut self) -> f64[src]

Estimates the cardinality of the multiset.

impl<H: ?Sized, B> Serialize for HyperLogLogPF<H, B> where
    H: Hash,
    B: BuildHasher,
    B: Serialize
[src]

Auto Trait Implementations

impl<H: ?Sized, B> RefUnwindSafe for HyperLogLogPF<H, B> where
    B: RefUnwindSafe,
    H: RefUnwindSafe

impl<H: ?Sized, B> Send for HyperLogLogPF<H, B> where
    B: Send,
    H: Send

impl<H: ?Sized, B> Sync for HyperLogLogPF<H, B> where
    B: Sync,
    H: Sync

impl<H: ?Sized, B> Unpin for HyperLogLogPF<H, B> where
    B: Unpin,
    H: Unpin

impl<H: ?Sized, B> UnwindSafe for HyperLogLogPF<H, B> where
    B: UnwindSafe,
    H: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.