ZENOTME commented on code in PR #336:
URL: https://github.com/apache/datasketches-rust/pull/336#discussion_r4511068898
##########
datasketches/src/thetafamily/theta/serialization.rs:
##########
@@ -26,3 +33,49 @@ pub const EMPTY_SKETCH_BYTES: [u8; 8] = [1, 3, 3, 0, 0,
0x1e, 0, 0];
pub const V2_PREAMBLE_EMPTY: u8 = 1;
pub const V2_PREAMBLE_PRECISE: u8 = 2;
pub const V2_PREAMBLE_ESTIMATE: u8 = 3;
+
+pub(super) fn serialize_uncompressed<E>(
+ state: &CompactSketchState<E>,
+ hash: impl Fn(&E) -> u64,
+) -> Vec<u8> {
+ if state.is_empty() {
+ return EMPTY_SKETCH_BYTES.to_vec();
+ }
+
+ let entries = state.retained_entries();
+ let pre_longs = if state.is_estimation_mode() {
Review Comment:
Better extract `preamble_longs` as before
##########
datasketches/src/thetafamily/tuple/serialization.rs:
##########
@@ -43,6 +51,60 @@ pub const SKETCH_TYPE_LEGACY: u8 = 5;
/// Canonical empty compact image, independent of the configured seed and
summary type.
pub const EMPTY_SKETCH_BYTES: [u8; 8] = [1, 3, 9, 1, 0, 0x1e, 0, 0];
+/// Serializes compact Tuple state whose retained entries are owned or
borrowed.
+pub(super) fn serialize_compact_state<S, E>(compact_state:
&CompactSketchState<E>) -> Vec<u8>
Review Comment:
I can't get the meaning of the name `serialize_compact_state` and
`serialize_uncompressed`. Looks like the diff is how they serialize entry.
Maybe need to refine.
##########
datasketches/src/thetafamily/theta/serialization.rs:
##########
@@ -26,3 +33,49 @@ pub const EMPTY_SKETCH_BYTES: [u8; 8] = [1, 3, 3, 0, 0,
0x1e, 0, 0];
pub const V2_PREAMBLE_EMPTY: u8 = 1;
pub const V2_PREAMBLE_PRECISE: u8 = 2;
pub const V2_PREAMBLE_ESTIMATE: u8 = 3;
+
+pub(super) fn serialize_uncompressed<E>(
+ state: &CompactSketchState<E>,
+ hash: impl Fn(&E) -> u64,
Review Comment:
How about
```
pub(super) fn serialize_uncompressed<E: SketchEntry>(
state: &CompactSketchState<E>,
) -> Vec<u8>
```
to omit `hash`
--
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]