HyperLogLogPlusPlus

Struct HyperLogLogPlusPlus 

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

HLL++ aggregator for estimating cardinalities of multisets.

The aggregator uses the standard format for storing the internal state of the cardinality estimate as defined in hllplus-unique.proto, allowing users to merge aggregators with data computed in C++ or Go and to load up the cardinalities in a variety of analysis tools.

The precision defines the accuracy of the HLL++ aggregator at the cost of the memory used. The upper bound on the memory required is 2precision bytes, but less memory is used for smaller cardinalities (up to ~2precision - 2). The relative error is 1.04 / sqrt(2precision). A typical value used at Google is 15, which gives an error of about 0.6% while requiring an upper bound of 32 KiB of memory.

Implementations§

Source§

impl HyperLogLogPlusPlus

Source

pub const MINIMUM_PRECISION: i32 = 10i32

The smallest normal precision supported by this aggregator.

Source

pub const MAXIMUM_PRECISION: i32 = 24i32

The largest normal precision supported by this aggregator.

Source

pub const DEFAULT_NORMAL_PRECISION: i32 = 15i32

The default normal precision that is used if the user does not specify a normal precision.

Source

pub const MAXIMUM_SPARSE_PRECISION: i32 = 25i32

The largest sparse precision supported by this aggregator.

Source

pub const SPARSE_PRECISION_DISABLED: i32 = 0i32

Value used to indicate that the sparse representation should not be used.

Source

pub const DEFAULT_SPARSE_PRECISION_DELTA: i32 = 5i32

If no sparse precision is specified, this value is added to the normal precision to obtain the sparse precision, which optimizes the memory-precision trade-off.

Source

pub const ENCODING_VERSION: i32 = 2i32

The encoding version of the AggregatorStateProto. We only support v2.

Source

pub fn builder() -> HyperLogLogPlusPlusBuilder

Returns a new builder to customize and create a new instance of this aggregator.

Source

pub fn from_proto(proto: AggregatorStateProto) -> Result<Self, SketchError>

Creates a new HyperLogLog++ aggregator from the serialized proto.

The proto must be a valid aggregator state of type AggregatorType::HYPERLOGLOG_PLUS_UNIQUE.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, SketchError>

Creates a new HyperLogLog++ aggregator from the bytes.

The bytes must be a valid serialized AggregatorStateProto of the type AggregatorType::HYPERLOGLOG_PLUS_UNIQUE.

Source

pub fn add_i32(&mut self, value: i32) -> Result<(), SketchError>

Add value to the aggregator.

Returns SketchError if the aggregator is of different type than i32 or u32. See HyperLogLogPlusPlusBuilder::build_for_u32.

Source

pub fn add_u32(&mut self, value: u32) -> Result<(), SketchError>

Add value to the aggregator.

Returns SketchError if the aggregator is of different type than i32 or u32. See HyperLogLogPlusPlusBuilder::build_for_u32.

Source

pub fn add_i64(&mut self, value: i64) -> Result<(), SketchError>

Add value to the aggregator.

Returns SketchError if the aggregator is of different type than i64 or u64. See HyperLogLogPlusPlusBuilder::build_for_u64.

Source

pub fn add_u64(&mut self, value: u64) -> Result<(), SketchError>

Add value to the aggregator.

Returns SketchError if the aggregator is of different type than i64 or u64. See HyperLogLogPlusPlusBuilder::build_for_u64.

Source

pub fn add_bytes(&mut self, value: &[u8]) -> Result<(), SketchError>

Add value to the aggregator.

Returns SketchError if the aggregator is of different type than bytes. See HyperLogLogPlusPlusBuilder::build_for_bytes.

Source

pub fn add_string(&mut self, value: &str) -> Result<(), SketchError>

Add value to the aggregator.

Returns SketchError if the aggregator is of different type than string. See HyperLogLogPlusPlusBuilder::build_for_string.

Source

pub fn normal_precision(&self) -> i32

Returns the normal precision of the aggregator.

Source

pub fn sparse_precision(&self) -> i32

Returns the sparse precision of the aggregator.

Trait Implementations§

Source§

impl Aggregator<i64, HyperLogLogPlusPlus> for HyperLogLogPlusPlus

Source§

fn result(&self) -> Result<i64, SketchError>

Returns the aggregated result of this aggregator.
Source§

fn merge_aggregator( &mut self, other: HyperLogLogPlusPlus, ) -> Result<(), SketchError>

Merges the state from other aggregator to this one. Read more
Source§

fn merge_proto( &mut self, proto: AggregatorStateProto, ) -> Result<(), SketchError>

Merge the state from proto into this one. Read more
Source§

fn merge_bytes(&mut self, data: &[u8]) -> Result<(), SketchError>

Merges the stage from data into this one. Read more
Source§

fn num_values(&self) -> u64

Returns the total number of input values that this aggregator has seen.
Source§

fn serialize_to_bytes(self) -> Result<Vec<u8>, SketchError>

Returns the internal state of the aggregator as a serialized string. Read more
Source§

fn serialize_to_proto(self) -> Result<AggregatorStateProto, SketchError>

Returns the internal state of the aggregator as a protocol bugger. Read more
Source§

impl Clone for HyperLogLogPlusPlus

Source§

fn clone(&self) -> HyperLogLogPlusPlus

Returns a duplicate 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 HyperLogLogPlusPlus

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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, 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.