aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_datastore_plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_datastore_plugin.h')
-rw-r--r--src/include/gnunet_datastore_plugin.h143
1 files changed, 54 insertions, 89 deletions
diff --git a/src/include/gnunet_datastore_plugin.h b/src/include/gnunet_datastore_plugin.h
index a5c548146..4d717996d 100644
--- a/src/include/gnunet_datastore_plugin.h
+++ b/src/include/gnunet_datastore_plugin.h
@@ -78,26 +78,9 @@ struct GNUNET_DATASTORE_PluginEnvironment
78 78
79 79
80/** 80/**
81 * Function invoked on behalf of a "PluginIterator" 81 * An processor over a set of items stored in the datastore.
82 * asking the database plugin to call the iterator
83 * with the next item.
84 *
85 * @param next_cls whatever argument was given
86 * to the PluginIterator as "next_cls".
87 * @param end_it set to GNUNET_YES if we
88 * should terminate the iteration early
89 * (iterator should be still called once more
90 * to signal the end of the iteration).
91 */
92typedef void (*PluginNextRequest)(void *next_cls,
93 int end_it);
94
95
96/**
97 * An iterator over a set of items stored in the datastore.
98 * 82 *
99 * @param cls closure 83 * @param cls closure
100 * @param next_cls closure to pass to the "next" function.
101 * @param key key for the content 84 * @param key key for the content
102 * @param size number of bytes in data 85 * @param size number of bytes in data
103 * @param data content stored 86 * @param data content stored
@@ -105,24 +88,21 @@ typedef void (*PluginNextRequest)(void *next_cls,
105 * @param priority priority of the content 88 * @param priority priority of the content
106 * @param anonymity anonymity-level for the content 89 * @param anonymity anonymity-level for the content
107 * @param expiration expiration time for the content 90 * @param expiration expiration time for the content
108 * @param uid unique identifier for the datum; 91 * @param uid unique identifier for the datum
109 * maybe 0 if no unique identifier is available
110 * 92 *
111 * @return GNUNET_SYSERR to abort the iteration, GNUNET_OK to continue 93 * @return GNUNET_OK to keep the item
112 * (continue on call to "next", of course), 94 * GNUNET_NO to delete the item
113 * GNUNET_NO to delete the item and continue (if supported)
114 */ 95 */
115typedef int (*PluginIterator) (void *cls, 96typedef int (*PluginDatumProcessor) (void *cls,
116 void *next_cls, 97 const GNUNET_HashCode * key,
117 const GNUNET_HashCode * key, 98 uint32_t size,
118 uint32_t size, 99 const void *data,
119 const void *data, 100 enum GNUNET_BLOCK_Type type,
120 enum GNUNET_BLOCK_Type type, 101 uint32_t priority,
121 uint32_t priority, 102 uint32_t anonymity,
122 uint32_t anonymity, 103 struct GNUNET_TIME_Absolute
123 struct GNUNET_TIME_Absolute 104 expiration,
124 expiration, 105 uint64_t uid);
125 uint64_t uid);
126 106
127/** 107/**
128 * Get an estimate of how much space the database is 108 * Get an estimate of how much space the database is
@@ -131,7 +111,7 @@ typedef int (*PluginIterator) (void *cls,
131 * @param cls closure 111 * @param cls closure
132 * @return number of bytes used on disk 112 * @return number of bytes used on disk
133 */ 113 */
134typedef unsigned long long (*PluginGetSize) (void *cls); 114typedef unsigned long long (*PluginEstimateSize) (void *cls);
135 115
136 116
137/** 117/**
@@ -165,10 +145,11 @@ typedef int (*PluginPut) (void *cls,
165 145
166 146
167/** 147/**
168 * Iterate over the results for a particular key 148 * Get one of the results for a particular key in the datastore.
169 * in the datastore.
170 * 149 *
171 * @param cls closure 150 * @param cls closure
151 * @param offset offset of the result (mod #num-results);
152 * specific ordering does not matter for the offset
172 * @param key key to match, never NULL 153 * @param key key to match, never NULL
173 * @param vhash hash of the value, maybe NULL (to 154 * @param vhash hash of the value, maybe NULL (to
174 * match all values that have the right key). 155 * match all values that have the right key).
@@ -177,34 +158,31 @@ typedef int (*PluginPut) (void *cls,
177 * there may be! 158 * there may be!
178 * @param type entries of which type are relevant? 159 * @param type entries of which type are relevant?
179 * Use 0 for any type. 160 * Use 0 for any type.
180 * @param iter function to call on each matching value; however, 161 * @param proc function to call on the matching value;
181 * after the first call to "iter", the plugin must wait 162 * proc should be called with NULL if there is no result
182 * until "NextRequest" was called before giving the iterator 163 * @param proc_cls closure for proc
183 * the next item; finally, the "iter" should be called once
184 * once with a NULL value at the end ("next_cls" should be NULL
185 * for that last call)
186 * @param iter_cls closure for iter
187 */ 164 */
188typedef void (*PluginGet) (void *cls, 165typedef void (*PluginGetKey) (void *cls,
189 const GNUNET_HashCode *key, 166 uint64_t offset,
190 const GNUNET_HashCode *vhash, 167 const GNUNET_HashCode *key,
191 enum GNUNET_BLOCK_Type type, 168 const GNUNET_HashCode *vhash,
192 PluginIterator iter, void *iter_cls); 169 enum GNUNET_BLOCK_Type type,
170 PluginDatumProcessor proc, void *proc_cls);
193 171
194 172
195 173
196/** 174/**
197 * Get a random item (additional constraints may apply depending on 175 * Get a random item (additional constraints may apply depending on
198 * the specific implementation). Calls 'iter' with all values ZERO or 176 * the specific implementation). Calls 'proc' with all values ZERO or
199 * NULL if no item applies, otherwise 'iter' is called once and only 177 * NULL if no item applies, otherwise 'proc' is called once and only
200 * once with an item, with the 'next_cls' argument being NULL. 178 * once with an item, with the 'next_cls' argument being NULL.
201 * 179 *
202 * @param cls closure 180 * @param cls closure
203 * @param iter function to call the value (once only). 181 * @param proc function to call the value (once only).
204 * @param iter_cls closure for iter 182 * @param proc_cls closure for proc
205 */ 183 */
206typedef void (*PluginRandomGet) (void *cls, 184typedef void (*PluginGetRandom) (void *cls,
207 PluginIterator iter, void *iter_cls); 185 PluginDatumProcessor proc, void *proc_cls);
208 186
209 187
210/** 188/**
@@ -238,26 +216,22 @@ typedef int (*PluginUpdate) (void *cls,
238 216
239 217
240/** 218/**
241 * Select a subset of the items in the datastore and call the given 219 * Select a single item from the datastore at the specified offset
242 * iterator for the first item; then allow getting more items by 220 * (among those applicable).
243 * calling the 'next_request' callback with the given 'next_cls'
244 * argument passed to 'iter'.
245 * 221 *
246 * @param cls closure 222 * @param cls closure
223 * @param offset offset of the result (mod #num-results);
224 * specific ordering does not matter for the offset
247 * @param type entries of which type should be considered? 225 * @param type entries of which type should be considered?
248 * Myst not be zero (ANY). 226 * Must not be zero (ANY).
249 * @param iter function to call on each matching value; however, 227 * @param proc function to call on the matching value
250 * after the first call to "iter", the plugin must wait 228 * @param proc_cls closure for proc
251 * until "NextRequest" was called before giving the iterator
252 * the next item; finally, the "iter" should be called once
253 * once with a NULL value at the end ("next_cls" should be NULL
254 * for that last call)
255 * @param iter_cls closure for iter
256 */ 229 */
257typedef void (*PluginSelector) (void *cls, 230typedef void (*PluginGetType) (void *cls,
258 enum GNUNET_BLOCK_Type type, 231 uint64_t offset,
259 PluginIterator iter, 232 enum GNUNET_BLOCK_Type type,
260 void *iter_cls); 233 PluginDatumProcessor proc,
234 void *proc_cls);
261 235
262 236
263/** 237/**
@@ -283,10 +257,10 @@ struct GNUNET_DATASTORE_PluginFunctions
283 void *cls; 257 void *cls;
284 258
285 /** 259 /**
286 * Get the current on-disk size of the SQ store. Estimates are 260 * Calculate the current on-disk size of the SQ store. Estimates
287 * fine, if that's the only thing available. 261 * are fine, if that's the only thing available.
288 */ 262 */
289 PluginGetSize get_size; 263 PluginEstimateSize estimate_size;
290 264
291 /** 265 /**
292 * Function to store an item in the datastore. 266 * Function to store an item in the datastore.
@@ -304,23 +278,14 @@ struct GNUNET_DATASTORE_PluginFunctions
304 PluginUpdate update; 278 PluginUpdate update;
305 279
306 /** 280 /**
307 * Function called by iterators whenever they want the next value; 281 * Get a particular datum matching a given hash from the datastore.
308 * note that unlike all of the other callbacks, this one does get a
309 * the "next_cls" closure which is usually different from the "cls"
310 * member of this struct!
311 */
312 PluginNextRequest next_request;
313
314 /**
315 * Function to iterate over the results for a particular key
316 * in the datastore.
317 */ 282 */
318 PluginGet get; 283 PluginGetKey get_key;
319 284
320 /** 285 /**
321 * Iterate over content with anonymity level zero. 286 * Get datum (of the specified type) with anonymity level zero.
322 */ 287 */
323 PluginSelector iter_zero_anonymity; 288 PluginGetType get_zero_anonymity;
324 289
325 /** 290 /**
326 * Function to get a random item with high replication score from 291 * Function to get a random item with high replication score from
@@ -329,13 +294,13 @@ struct GNUNET_DATASTORE_PluginFunctions
329 * counters. The item's replication counter is decremented by one 294 * counters. The item's replication counter is decremented by one
330 * IF it was positive before. 295 * IF it was positive before.
331 */ 296 */
332 PluginRandomGet replication_get; 297 PluginGetRandom get_replication;
333 298
334 /** 299 /**
335 * Function to get a random expired item or, if none are expired, one 300 * Function to get a random expired item or, if none are expired, one
336 * with a low priority. 301 * with a low priority.
337 */ 302 */
338 PluginRandomGet expiration_get; 303 PluginGetRandom get_expiration;
339 304
340 /** 305 /**
341 * Delete the database. The next operation is 306 * Delete the database. The next operation is