Copilot commented on code in PR #91:
URL: https://github.com/apache/datasketches-rust/pull/91#discussion_r2804954099


##########
datasketches/src/codec/family.rs:
##########
@@ -0,0 +1,94 @@
+// 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 crate::error::Error;
+
+/// Defines the various families of sketch and set operation classes.
+///
+/// A family defines a set of classes that share fundamental algorithms and 
behaviors. The classes
+/// within a family may still differ by how they are stored and accessed.
+#[allow(dead_code)] // min_pre_longs and max_pre_longs are not used yet
+pub struct Family {
+    /// The byte ID for this family.
+    pub id: u8,
+    /// The name for this family.
+    pub name: &'static str,
+    /// The minimum preamble size for this family in longs (8-bytes integer).
+    pub min_pre_longs: u8,
+    /// The maximum preamble size for this family in longs (8-bytes integer).
+    pub max_pre_longs: u8,
+}
+
+impl Family {
+    /// The HLL family of sketches.
+    pub const HLL: Family = Family {
+        id: 7,
+        name: "HLL",
+        min_pre_longs: 1,
+        max_pre_longs: 1,
+    };
+
+    /// The Frequency family of sketches.
+    pub const FREQUENCY: Family = Family {
+        id: 10,
+        name: "FREQUENCY",
+        min_pre_longs: 1,
+        max_pre_longs: 4,
+    };
+
+    /// Compressed Probabilistic Counting (CPC) Sketch.
+    pub const CPC: Family = Family {
+        id: 16,
+        name: "CPC",
+        min_pre_longs: 1,
+        max_pre_longs: 5,
+    };
+
+    /// CountMin Sketch
+    pub const COUNTMIN: Family = Family {
+        id: 17,
+        name: "COUNTMIN",
+        min_pre_longs: 2,
+        max_pre_longs: 2,
+    };
+
+    /// T-Digest for estimating quantiles and ranks.
+    pub const TDIGEST: Family = Family {
+        id: 20,
+        name: "TDIGEST",
+        min_pre_longs: 1,
+        max_pre_longs: 2,
+    };
+
+    /// Bloom Filter.
+    pub const BLOOMFILTER: Family = Family {
+        id: 21,
+        name: "BLOOMFILTER",
+        min_pre_longs: 3,
+        max_pre_longs: 4,
+    };

Review Comment:
   `Family::BLOOMFILTER.id` is 24, but BloomFilter serialization previously 
used family ID 21. This will make the crate unable to deserialize Java/C++ 
generated Bloom filters and will change the bytes produced by `serialize()`. 
Please update the family ID to the correct value used by the DataSketches wire 
format.



##########
datasketches/src/codec/family.rs:
##########
@@ -0,0 +1,94 @@
+// 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 crate::error::Error;
+
+/// Defines the various families of sketch and set operation classes.
+///
+/// A family defines a set of classes that share fundamental algorithms and 
behaviors. The classes
+/// within a family may still differ by how they are stored and accessed.
+#[allow(dead_code)] // min_pre_longs and max_pre_longs are not used yet
+pub struct Family {
+    /// The byte ID for this family.
+    pub id: u8,
+    /// The name for this family.
+    pub name: &'static str,
+    /// The minimum preamble size for this family in longs (8-bytes integer).
+    pub min_pre_longs: u8,
+    /// The maximum preamble size for this family in longs (8-bytes integer).
+    pub max_pre_longs: u8,
+}
+
+impl Family {
+    /// The HLL family of sketches.
+    pub const HLL: Family = Family {
+        id: 7,
+        name: "HLL",
+        min_pre_longs: 1,
+        max_pre_longs: 1,
+    };
+
+    /// The Frequency family of sketches.
+    pub const FREQUENCY: Family = Family {
+        id: 10,
+        name: "FREQUENCY",
+        min_pre_longs: 1,
+        max_pre_longs: 4,
+    };
+
+    /// Compressed Probabilistic Counting (CPC) Sketch.
+    pub const CPC: Family = Family {
+        id: 16,
+        name: "CPC",
+        min_pre_longs: 1,
+        max_pre_longs: 5,
+    };
+
+    /// CountMin Sketch
+    pub const COUNTMIN: Family = Family {
+        id: 17,
+        name: "COUNTMIN",
+        min_pre_longs: 2,
+        max_pre_longs: 2,
+    };

Review Comment:
   `Family::COUNTMIN.id` is set to 17, but CountMin previously 
serialized/deserialized using family ID 18. This changes the on-wire format and 
will break backwards compatibility for persisted sketches and any 
cross-language compatibility. Please confirm the correct DataSketches family ID 
and update this constant (or keep the previous value if this is intended to be 
a pure refactor).



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