@@ -27,8 +27,9 @@ sketches-rust = "0.2.1"
2727```
2828
2929# Demos
30+ Query quantile:
3031``` rust
31- // query quantile
32+ use sketches_rust :: DDSketch ;
3233 let mut d = DDSketch :: collapsing_lowest_dense (0.02 ,100 ). unwrap ();
3334 d . accept (1.0 );
3435 d . accept (2.0 );
@@ -37,9 +38,11 @@ sketches-rust = "0.2.1"
3738 assert_eq! (c , 3.0 );
3839 let q = d . get_value_at_quantile (0.5 ). unwrap ();
3940 assert! (q < 2.01 && q > 1.99 );
41+ ```
4042
41-
42- // merge with other instance
43+ Merge with other instance:
44+ ``` rust
45+ use sketches_rust :: DDSketch ;
4346 let mut d1 = DDSketch :: collapsing_lowest_dense (0.02 ,100 ). unwrap ();
4447 d1 . accept (1.0 );
4548 d1 . accept (2.0 );
@@ -52,8 +55,11 @@ sketches-rust = "0.2.1"
5255 assert_eq! (3.0 , d2 . get_count ());
5356 d2 . merge_with (& mut d1 ). unwrap ();
5457 assert_eq! (6.0 , d2 . get_count ());
58+ ```
5559
56- // serialize to bytes:
60+ Serialize to bytes:
61+ ``` rust
62+ use sketches_rust :: DDSketch ;
5763 let mut d = DDSketch :: unbounded_dense (2e - 2 ). unwrap ();
5864 d . accept (1.0 );
5965 d . accept (2.0 );
@@ -62,7 +68,11 @@ sketches-rust = "0.2.1"
6268 d . accept (5.0 );
6369 println! (" encode: {:?}" , d . encode (). unwrap ());
6470
65- // deserialize from bytes
71+ ```
72+
73+ Deserialize from bytes:
74+ ``` rust
75+ use sketches_rust :: DDSketch ;
6676 let mut input = vec! [
6777 2 , 42 , 120 , 57 , 5 , 47 , 167 , 240 , 63 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 13 , 50 , 130 , 1 , 2 , 136 , 32 , 0 ,
6878 3 , 0 , 0 , 0 , 3 , 0 , 2 , 0 , 0 , 3 , 3 , 2 , 2 , 3 , 3 , 2 , 0 , 0 , 0 , 0 , 2 , 0 , 2 , 2 , 2 , 4 , 4 , 132 , 64 ,
0 commit comments