Struct hyperloglogplus::HyperLogLogPF [−][src]
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
impl<H: ?Sized, B> HyperLogLogPF<H, B> where
H: Hash,
B: BuildHasher,
[src]
H: Hash,
B: BuildHasher,
pub fn new(precision: u8, builder: B) -> Result<Self, HyperLogLogError>
[src]
Creates a new HyperLogLogPF instance.
pub fn merge<S: ?Sized, T>(
&mut self,
other: &HyperLogLogPF<S, T>
) -> Result<(), HyperLogLogError> where
S: Hash,
T: BuildHasher,
[src]
&mut self,
other: &HyperLogLogPF<S, T>
) -> Result<(), HyperLogLogError> where
S: Hash,
T: BuildHasher,
Merges the other
HyperLogLogPF instance into self
.
Both sketches must have the same precision.
pub fn insert_any<R: ?Sized>(&mut self, value: &R) where
R: Hash,
[src]
R: Hash,
Inserts a new value, of any type, to the multiset.
Trait Implementations
impl<H: Clone + ?Sized, B: Clone> Clone for HyperLogLogPF<H, B> where
H: Hash,
B: BuildHasher,
[src]
H: Hash,
B: BuildHasher,
fn clone(&self) -> HyperLogLogPF<H, B>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<H: Debug + ?Sized, B: Debug> Debug for HyperLogLogPF<H, B> where
H: Hash,
B: BuildHasher,
[src]
H: Hash,
B: BuildHasher,
impl<'de, H: ?Sized, B> Deserialize<'de> for HyperLogLogPF<H, B> where
H: Hash,
B: BuildHasher,
B: Deserialize<'de>,
[src]
H: Hash,
B: BuildHasher,
B: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<H: ?Sized, B> HyperLogLog<H> for HyperLogLogPF<H, B> where
H: Hash,
B: BuildHasher,
[src]
H: Hash,
B: BuildHasher,
fn add(&mut self, value: &H)
[src]
👎 Deprecated since 0.3.0:
use insert() function instead.
Adds a new value to the multiset.
fn insert<Q: ?Sized>(&mut self, value: &Q) where
H: Borrow<Q>,
Q: Hash,
[src]
H: Borrow<Q>,
Q: Hash,
Inserts a new value to the multiset.
fn count(&mut self) -> f64
[src]
Estimates the cardinality of the multiset.
impl<H: ?Sized, B> Serialize for HyperLogLogPF<H, B> where
H: Hash,
B: BuildHasher,
B: Serialize,
[src]
H: Hash,
B: BuildHasher,
B: Serialize,
Auto Trait Implementations
impl<H: ?Sized, B> RefUnwindSafe for HyperLogLogPF<H, B> where
B: RefUnwindSafe,
H: RefUnwindSafe,
B: RefUnwindSafe,
H: RefUnwindSafe,
impl<H: ?Sized, B> Send for HyperLogLogPF<H, B> where
B: Send,
H: Send,
B: Send,
H: Send,
impl<H: ?Sized, B> Sync for HyperLogLogPF<H, B> where
B: Sync,
H: Sync,
B: Sync,
H: Sync,
impl<H: ?Sized, B> Unpin for HyperLogLogPF<H, B> where
B: Unpin,
H: Unpin,
B: Unpin,
H: Unpin,
impl<H: ?Sized, B> UnwindSafe for HyperLogLogPF<H, B> where
B: UnwindSafe,
H: UnwindSafe,
B: UnwindSafe,
H: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,