zhangxinyao88 commented on code in PR #232:
URL: https://github.com/apache/datasketches-rust/pull/232#discussion_r3899591562


##########
datasketches/src/cpc/sketch.rs:
##########
@@ -471,6 +472,35 @@ impl CpcSketch {
     }
 }
 
+impl fmt::Display for CpcSketch {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        let flavor = match self.flavor() {
+            Flavor::Empty => "Empty",
+            Flavor::Sparse => "Sparse",
+            Flavor::Hybrid => "Hybrid",
+            Flavor::Pinned => "Pinned",
+            Flavor::Sliding => "Sliding",
+        };

Review Comment:
   Updated this to use the existing `Debug` implementation for `Flavor`.



##########
datasketches/src/cpc/sketch.rs:
##########
@@ -471,6 +472,35 @@ impl CpcSketch {
     }
 }
 
+impl fmt::Display for CpcSketch {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        let flavor = match self.flavor() {
+            Flavor::Empty => "Empty",
+            Flavor::Sparse => "Sparse",
+            Flavor::Hybrid => "Hybrid",
+            Flavor::Pinned => "Pinned",
+            Flavor::Sliding => "Sliding",
+        };
+
+        writeln!(f, "CPC Sketch Summary:")?;
+        writeln!(f, "  flavor            : {flavor}")?;
+        writeln!(f, "  lg k              : {}", self.lg_k())?;
+        writeln!(f, "  merged            : {}", self.merge_flag)?;
+        writeln!(
+            f,
+            "  lower bound       : {}",
+            self.lower_bound(NumStdDev::One)

Review Comment:
   Good point. The Java HLL summary uses one standard deviation, but the Java 
CPC summary does not include bounds. I removed the CPC lower and upper bounds 
instead of introducing that choice here.



##########
datasketches/src/cpc/sketch.rs:
##########
@@ -471,6 +472,35 @@ impl CpcSketch {
     }
 }
 
+impl fmt::Display for CpcSketch {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        let flavor = match self.flavor() {
+            Flavor::Empty => "Empty",
+            Flavor::Sparse => "Sparse",
+            Flavor::Hybrid => "Hybrid",
+            Flavor::Pinned => "Pinned",
+            Flavor::Sliding => "Sliding",
+        };
+
+        writeln!(f, "CPC Sketch Summary:")?;
+        writeln!(f, "  flavor            : {flavor}")?;
+        writeln!(f, "  lg k              : {}", self.lg_k())?;
+        writeln!(f, "  merged            : {}", self.merge_flag)?;
+        writeln!(
+            f,
+            "  lower bound       : {}",
+            self.lower_bound(NumStdDev::One)
+        )?;
+        writeln!(f, "  estimate          : {}", self.estimate())?;
+        writeln!(
+            f,
+            "  upper bound       : {}",
+            self.upper_bound(NumStdDev::One)

Review Comment:
   Removed this together with the lower bound, since the Java CPC summary does 
not include either bound.



##########
tests-integration/tests/cpc_test/display.rs:
##########


Review Comment:
   Updated the exact `Display` assertions to use `insta` inline snapshots. I 
kept the populated cases as focused assertions so we do not snapshot estimator 
values unnecessarily.



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