ZENOTME commented on code in PR #138:
URL: https://github.com/apache/datasketches-rust/pull/138#discussion_r3530833211


##########
datasketches/src/tuple/hash_table.rs:
##########
@@ -0,0 +1,780 @@
+// 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.
+
+use std::hash::Hash;
+
+use crate::common::ResizeFactor;
+use crate::hash::MurmurHash3X64128;
+use crate::hash::compute_seed_hash;
+use crate::theta::HASH_TABLE_REBUILD_THRESHOLD;
+use crate::theta::HASH_TABLE_RESIZE_THRESHOLD;
+use crate::theta::MAX_THETA;
+use crate::theta::MIN_LG_K;
+use crate::theta::STRIDE_MASK;
+use crate::theta::starting_sub_multiple;
+use crate::theta::starting_theta_from_sampling_probability;
+
+/// A retained entry: a hash key together with its associated summary.
+#[derive(Debug)]
+struct TupleEntry<S> {
+    hash: u64,
+    summary: S,
+}
+
+/// Specific hash table for tuple sketch.
+///
+/// This is the Theta sketch hash table extended so that each retained key 
carries a user-defined
+/// summary. It maintains an array with capacity up to 2^lg_max_size:
+/// * Before it reaches the max capacity, it will extend the array based on 
resize_factor.
+/// * After it reaches the capacity bigger than 2^lg_nom_size, every time the 
number of entries
+///   exceeds the threshold, it will rebuild the table: only keep the min 
2^lg_nom_size entries and
+///   update the theta to the k-th smallest entry.
+///
+/// Unlike the Theta hash table, when a key is inserted that already exists, 
the incoming update is
+/// merged into the existing summary rather than discarded.
+#[derive(Debug)]
+pub(super) struct TupleHashTable<S> {

Review Comment:
   Since this hash table is same as `ThetaHashTable`. Like cpp, maybe we should 
refactor it to use Generics type and avoid duplicate implementation.



-- 
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]

Reply via email to