pub struct HyperLogLog8<T, H, const BETA: bool = true> { /* private fields */ }Expand description
Estimation logic implementing the HyperLogLog algorithm with byte-sized registers.
This implementation uses a full byte for each register instead of packed 5–
or 6-bit registers. This approach trades 60% (for 5-bit registers) or 33.3%
(for 6-bit registers) extra space with respect to
HyperLogLog for:
- fast register access (byte indexing instead of bit-field extraction);
- no backend alignment constraints;
- SIMD-accelerated merge using platform-specific byte-wise maximum
instructions (SSE2 on
x86/x86_64, NEON onaarch64); - no temporary allocations for merge operations.
The choice between the two logics should be guided by the specific use case and constraints of your application. Please try the included benchmarks to have an idea of the difference in performance between the two logics in your environment.
Instances are created through HyperLogLog8Builder:
// Default: LogLog-β correction enabled
let logic = HyperLogLog8Builder::new()
.log2_num_regs(8)
.build::<String>();
// Disable LogLog-β, use classic HLL + linear-counting fallback
let logic = HyperLogLog8Builder::new()
.log2_num_regs(8)
.beta::<false>()
.build::<String>();§Type parameters
-
T: the type of elements to count (must implementHash). -
H: theBuildHasherused to hash elements. -
BETA: whentrue(the default), the LogLog-β bias correction is used during estimation. SeeHyperLogLogfor details.
Implementations§
Source§impl<T, H: Clone, const BETA: bool> HyperLogLog8<T, H, BETA>
impl<T, H: Clone, const BETA: bool> HyperLogLog8<T, H, BETA>
Sourcepub fn log2_num_regs(&self) -> u32
pub fn log2_num_regs(&self) -> u32
Returns the base-2 logarithm of the number of registers per estimator.
Trait Implementations§
Source§impl<T, H, const BETA: bool> Display for HyperLogLog8<T, H, BETA>
impl<T, H, const BETA: bool> Display for HyperLogLog8<T, H, BETA>
Source§impl<T: Hash, H: BuildHasher + Clone, const BETA: bool> EstimationLogic for HyperLogLog8<T, H, BETA>
impl<T: Hash, H: BuildHasher + Clone, const BETA: bool> EstimationLogic for HyperLogLog8<T, H, BETA>
Source§type Estimator<'a> = DefaultEstimator<HyperLogLog8<T, H, BETA>, &'a HyperLogLog8<T, H, BETA>, Box<[u8]>>
where
T: 'a,
H: 'a
type Estimator<'a> = DefaultEstimator<HyperLogLog8<T, H, BETA>, &'a HyperLogLog8<T, H, BETA>, Box<[u8]>> where T: 'a, H: 'a
Source§fn new_estimator(&self) -> Self::Estimator<'_>
fn new_estimator(&self) -> Self::Estimator<'_>
Source§fn add(&self, backend: &mut Self::Backend, element: impl Borrow<T>)
fn add(&self, backend: &mut Self::Backend, element: impl Borrow<T>)
Source§impl<T: Hash, H: BuildHasher + Clone, const BETA: bool> MergeEstimationLogic for HyperLogLog8<T, H, BETA>
impl<T: Hash, H: BuildHasher + Clone, const BETA: bool> MergeEstimationLogic for HyperLogLog8<T, H, BETA>
Source§fn new_helper(&self) -> Self::Helper
fn new_helper(&self) -> Self::Helper
Source§impl<T: Hash, H: BuildHasher + Clone, const BETA: bool> SliceEstimationLogic<u8> for HyperLogLog8<T, H, BETA>
impl<T: Hash, H: BuildHasher + Clone, const BETA: bool> SliceEstimationLogic<u8> for HyperLogLog8<T, H, BETA>
Source§fn backend_len(&self) -> usize
fn backend_len(&self) -> usize
T in a backend.