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
impl HyperLogLogPlusPlus
Sourcepub const MINIMUM_PRECISION: i32 = 10i32
pub const MINIMUM_PRECISION: i32 = 10i32
The smallest normal precision supported by this aggregator.
Sourcepub const MAXIMUM_PRECISION: i32 = 24i32
pub const MAXIMUM_PRECISION: i32 = 24i32
The largest normal precision supported by this aggregator.
Sourcepub const DEFAULT_NORMAL_PRECISION: i32 = 15i32
pub const DEFAULT_NORMAL_PRECISION: i32 = 15i32
The default normal precision that is used if the user does not specify a normal precision.
Sourcepub const MAXIMUM_SPARSE_PRECISION: i32 = 25i32
pub const MAXIMUM_SPARSE_PRECISION: i32 = 25i32
The largest sparse precision supported by this aggregator.
Sourcepub const SPARSE_PRECISION_DISABLED: i32 = 0i32
pub const SPARSE_PRECISION_DISABLED: i32 = 0i32
Value used to indicate that the sparse representation should not be used.
Sourcepub const DEFAULT_SPARSE_PRECISION_DELTA: i32 = 5i32
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.
Sourcepub const ENCODING_VERSION: i32 = 2i32
pub const ENCODING_VERSION: i32 = 2i32
The encoding version of the AggregatorStateProto. We only support v2.
Sourcepub fn builder() -> HyperLogLogPlusPlusBuilder
pub fn builder() -> HyperLogLogPlusPlusBuilder
Returns a new builder to customize and create a new instance of this aggregator.
Sourcepub fn from_proto(proto: AggregatorStateProto) -> Result<Self, SketchError>
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.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, SketchError>
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.
Sourcepub fn add_i32(&mut self, value: i32) -> Result<(), SketchError>
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.
Sourcepub fn add_u32(&mut self, value: u32) -> Result<(), SketchError>
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.
Sourcepub fn add_i64(&mut self, value: i64) -> Result<(), SketchError>
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.
Sourcepub fn add_u64(&mut self, value: u64) -> Result<(), SketchError>
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.
Sourcepub fn add_bytes(&mut self, value: &[u8]) -> Result<(), SketchError>
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.
Sourcepub fn add_string(&mut self, value: &str) -> Result<(), SketchError>
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.
Sourcepub fn normal_precision(&self) -> i32
pub fn normal_precision(&self) -> i32
Returns the normal precision of the aggregator.
Sourcepub fn sparse_precision(&self) -> i32
pub fn sparse_precision(&self) -> i32
Returns the sparse precision of the aggregator.
Trait Implementations§
Source§impl Aggregator<i64, HyperLogLogPlusPlus> for HyperLogLogPlusPlus
impl Aggregator<i64, HyperLogLogPlusPlus> for HyperLogLogPlusPlus
Source§fn result(&self) -> Result<i64, SketchError>
fn result(&self) -> Result<i64, SketchError>
Source§fn merge_aggregator(
&mut self,
other: HyperLogLogPlusPlus,
) -> Result<(), SketchError>
fn merge_aggregator( &mut self, other: HyperLogLogPlusPlus, ) -> Result<(), SketchError>
other aggregator to this one. Read moreSource§fn merge_proto(
&mut self,
proto: AggregatorStateProto,
) -> Result<(), SketchError>
fn merge_proto( &mut self, proto: AggregatorStateProto, ) -> Result<(), SketchError>
proto into this one. Read moreSource§fn merge_bytes(&mut self, data: &[u8]) -> Result<(), SketchError>
fn merge_bytes(&mut self, data: &[u8]) -> Result<(), SketchError>
data into this one. Read moreSource§fn num_values(&self) -> u64
fn num_values(&self) -> u64
Source§fn serialize_to_bytes(self) -> Result<Vec<u8>, SketchError>
fn serialize_to_bytes(self) -> Result<Vec<u8>, SketchError>
Source§fn serialize_to_proto(self) -> Result<AggregatorStateProto, SketchError>
fn serialize_to_proto(self) -> Result<AggregatorStateProto, SketchError>
Source§impl Clone for HyperLogLogPlusPlus
impl Clone for HyperLogLogPlusPlus
Source§fn clone(&self) -> HyperLogLogPlusPlus
fn clone(&self) -> HyperLogLogPlusPlus
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for HyperLogLogPlusPlus
impl RefUnwindSafe for HyperLogLogPlusPlus
impl Send for HyperLogLogPlusPlus
impl Sync for HyperLogLogPlusPlus
impl Unpin for HyperLogLogPlusPlus
impl UnwindSafe for HyperLogLogPlusPlus
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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