[][src]Struct hyperloglogplus::HyperLogLogPlus

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

Implements the HyperLogLog++ algorithm for cardinality estimation.

This implementation is based on the paper:

HyperLogLog in Practice: Algorithmic Engineering of a State of The Art Cardinality Estimation Algorithm.

  • Uses 6-bit registers, packed in a 32-bit unsigned integer. Thus, every five registers 2 bits are not used.
  • In small cardinalities, a sparse representation is used which allows for higher precision in estimations.
  • Performs bias correction using the empirical data provided by Google (can be found here).
  • Supports serialization/deserialization through serde.

Examples

use std::collections::hash_map::RandomState;
use hyperloglogplus::{HyperLogLog, HyperLogLogPlus};

let mut hllp: HyperLogLogPlus<u64, RandomState> =
    HyperLogLogPlus::new(16, RandomState::new()).unwrap();

hllp.add(&12345);
hllp.add(&23456);

assert_eq!(hllp.count().trunc() as u32, 2);

References

Methods

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

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

Creates a new HyperLogLogPlus instance.

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

Merges the other HyperLogLogPlus instance into self.

Both sketches must have the same precision. Merge can trigger the transition from sparse to normal representation.

Trait Implementations

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

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

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

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

Adds a new value to the multiset.

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

Estimates the cardinality of the multiset.

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

Auto Trait Implementations

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

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

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

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

impl<H: ?Sized, B> UnwindSafe for HyperLogLogPlus<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, 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.