#[repr(transparent)]
pub struct HyperLogLogArray<const PRECISION: usize, const BITS: usize, const N: usize> { /* private fields */ }

Implementations§

source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> HyperLogLogArray<PRECISION, BITS, N>

source

pub fn new() -> Self

Creates a new HyperLogLogArray with the given precision and number of bits.

Example
#![feature(generic_const_exprs)]
use hyperloglog_rs::prelude::*;

let hll_array = HyperLogLogArray::<12, 6, 3>::new();
source

pub fn estimate_overlap_cardinalities(&self, other: &Self) -> [[f32; N]; N]

Returns the estimated overlap cardinality matrices with the provided HyperLogLogArray.

Arguments
  • other: The HyperLogLogArray to estimate the overlap cardinality matrices with.
Returns

The estimated overlap cardinality matrices with the provided HyperLogLogArray.

source

pub fn estimated_difference_cardinality_vector( &self, other: &HyperLogLog<PRECISION, BITS> ) -> [f32; N]

Returns the estimated difference cardinality matrices with the provided HyperLogLog.

Arguments
  • other: The HyperLogLog to estimate the difference cardinality matrices with.
Returns

The estimated difference cardinality matrices with the provided HyperLogLogArray.

source

pub fn estimated_overlap_and_differences_cardinality_matrices( &self, other: &Self ) -> ([[f32; N]; N], [f32; N], [f32; N])

Returns the estimated overlap and difference cardinality matrices and vectors with the provided HyperLogLogArray.

Arguments
  • other: The HyperLogLogArray to estimate the overlap and difference cardinality matrices and vectors with.
Returns

The estimated overlap and difference cardinality matrices and vectors with the provided HyperLogLogArray.

Trait Implementations§

source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> AsMut<[HyperLogLog<PRECISION, BITS>; N]> for HyperLogLogArray<PRECISION, BITS, N>

source§

fn as_mut(&mut self) -> &mut [HyperLogLog<PRECISION, BITS>; N]

Returns a mutable reference to the underlying array of HyperLogLog counters.

Returns

A mutable reference to the underlying array of HyperLogLog counters.

source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> AsRef<[HyperLogLog<PRECISION, BITS>; N]> for HyperLogLogArray<PRECISION, BITS, N>

source§

fn as_ref(&self) -> &[HyperLogLog<PRECISION, BITS>; N]

Returns a reference to the underlying array of HyperLogLog counters.

Returns

A reference to the underlying array of HyperLogLog counters.

source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> Clone for HyperLogLogArray<PRECISION, BITS, N>

source§

fn clone(&self) -> HyperLogLogArray<PRECISION, BITS, N>

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<const PRECISION: usize, const BITS: usize, const N: usize> Debug for HyperLogLogArray<PRECISION, BITS, N>

source§

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

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

impl<const PRECISION: usize, const BITS: usize, const N: usize> Default for HyperLogLogArray<PRECISION, BITS, N>

source§

fn default() -> Self

Creates a new HyperLogLogArray with the given precision and number of bits.

Returns

A new HyperLogLogArray with the given precision and number of bits.

Example
#![feature(generic_const_exprs)]
use hyperloglog_rs::prelude::*;

let hll_array = HyperLogLogArray::<12, 6, 3>::default();
source§

impl<'de, const PRECISION: usize, const BITS: usize, const N: usize> Deserialize<'de> for HyperLogLogArray<PRECISION, BITS, N>

source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserializes the HyperLogLog counter using the given deserializer.

This method is part of the Deserialize trait implementation for the HyperLogLog struct, allowing the counter to be deserialized from a format supported by the deserializer.

Arguments
  • deserializer: The deserializer used to deserialize the HyperLogLog counter.
Returns

The deserialization result, indicating success or failure.

source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> Index<usize> for HyperLogLogArray<PRECISION, BITS, N>

source§

fn index(&self, index: usize) -> &Self::Output

Returns a reference to the HyperLogLog counter at the given index.

Arguments
  • index: The index of the HyperLogLog counter to return.
Returns

A reference to the HyperLogLog counter at the given index.

Panics

Panics if the index is out of bounds.

Example
#![feature(generic_const_exprs)]
use hyperloglog_rs::prelude::*;

let mut hll_array = HyperLogLogArray::<12, 6, 4>::new();
hll_array[0].insert(&1);
hll_array[1].insert(&2);
hll_array[2].insert(&3);

