Struct HLL

Source
pub struct HLL { /* private fields */ }
Expand description

The HLL struct stores the underlying registers of the HyperLogLog, with m many registers.

The value for m is derived from the desired error of the estimation. The error is considered to be 1.04 / sqrt(2 ^ bits). So, given a desired 1% error rate, we result in around 12 bits per register, producing an underlying M of 2^12 bits (i.e. 4kb).

Implementations§

Source§

impl HLL

Source

pub fn one_hundred_twenty_eight() -> HLL

Convenience function to produce a HLL with one hundred and twenty eight registers.

Source

pub fn new(error: f64) -> HLL

Create a new HLL with the desired standard error. Some examples might be:

     bits    size    error
     12      4096    0.0163
     13      8192    0.0115
     14      16384   0.0081

The error must be between 0.0 and 1.0. Beware using a stupidly small error size will grow beyond e.g. isize at less than 0.03 (if you need something that isn’t an estimate probably don’t use a hyperloglog).

Source

pub fn insert<T: Hash>(&mut self, val: &T) -> bool

Add an element into the hyperloglog estimate. We require the type of value to be able to be hashed. Returns whether the insertion altered the hyperloglog

Source

pub fn count(&self) -> f64

Return the estimated cardinality of the observed set of elements.

Source

pub fn registers(&self) -> Vec<u8>

Access a copy of the underlying registers (this is mainly here just for debugging/testing… its unlikely you’ll need this access typically).

Source

pub fn empty() -> HLL

A completely zeroed HLL. Not particularly useful except as an identity element in Add.

Source

pub fn into_vec(self) -> Vec<u8>

Source

pub fn from_vec(data: Vec<u8>) -> HLL

Trait Implementations§

Source§

impl<'a> Add for &'a HLL

Adding together two HLLs produces a new HLL where the larger value of each register has been selected.

Source§

type Output = HLL

The resulting type after applying the + operator.
Source§

fn add(self, other: &'a HLL) -> HLL

Performs the + operation. Read more
Source§

impl Clone for HLL

Source§

fn clone(&self) -> HLL

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HLL

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for HLL

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for HLL

Source§

fn eq(&self, other: &HLL) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for HLL

Source§

impl StructuralPartialEq for HLL

Auto Trait Implementations§

§

impl Freeze for HLL

§

impl RefUnwindSafe for HLL

§

impl Send for HLL

§

impl Sync for HLL

§

impl Unpin for HLL

§

impl UnwindSafe for HLL

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.