pub struct HyperLogLogPF<H, B> where
    H: Hash + ?Sized,
    B: BuildHasher
{ /* 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_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

Creates a new HyperLogLogPF instance.

Merges the other HyperLogLogPF instance into self.

Both sketches must have the same precision.

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.