tisonkun commented on code in PR #1: URL: https://github.com/apache/datasketches-rust/pull/1#discussion_r2616349960
########## src/hll/mod.rs: ########## @@ -0,0 +1,132 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! HyperLogLog sketch implementation for cardinality estimation. +//! +//! This module provides a probabilistic data structure for estimating the cardinality +//! (number of distinct elements) of large datasets with high accuracy and low memory usage. +//! +//! # Overview +//! +//! HyperLogLog (HLL) sketches use hash functions to estimate cardinality in logarithmic space. +//! This implementation follows the Apache DataSketches specification and supports multiple +//! storage modes that automatically adapt based on cardinality: +//! +//! - **List mode**: Stores individual coupons for small cardinalities +//! - **Set mode**: Uses a hash set for medium cardinalities +//! - **HLL mode**: Uses compact arrays for large cardinalities +//! +//! # HLL Types +//! +//! Three target HLL types are supported, trading precision for memory: +//! +//! - [`HllType::Hll4`]: 4 bits per bucket (most compact) +//! - [`HllType::Hll6`]: 6 bits per bucket (balanced) +//! - [`HllType::Hll8`]: 8 bits per bucket (highest precision) +//! +//! # Coupons +//! +//! A coupon is a 32-bit value encoding both a slot number (26 bits) and a value (6 bits). +//! The slot identifies which bucket to update, and the value represents the number of +//! leading zeros in the hash plus one. + +use std::hash::Hash; + +mod array4; +mod array6; +mod array8; +mod aux_map; +mod composite_interpolation; +mod container; +mod coupon_mapping; +mod cubic_interpolation; +mod estimator; +mod harmonic_numbers; +mod hash_set; +mod list; +mod serialization; +mod sketch; + +// Re-export public API +pub use sketch::HllSketch; + +/// Target HLL type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum HllType { + Hll4 = 0, + Hll6 = 1, + Hll8 = 2, +} Review Comment: I found some related description in module level document, so perhaps link it here like: ```rust /// See the [module level documentation](self) for more. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
