aboutsummaryrefslogtreecommitdiff
path: root/src/setu/gnunet-service-setu_strata_estimator.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/setu/gnunet-service-setu_strata_estimator.h')
-rw-r--r--src/setu/gnunet-service-setu_strata_estimator.h54
1 files changed, 42 insertions, 12 deletions
diff --git a/src/setu/gnunet-service-setu_strata_estimator.h b/src/setu/gnunet-service-setu_strata_estimator.h
index afdbcdbbf..4871a7fcd 100644
--- a/src/setu/gnunet-service-setu_strata_estimator.h
+++ b/src/setu/gnunet-service-setu_strata_estimator.h
@@ -22,6 +22,7 @@
22 * @file set/gnunet-service-setu_strata_estimator.h 22 * @file set/gnunet-service-setu_strata_estimator.h
23 * @brief estimator of set difference 23 * @brief estimator of set difference
24 * @author Florian Dold 24 * @author Florian Dold
25 * @author Elias Summermatter
25 */ 26 */
26 27
27#ifndef GNUNET_SERVICE_SETU_STRATA_ESTIMATOR_H 28#ifndef GNUNET_SERVICE_SETU_STRATA_ESTIMATOR_H
@@ -61,6 +62,31 @@ struct StrataEstimator
61 unsigned int ibf_size; 62 unsigned int ibf_size;
62}; 63};
63 64
65struct MultiStrataEstimator
66{
67 /**
68 * Array of strata estimators
69 */
70 struct StrataEstimator **stratas;
71
72 /**
73 * Number of strata estimators in struct
74 */
75 uint8_t size;
76
77};
78
79/**
80 * Deteminate how many strata estimators in the message are necessary
81 * @param avg_element_size
82 * @param element_count
83 * @return number of strata's
84 */
85
86uint8_t
87determine_strata_count (uint64_t avg_element_size,
88 uint64_t element_count);
89
64 90
65/** 91/**
66 * Write the given strata estimator to the buffer. 92 * Write the given strata estimator to the buffer.
@@ -70,7 +96,9 @@ struct StrataEstimator
70 * @return number of bytes written to @a buf 96 * @return number of bytes written to @a buf
71 */ 97 */
72size_t 98size_t
73strata_estimator_write (const struct StrataEstimator *se, 99strata_estimator_write (struct MultiStrataEstimator *se,
100 uint16_t se_ibf_total_size,
101 uint8_t number_se_send,
74 void *buf); 102 void *buf);
75 103
76 104
@@ -88,7 +116,9 @@ int
88strata_estimator_read (const void *buf, 116strata_estimator_read (const void *buf,
89 size_t buf_len, 117 size_t buf_len,
90 int is_compressed, 118 int is_compressed,
91 struct StrataEstimator *se); 119 uint8_t number_se_received,
120 uint16_t se_ibf_total_size,
121 struct MultiStrataEstimator *se);
92 122
93 123
94/** 124/**
@@ -99,7 +129,7 @@ strata_estimator_read (const void *buf,
99 * @param ibf_hashnum hashnum parameter of each ibf 129 * @param ibf_hashnum hashnum parameter of each ibf
100 * @return a freshly allocated, empty strata estimator, NULL on error 130 * @return a freshly allocated, empty strata estimator, NULL on error
101 */ 131 */
102struct StrataEstimator * 132struct MultiStrataEstimator *
103strata_estimator_create (unsigned int strata_count, 133strata_estimator_create (unsigned int strata_count,
104 uint32_t ibf_size, 134 uint32_t ibf_size,
105 uint8_t ibf_hashnum); 135 uint8_t ibf_hashnum);
@@ -111,11 +141,11 @@ strata_estimator_create (unsigned int strata_count,
111 * 141 *
112 * @param se1 first strata estimator 142 * @param se1 first strata estimator
113 * @param se2 second strata estimator 143 * @param se2 second strata estimator
114 * @return abs(|se1| - |se2|) 144 * @return nothing
115 */ 145 */
116unsigned int 146void
117strata_estimator_difference (const struct StrataEstimator *se1, 147strata_estimator_difference (const struct MultiStrataEstimator *se1,
118 const struct StrataEstimator *se2); 148 const struct MultiStrataEstimator *se2);
119 149
120 150
121/** 151/**
@@ -125,7 +155,7 @@ strata_estimator_difference (const struct StrataEstimator *se1,
125 * @param key key to add 155 * @param key key to add
126 */ 156 */
127void 157void
128strata_estimator_insert (struct StrataEstimator *se, 158strata_estimator_insert (struct MultiStrataEstimator *se,
129 struct IBF_Key key); 159 struct IBF_Key key);
130 160
131 161
@@ -136,7 +166,7 @@ strata_estimator_insert (struct StrataEstimator *se,
136 * @param key key to remove 166 * @param key key to remove
137 */ 167 */
138void 168void
139strata_estimator_remove (struct StrataEstimator *se, 169strata_estimator_remove (struct MultiStrataEstimator *se,
140 struct IBF_Key key); 170 struct IBF_Key key);
141 171
142 172
@@ -146,7 +176,7 @@ strata_estimator_remove (struct StrataEstimator *se,
146 * @param se strata estimator to destroy. 176 * @param se strata estimator to destroy.
147 */ 177 */
148void 178void
149strata_estimator_destroy (struct StrataEstimator *se); 179strata_estimator_destroy (struct MultiStrataEstimator *se);
150 180
151 181
152/** 182/**
@@ -155,8 +185,8 @@ strata_estimator_destroy (struct StrataEstimator *se);
155 * @param se the strata estimator to copy 185 * @param se the strata estimator to copy
156 * @return the copy 186 * @return the copy
157 */ 187 */
158struct StrataEstimator * 188struct MultiStrataEstimator *
159strata_estimator_dup (struct StrataEstimator *se); 189strata_estimator_dup (struct MultiStrataEstimator *se);
160 190
161 191
162#if 0 /* keep Emacsens' auto-indent happy */ 192#if 0 /* keep Emacsens' auto-indent happy */