pub struct HyperLogLogPlus<H, B> where
    H: Hash + ?Sized,
    B: BuildHasher
{ /* private fields */ }
Expand description

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<u32, _> =
    HyperLogLogPlus::new(16, RandomState::new()).unwrap();

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

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

References

Implementations

Creates a new HyperLogLogPlus instance.

Merges the other HyperLogLogPlus instance into self.

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

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

👎 Deprecated since 0.3.0:

use insert() function instead.

Adds a new value to the multiset.

Inserts a new value to the multiset.

Estimates the cardinality of the multiset.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.