pub struct AtomicHyperLogLog<S = DefaultHasher> { /* private fields */ }Expand description
HyperLogLog is a data structure for the “count-distinct problem”, approximating the number of distinct elements in a multiset.
AtomicHyperLogLog is the thread-safe counterpart of HyperLogLog.
§Example
use hyperloglockless::AtomicHyperLogLog;
let hll = AtomicHyperLogLog::new(16);
hll.insert("42");
hll.insert("🦀");
let count = hll.count();Implementations§
Source§impl<S: BuildHasher> AtomicHyperLogLog<S>
impl<S: BuildHasher> AtomicHyperLogLog<S>
Sourcepub fn with_hasher(precision: u8, hasher: S) -> Self
pub fn with_hasher(precision: u8, hasher: S) -> Self
Returns a new AtomicHyperLogLog with 1 << precision registers (1 byte each)
using the provided hasher.
Source§impl AtomicHyperLogLog
impl AtomicHyperLogLog
Sourcepub fn new(precision: u8) -> AtomicHyperLogLog<DefaultHasher>
pub fn new(precision: u8) -> AtomicHyperLogLog<DefaultHasher>
Returns a new Self with 1 << precision registers (1 byte each)
using the default hasher with a random seed.
Sourcepub fn seeded(precision: u8, seed: u128) -> AtomicHyperLogLog<DefaultHasher>
pub fn seeded(precision: u8, seed: u128) -> AtomicHyperLogLog<DefaultHasher>
Returns a new Self with 1 << precision registers (1 byte each)
using the default hasher seeded with seed.
Source§impl<S: BuildHasher> AtomicHyperLogLog<S>
impl<S: BuildHasher> AtomicHyperLogLog<S>
Source§impl<S: BuildHasher> AtomicHyperLogLog<S>
impl<S: BuildHasher> AtomicHyperLogLog<S>
Sourcepub fn iter(&self) -> impl Iterator<Item = u8> + '_
pub fn iter(&self) -> impl Iterator<Item = u8> + '_
Returns an iterator over the value of each register.
Sourcepub fn insert_hash(&self, hash: u64)
pub fn insert_hash(&self, hash: u64)
Inserts the hash of an item into the HyperLogLog.
Sourcepub fn insert_all<T: Hash, I: IntoIterator<Item = T>>(&self, iter: I)
pub fn insert_all<T: Hash, I: IntoIterator<Item = T>>(&self, iter: I)
Inserts all the items in iter into the self. Immutable version of Self::extend.
Sourcepub fn union(&self, other: &Self) -> Result<(), Error>
pub fn union(&self, other: &Self) -> Result<(), Error>
Merges another HyperLogLog into self, updating the count.
Returns Err(Error::IncompatibleLength) if the two HyperLogLogs have
different length (Self::len).
Trait Implementations§
Source§impl<S: BuildHasher + Clone> Clone for AtomicHyperLogLog<S>
impl<S: BuildHasher + Clone> Clone for AtomicHyperLogLog<S>
Source§impl<S: Debug> Debug for AtomicHyperLogLog<S>
impl<S: Debug> Debug for AtomicHyperLogLog<S>
Source§impl<T: Hash, S: BuildHasher> Extend<T> for AtomicHyperLogLog<S>
impl<T: Hash, S: BuildHasher> Extend<T> for AtomicHyperLogLog<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)