tisonkun commented on code in PR #23:
URL: https://github.com/apache/datasketches-rust/pull/23#discussion_r2623730274


##########
src/tdigest/serialization.rs:
##########
@@ -17,6 +41,45 @@ impl TDigest {
         });
         bytes.push(SERIAL_VERSION);
         bytes.push(TDIGEST_FAMILY_ID);
+        LE::write_u16(&mut bytes, self.k);
+        bytes.push({
+            let mut flags = 0;
+            if self.is_empty() {
+                flags |= FLAGS_IS_EMPTY;
+            }
+            if self.is_single_value() {
+                flags |= FLAGS_IS_SINGLE_VALUE;
+            }
+            if self.reverse_merge {
+                flags |= FLAGS_REVERSE_MERGE;
+            }
+            flags
+        });
+        LE::write_u16(&mut bytes, 0); // unused
+        if self.is_empty() {
+            return bytes;
+        }
+        if self.is_single_value() {
+            LE::write_f64(&mut bytes, self.min);
+            return bytes;
+        }
+        LE::write_u32(&mut bytes, self.centroids.len() as u32);

Review Comment:
   Totally get it wrong.
   
       let x = u16::MAX as u64 * 2 + 10;
       let y = u32::MAX as u64;
       println!("x: {}, y: {}, x < y: {}", x, y, x < y);
   
   Gives: "x: 131080, y: 4294967295, x < y: true".
   
   Never exceeded.



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