GNUnet  0.11.x
gnunet-service-setu_strata_estimator.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2012 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
28 #ifndef GNUNET_SERVICE_SETU_STRATA_ESTIMATOR_H
29 #define GNUNET_SERVICE_SETU_STRATA_ESTIMATOR_H
30 
31 #include "platform.h"
32 #include "gnunet_common.h"
33 #include "gnunet_util_lib.h"
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #if 0 /* keep Emacsens' auto-indent happy */
39 }
40 #endif
41 #endif
42 
43 
47 struct StrataEstimator
48 {
53 
57  unsigned int strata_count;
58 
62  unsigned int ibf_size;
63 };
64 
66 {
71 
75  uint8_t size;
76 
77 };
78 
86 uint8_t
87 determine_strata_count (uint64_t avg_element_size,
88  uint64_t element_count);
89 
90 
98 size_t
100  uint16_t se_ibf_total_size,
101  uint8_t number_se_send,
102  void *buf);
103 
104 
115 int
116 strata_estimator_read (const void *buf,
117  size_t buf_len,
118  int is_compressed,
119  uint8_t number_se_received,
120  uint16_t se_ibf_total_size,
121  struct MultiStrataEstimator *se);
122 
123 
132 struct MultiStrataEstimator *
133 strata_estimator_create (unsigned int strata_count,
134  uint32_t ibf_size,
135  uint8_t ibf_hashnum);
136 
137 
146 void
148  const struct MultiStrataEstimator *se2);
149 
150 
157 void
159  struct IBF_Key key);
160 
161 
168 void
170  struct IBF_Key key);
171 
172 
178 void
180 
181 
188 struct MultiStrataEstimator *
190 
191 
192 #if 0 /* keep Emacsens' auto-indent happy */
193 {
194 #endif
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif
struct GNUNET_HashCode key
The key used in the DHT.
size_t strata_estimator_write(struct MultiStrataEstimator *se, uint16_t se_ibf_total_size, uint8_t number_se_send, void *buf)
Write the given strata estimator to the buffer.
struct MultiStrataEstimator * strata_estimator_dup(struct MultiStrataEstimator *se)
Make a copy of a strata estimator.
struct MultiStrataEstimator * strata_estimator_create(unsigned int strata_count, uint32_t ibf_size, uint8_t ibf_hashnum)
Create a new strata estimator with the given parameters.
void strata_estimator_destroy(struct MultiStrataEstimator *se)
Destroy a strata estimator, free all of its resources.
uint8_t determine_strata_count(uint64_t avg_element_size, uint64_t element_count)
Deteminate how many strata estimators in the message are necessary.
int strata_estimator_read(const void *buf, size_t buf_len, int is_compressed, uint8_t number_se_received, uint16_t se_ibf_total_size, struct MultiStrataEstimator *se)
Read strata from the buffer into the given strata estimator.
void strata_estimator_insert(struct MultiStrataEstimator *se, struct IBF_Key key)
Add a key to the strata estimator.
void strata_estimator_difference(const struct MultiStrataEstimator *se1, const struct MultiStrataEstimator *se2)
Get an estimation of the symmetric difference of the elements contained in both strata estimators.
void strata_estimator_remove(struct MultiStrataEstimator *se, struct IBF_Key key)
Remove a key from the strata estimator.
static char buf[2048]
static unsigned int ibf_size
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
Keys that can be inserted into and removed from an IBF.
Definition: ibf.h:46
Invertible bloom filter (IBF).
Definition: ibf.h:83
uint8_t size
Number of strata estimators in struct.
struct StrataEstimator ** stratas
Array of strata estimators.
A handle to a strata estimator.
unsigned int ibf_size
Size of each IBF stratum (in bytes)
struct InvertibleBloomFilter ** strata
The IBFs of this strata estimator.
unsigned int strata_count
Size of the IBF array in strata.