pub struct HyperLogLog<T, H, W> { /* private fields */ }
Expand description
Estimator logic implementing the HyperLogLog algorithm.
Instances are built using HyperLogLogBuilder
, which provides convenient
ways to set the internal parameters.
Note that T
can be any type satisfying the Hash
trait. The parameter
H
makes it possible to select a hashing algorithm, and W
is the unsigned
type used to store backends.
An important constraint is that W
must be able to represent exactly the
backend of an estimator. While usually usize
will work (and it is the default
type chosen by new
), with odd register sizes
and small number of registers it might be necessary to select a smaller
type, resulting in slower merges. For example, using 16 5-bit registers one
needs to use u16
, whereas for 16 6-bit registers u32
will be sufficient.
Implementations§
Source§impl HyperLogLog<(), (), ()>
impl HyperLogLog<(), (), ()>
Sourcepub fn log_2_num_of_registers(rsd: f64) -> usize
pub fn log_2_num_of_registers(rsd: f64) -> usize
Returns the logarithm of the number of registers per estimator that are necessary to attain a given relative standard deviation.
§Arguments
rsd
: the relative standard deviation to be attained.
Sourcepub fn rel_std(log_2_num_registers: usize) -> f64
pub fn rel_std(log_2_num_registers: usize) -> f64
Returns the relative standard deviation corresponding to a given number of registers per estimator.
§Arguments
log_2_num_registers
: the logarithm of the number of registers per estimator.
Sourcepub fn register_size(n: usize) -> usize
pub fn register_size(n: usize) -> usize
Returns the register size in bits, given an upper bound on the number of distinct elements.
§Arguments
n
: an upper bound on the number of distinct elements.
Trait Implementations§
Source§impl<T, H, W> Display for HyperLogLog<T, H, W>
impl<T, H, W> Display for HyperLogLog<T, H, W>
Source§impl<T: Hash, H: BuildHasher + Clone, W: Word + UpcastableInto<u64> + CastableFrom<u64>> EstimationLogic for HyperLogLog<T, H, W>
impl<T: Hash, H: BuildHasher + Clone, W: Word + UpcastableInto<u64> + CastableFrom<u64>> EstimationLogic for HyperLogLog<T, H, W>
Source§type Estimator<'a> = DefaultEstimator<HyperLogLog<T, H, W>, &'a HyperLogLog<T, H, W>, Box<[W]>>
where
T: 'a,
W: 'a,
H: 'a
type Estimator<'a> = DefaultEstimator<HyperLogLog<T, H, W>, &'a HyperLogLog<T, H, W>, Box<[W]>> where T: 'a, W: 'a, H: 'a
Source§fn new_estimator(&self) -> Self::Estimator<'_>
fn new_estimator(&self) -> Self::Estimator<'_>
Source§fn add(&self, backend: &mut Self::Backend, element: impl Borrow<T>)
fn add(&self, backend: &mut Self::Backend, element: impl Borrow<T>)
Source§impl<T: Hash, H: BuildHasher + Clone, W: Word + UpcastableInto<u64> + CastableFrom<u64>> MergeEstimationLogic for HyperLogLog<T, H, W>
impl<T: Hash, H: BuildHasher + Clone, W: Word + UpcastableInto<u64> + CastableFrom<u64>> MergeEstimationLogic for HyperLogLog<T, H, W>
Source§type Helper = HyperLogLogHelper<W>
type Helper = HyperLogLogHelper<W>
Source§fn new_helper(&self) -> Self::Helper
fn new_helper(&self) -> Self::Helper
Source§impl<T: Hash, H: BuildHasher + Clone, W: Word + UpcastableInto<u64> + CastableFrom<u64>> SliceEstimationLogic<W> for HyperLogLog<T, H, W>
impl<T: Hash, H: BuildHasher + Clone, W: Word + UpcastableInto<u64> + CastableFrom<u64>> SliceEstimationLogic<W> for HyperLogLog<T, H, W>
Source§fn backend_len(&self) -> usize
fn backend_len(&self) -> usize
T
in a backend.impl<T, H, W> StructuralPartialEq for HyperLogLog<T, H, W>
Auto Trait Implementations§
impl<T, H, W> Freeze for HyperLogLog<T, H, W>where
H: Freeze,
impl<T, H, W> RefUnwindSafe for HyperLogLog<T, H, W>
impl<T, H, W> Send for HyperLogLog<T, H, W>
impl<T, H, W> Sync for HyperLogLog<T, H, W>
impl<T, H, W> Unpin for HyperLogLog<T, H, W>
impl<T, H, W> UnwindSafe for HyperLogLog<T, H, W>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more