File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ #[ cfg( feature = "with_serde" ) ]
2
+ fn main ( ) {
3
+ let mut estimator =
4
+ cardinality_estimator:: CardinalityEstimator :: < usize , wyhash:: WyHash , 8 , 5 > :: new ( ) ;
5
+
6
+ println ! (
7
+ "serialized empty estimator (small): {}" ,
8
+ serde_json:: to_string_pretty( & estimator) . unwrap( )
9
+ ) ;
10
+
11
+ estimator. insert ( & 0 ) ;
12
+
13
+ println ! (
14
+ "serialized with one insert (small): {}" ,
15
+ serde_json:: to_string_pretty( & estimator) . unwrap( )
16
+ ) ;
17
+
18
+ estimator. insert ( & 1 ) ;
19
+ estimator. insert ( & 2 ) ;
20
+
21
+ println ! (
22
+ "serialized with three inserts (array): {}" ,
23
+ serde_json:: to_string_pretty( & estimator) . unwrap( )
24
+ ) ;
25
+
26
+ for i in 3 ..1000 {
27
+ estimator. insert ( & i) ;
28
+ }
29
+
30
+ println ! (
31
+ "serialized with many inserts (HLL): {}" ,
32
+ serde_json:: to_string_pretty( & estimator) . unwrap( )
33
+ ) ;
34
+ }
35
+
36
+ #[ cfg( not( feature = "with_serde" ) ) ]
37
+ fn main ( ) -> Result < ( ) , u32 > {
38
+ eprintln ! ( "this example requires --features with_serde" ) ;
39
+ Err ( 1 )
40
+ }
You can’t perform that action at this time.
0 commit comments