pub struct HyperLogLogPlus<S = DefaultHasher> { /* private fields */ }Expand description
An implementation of the the HyperLogLog++ data structure.
For small cardinalities, a “sparse” representation is used. The sparse representation is more accurate and uses less memory,
but has slower insert speed.
The error and memory usage of the sparse representation scales roughly linearly with the number of items inserted. When
the memory of the sparse representation equals the memory of the dense representation, it switches to dense automatically.
This happens inside the insert/insert_hash call (which is why it needs &mut self). The error of the sparse representation
never exceeds that of the dense.
Implementations§
Source§impl HyperLogLogPlus
impl HyperLogLogPlus
Source§impl<S: BuildHasher> HyperLogLogPlus<S>
impl<S: BuildHasher> HyperLogLogPlus<S>
Sourcepub fn with_hasher(precision: u8, hasher: S) -> Self
pub fn with_hasher(precision: u8, hasher: S) -> Self
Sourcepub fn insert_hash(&mut self, hash: u64)
pub fn insert_hash(&mut self, hash: u64)
Inserts the hash of an item into the HyperLogLogPlus.
self switches to dense mode if sparse mode exceeds memory usage of dense mode.
Sourcepub fn insert<T: Hash + ?Sized>(&mut self, value: &T)
pub fn insert<T: Hash + ?Sized>(&mut self, value: &T)
Inserts the item into the HyperLogLogPlus.
self switches to dense mode if sparse mode exceeds memory usage of dense mode.
Sourcepub fn insert_all<T: Hash, I: IntoIterator<Item = T>>(&mut self, iter: I)
pub fn insert_all<T: Hash, I: IntoIterator<Item = T>>(&mut self, iter: I)
Inserts all the items in iter into the self.
Sourcepub fn is_sparse(&self) -> bool
pub fn is_sparse(&self) -> bool
Returns true if the current internal representation is sparse,
false if using classic dense (HyperLogLog) representation.
Sourcepub fn union(&mut self, other: &Self) -> Result<(), Error>
pub fn union(&mut self, other: &Self) -> Result<(), Error>
Merges another HyperLogLog into self, updating the count.
Returns Err(Error::IncompatibleLength) if the two HyperLogLogs have
different precision (Self::precision).
This does not verify that the HLLs use equal hashers or seeds.
If they are different then self will be “corrupted”.
Trait Implementations§
Source§impl<S: Clone> Clone for HyperLogLogPlus<S>
impl<S: Clone> Clone for HyperLogLogPlus<S>
Source§fn clone(&self) -> HyperLogLogPlus<S>
fn clone(&self) -> HyperLogLogPlus<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<S: Debug> Debug for HyperLogLogPlus<S>
impl<S: Debug> Debug for HyperLogLogPlus<S>
Source§impl<T: Hash, S: BuildHasher> Extend<T> for HyperLogLogPlus<S>
impl<T: Hash, S: BuildHasher> Extend<T> for HyperLogLogPlus<S>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)