diff options
Diffstat (limited to 'src/set/strata_estimator.h')
-rw-r--r-- | src/set/strata_estimator.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/set/strata_estimator.h b/src/set/strata_estimator.h index abc39f25a..9de5598bd 100644 --- a/src/set/strata_estimator.h +++ b/src/set/strata_estimator.h | |||
@@ -40,6 +40,9 @@ extern "C" | |||
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | 42 | ||
43 | /** | ||
44 | * A handle to a strata estimator. | ||
45 | */ | ||
43 | struct StrataEstimator | 46 | struct StrataEstimator |
44 | { | 47 | { |
45 | struct InvertibleBloomFilter **strata; | 48 | struct InvertibleBloomFilter **strata; |
@@ -48,31 +51,77 @@ struct StrataEstimator | |||
48 | }; | 51 | }; |
49 | 52 | ||
50 | 53 | ||
54 | /** | ||
55 | * Write the given strata estimator to the buffer. | ||
56 | * | ||
57 | * @param se strata estimator to serialize | ||
58 | * @param buf buffer to write to, must be of appropriate size | ||
59 | */ | ||
51 | void | 60 | void |
52 | strata_estimator_write (const struct StrataEstimator *se, void *buf); | 61 | strata_estimator_write (const struct StrataEstimator *se, void *buf); |
53 | 62 | ||
54 | 63 | ||
64 | /** | ||
65 | * Read strata from the buffer into the given strata | ||
66 | * estimator. The strata estimator must already be allocated. | ||
67 | * | ||
68 | * @param buf buffer to read from | ||
69 | * @param se strata estimator to write to | ||
70 | */ | ||
55 | void | 71 | void |
56 | strata_estimator_read (const void *buf, struct StrataEstimator *se); | 72 | strata_estimator_read (const void *buf, struct StrataEstimator *se); |
57 | 73 | ||
58 | 74 | ||
75 | /** | ||
76 | * Create a new strata estimator with the given parameters. | ||
77 | * | ||
78 | * @param strata_count number of stratas, that is, number of ibfs in the estimator | ||
79 | * @param ibf_size size of each ibf stratum | ||
80 | * @param ibf_hashnum hashnum parameter of each ibf | ||
81 | * @return a freshly allocated, empty strata estimator | ||
82 | */ | ||
59 | struct StrataEstimator * | 83 | struct StrataEstimator * |
60 | strata_estimator_create (unsigned int strata_count, uint32_t ibf_size, uint8_t ibf_hashnum); | 84 | strata_estimator_create (unsigned int strata_count, uint32_t ibf_size, uint8_t ibf_hashnum); |
61 | 85 | ||
62 | 86 | ||
87 | /** | ||
88 | * Get an estimation of the symmetric difference of the elements | ||
89 | * contained in both strata estimators. | ||
90 | * | ||
91 | * @param se1 first strata estimator | ||
92 | * @param se2 second strata estimator | ||
93 | * @return abs(|se1| - |se2|) | ||
94 | */ | ||
63 | unsigned int | 95 | unsigned int |
64 | strata_estimator_difference (const struct StrataEstimator *se1, | 96 | strata_estimator_difference (const struct StrataEstimator *se1, |
65 | const struct StrataEstimator *se2); | 97 | const struct StrataEstimator *se2); |
66 | 98 | ||
67 | 99 | ||
100 | /** | ||
101 | * Add a key to the strata estimator. | ||
102 | * | ||
103 | * @param se strata estimator to add the key to | ||
104 | * @param key key to add | ||
105 | */ | ||
68 | void | 106 | void |
69 | strata_estimator_insert (struct StrataEstimator *se, struct IBF_Key key); | 107 | strata_estimator_insert (struct StrataEstimator *se, struct IBF_Key key); |
70 | 108 | ||
71 | 109 | ||
110 | /** | ||
111 | * Remove a key from the strata estimator. | ||
112 | * | ||
113 | * @param se strata estimator to remove the key from | ||
114 | * @param key key to remove | ||
115 | */ | ||
72 | void | 116 | void |
73 | strata_estimator_remove (struct StrataEstimator *se, struct IBF_Key key); | 117 | strata_estimator_remove (struct StrataEstimator *se, struct IBF_Key key); |
74 | 118 | ||
75 | 119 | ||
120 | /** | ||
121 | * Destroy a strata estimator, free all of its resources. | ||
122 | * | ||
123 | * @param se strata estimator to destroy. | ||
124 | */ | ||
76 | void | 125 | void |
77 | strata_estimator_destroy (struct StrataEstimator *se); | 126 | strata_estimator_destroy (struct StrataEstimator *se); |
78 | 127 | ||