tisonkun commented on code in PR #1: URL: https://github.com/apache/datasketches-rust/pull/1#discussion_r2617066669
########## src/hll/array6.rs: ########## @@ -0,0 +1,394 @@ +// 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 Array6 mode - 6-bit packed representation +//! +//! Array6 stores HLL register values using 6 bits per slot, providing a range of 0-63. +//! This is sufficient for most HLL use cases without needing exception handling or +//! cur_min optimization like Array4. + +use crate::hll::estimator::HipEstimator; +use crate::hll::{get_slot, get_value}; + +const VAL_MASK_6: u16 = 0x3F; // 6 bits: 0b0011_1111 + +/// Core Array6 data structure - stores 6-bit values with cross-byte packing +#[derive(Debug, Clone)] +pub struct Array6 { + lg_config_k: u8, + /// Packed 6-bit values, may cross byte boundaries + bytes: Box<[u8]>, + /// Count of slots with value 0 + num_zeros: u32, + /// HIP estimator for cardinality estimation + estimator: HipEstimator, +} + +impl PartialEq for Array6 { + fn eq(&self, other: &Self) -> bool { + self.lg_config_k == other.lg_config_k + && self.num_zeros == other.num_zeros + && self.bytes.as_ref() == other.bytes.as_ref() + && self.estimator == other.estimator + } +} Review Comment: Several trivial PartialEq impls can be replaced with `#[derive(PartialEq)]`. Here is a patch that you can make use of. `git am 0001-Derive-PartialEq-when-it-is-trivial.patch` would apply in one hit without manually redo. [0001-Derive-PartialEq-when-it-is-trivial.patch](https://github.com/user-attachments/files/24150130/0001-Derive-PartialEq-when-it-is-trivial.patch) -- 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]