assert!(hll_array[0].estimate_cardinality() > 0.9
    && hll_array[1].estimate_cardinality() < 1.1
);
assert!(hll_array[1].estimate_cardinality() > 0.9
   && hll_array[1].estimate_cardinality() < 1.1
);
assert!(hll_array[2].estimate_cardinality() > 0.9
  && hll_array[2].estimate_cardinality() < 1.1
);
assert!(hll_array[3].estimate_cardinality() > -0.1
 && hll_array[3].estimate_cardinality() < 0.1
);
§

type Output = HyperLogLog<PRECISION, BITS>

The returned type after indexing.
source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> IndexMut<usize> for HyperLogLogArray<PRECISION, BITS, N>

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Returns a mutable reference to the HyperLogLog counter at the given index.

Arguments
  • index: The index of the HyperLogLog counter to return.
Returns

A mutable reference to the HyperLogLog counter at the given index.

Panics

Panics if the index is out of bounds.

Example
#![feature(generic_const_exprs)]
use hyperloglog_rs::prelude::*;

let mut hll_array = HyperLogLogArray::<12, 6, 4>::new();
hll_array[0].insert(&1);
hll_array[1].insert(&2);
hll_array[2].insert(&3);

assert!(hll_array[0].estimate_cardinality() > 0.9
   && hll_array[1].estimate_cardinality() < 1.1
);
assert!(hll_array[1].estimate_cardinality() > 0.9
 && hll_array[1].estimate_cardinality() < 1.1
);
assert!(hll_array[2].estimate_cardinality() > 0.9
&& hll_array[2].estimate_cardinality() < 1.1
);
assert!(hll_array[3].estimate_cardinality() > -0.1
&& hll_array[3].estimate_cardinality() < 0.1
);
source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> PartialEq<HyperLogLogArray<PRECISION, BITS, N>> for HyperLogLogArray<PRECISION, BITS, N>

source§

fn eq(&self, other: &HyperLogLogArray<PRECISION, BITS, N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> Serialize for HyperLogLogArray<PRECISION, BITS, N>

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serializes the HyperLogLog counter using the given serializer.

This method is part of the Serialize trait implementation for the HyperLogLog struct, allowing the counter to be serialized into a format supported by the serializer.

Arguments
  • serializer: The serializer used to serialize the HyperLogLog counter.
Returns

The serialization result, indicating success or failure.

Example

In this example, we serialize an array of HyperLogLog counters into a JSON string. The resulting string is then deserialized back into an array of HyperLogLog counters.

Since we cannot implement these traits for array, we need to wrap the array in a struct, which in this case is HyperLogLogArray.

#![feature(generic_const_exprs)]
use serde::Serialize;
use serde_json::Serializer;
use hyperloglog_rs::prelude::*;

let mut hll_array = HyperLogLogArray::<12, 6, 3>::new();
hll_array[0].insert(&1);
hll_array[1].insert(&2);
hll_array[2].insert(&3);
let mut serializer = Serializer::new(Vec::new());
let result = hll_array.serialize(&mut serializer);
assert!(result.is_ok(), "Serialization failed, error: {:?}", result.err());
let hll_array_str = String::from_utf8(serializer.into_inner()).unwrap();
let hll_array_deserialized = serde_json::from_str(&hll_array_str);
assert!(hll_array_deserialized.is_ok(), "Deserialization failed, error: {:?}", hll_array_deserialized.err());
let hll_array_deserialized = hll_array_deserialized.unwrap();
assert_eq!(hll_array, hll_array_deserialized, "Deserialized array does not match original array");
source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> Copy for HyperLogLogArray<PRECISION, BITS, N>

source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> Eq for HyperLogLogArray<PRECISION, BITS, N>

source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> StructuralEq for HyperLogLogArray<PRECISION, BITS, N>

source§

impl<const PRECISION: usize, const BITS: usize, const N: usize> StructuralPartialEq for HyperLogLogArray<PRECISION, BITS, N>

Auto Trait Implementations§

§

impl<const PRECISION: usize, const BITS: usize, const N: usize> RefUnwindSafe for HyperLogLogArray<PRECISION, BITS, N>

§

impl<const PRECISION: usize, const BITS: usize, const N: usize> Send for HyperLogLogArray<PRECISION, BITS, N>

§

impl<const PRECISION: usize, const BITS: usize, const N: usize> Sync for HyperLogLogArray<PRECISION, BITS, N>

§

impl<const PRECISION: usize, const BITS: usize, const N: usize> Unpin for HyperLogLogArray<PRECISION, BITS, N>

§

impl<const PRECISION: usize, const BITS: usize, const N: usize> UnwindSafe for HyperLogLogArray<PRECISION, BITS, N>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,