heap-based datastore backend; usually we want the datastore to be persistent, and storing data in the heap is obviously NOT going to be persistent; still, this plugin is useful for testing/benchmarking — but never for production! More...
Go to the source code of this file.
Data Structures | |
struct | Value |
Entry in the hash map. More... | |
struct | ZeroAnonByType |
We organize 0-anonymity values in arrays "by type". More... | |
struct | Plugin |
Handle for a plugin. More... | |
struct | UpdateContext |
Closure for iterator for updating. More... | |
struct | GetContext |
Closure for get_cb(). More... | |
struct | GetAllContext |
Closure for the 'return_value' function. More... | |
struct | RemoveContext |
Closure for iterator called during 'remove_key'. More... | |
Functions | |
static void | heap_plugin_estimate_size (void *cls, unsigned long long *estimate) |
Get an estimate of how much space the database is currently using. More... | |
static int | update_iterator (void *cls, const struct GNUNET_HashCode *key, void *val) |
Update the matching value. More... | |
static void | heap_plugin_put (void *cls, const struct GNUNET_HashCode *key, bool absent, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, PluginPutCont cont, void *cont_cls) |
Store an item in the datastore. More... | |
static void | delete_value (struct Plugin *plugin, struct Value *value) |
Delete the given value, removing it from the plugin's data structures. More... | |
static int | get_iterator (void *cls, const struct GNUNET_HashCode *key, void *val) |
Obtain the matching value with the lowest uid >= next_uid. More... | |
static void | heap_plugin_get_key (void *cls, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls) |
Get one of the results for a particular key in the datastore. More... | |
static void | heap_plugin_get_replication (void *cls, PluginDatumProcessor proc, void *proc_cls) |
Get a random item for replication. More... | |
static void | heap_plugin_get_expiration (void *cls, PluginDatumProcessor proc, void *proc_cls) |
Get a random item for expiration. More... | |
static void | heap_plugin_get_zero_anonymity (void *cls, uint64_t next_uid, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls) |
Call the given processor on an item with zero anonymity. More... | |
static void | heap_plugin_drop (void *cls) |
Drop database. More... | |
static int | return_value (void *cls, const struct GNUNET_HashCode *key, void *val) |
Callback invoked to call callback on each value. More... | |
static void | heap_get_keys (void *cls, PluginKeyProcessor proc, void *proc_cls) |
Get all of the keys in the datastore. More... | |
static int | remove_iterator (void *cls, const struct GNUNET_HashCode *key, void *val) |
Obtain the matching value with the lowest uid >= next_uid. More... | |
static void | heap_plugin_remove_key (void *cls, const struct GNUNET_HashCode *key, uint32_t size, const void *data, PluginRemoveCont cont, void *cont_cls) |
Remove a particular key in the datastore. More... | |
void * | libgnunet_plugin_datastore_heap_init (void *cls) |
Entry point for the plugin. More... | |
static int | free_value (void *cls, const struct GNUNET_HashCode *key, void *val) |
Callback invoked to free all value. More... | |
void * | libgnunet_plugin_datastore_heap_done (void *cls) |
Exit point from the plugin. More... | |
heap-based datastore backend; usually we want the datastore to be persistent, and storing data in the heap is obviously NOT going to be persistent; still, this plugin is useful for testing/benchmarking — but never for production!
Definition in file plugin_datastore_heap.c.
|
static |
Get an estimate of how much space the database is currently using.
cls | our "struct Plugin*" |
Definition at line 184 of file plugin_datastore_heap.c.
References plugin.
Referenced by libgnunet_plugin_datastore_heap_init().
|
static |
Update the matching value.
cls | the 'struct UpdateContext' |
key | unused |
val | the 'struct Value' |
Definition at line 239 of file plugin_datastore_heap.c.
References GNUNET_CONTAINER_heap_update_cost(), GNUNET_NO, GNUNET_TIME_absolute_max(), GNUNET_YES, uc, and value.
Referenced by heap_plugin_put().
|
static |
Store an item in the datastore.
cls | closure |
key | key for the item |
absent | true if the key was not found in the bloom filter |
size | number of bytes in data |
data | content stored |
type | type of the content |
priority | priority of the content |
anonymity | anonymity-level for the content |
replication | replication-level for the content |
expiration | expiration time for the content |
cont | continuation called with success or failure status |
cont_cls | continuation closure |
Definition at line 289 of file plugin_datastore_heap.c.
References anonymity, ZeroAnonByType::array, ZeroAnonByType::array_pos, ZeroAnonByType::array_size, data, expiration, GNUNET_array_grow, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_OK, key, ZeroAnonByType::next, plugin, UpdateContext::priority, replication, size, type, ZeroAnonByType::type, uc, update_iterator(), and value.
Referenced by libgnunet_plugin_datastore_heap_init().
Delete the given value, removing it from the plugin's data structures.
plugin | the plugin |
value | value to delete |
Definition at line 383 of file plugin_datastore_heap.c.
References ZeroAnonByType::array, ZeroAnonByType::array_pos, ZeroAnonByType::array_size, GNUNET_array_grow, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_YES, ZeroAnonByType::next, plugin, ZeroAnonByType::type, value, and Value::zero_anon_offset.
Referenced by free_value(), heap_plugin_get_expiration(), and heap_plugin_remove_key().
|
static |
Obtain the matching value with the lowest uid >= next_uid.
cls | the 'struct GetContext' |
key | unused |
val | the 'struct Value' |
Definition at line 457 of file plugin_datastore_heap.c.
References GNUNET_BLOCK_TYPE_ANY, GNUNET_NO, GNUNET_OK, GetContext::random, GetContext::type, value, and GetContext::value.
Referenced by heap_plugin_get_key().
|
static |
Get one of the results for a particular key in the datastore.
cls | closure |
next_uid | return the result with lowest uid >= next_uid |
random | if true, return a random result instead of using next_uid |
key | maybe NULL (to match all entries) |
type | entries of which type are relevant? Use 0 for any type. |
proc | function to call on the matching value; will be called with NULL if nothing matches |
proc_cls | closure for proc |
Definition at line 496 of file plugin_datastore_heap.c.
References Value::anonymity, Value::expiration, get_iterator(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, key, Value::key, GetContext::next_uid, plugin, Value::priority, GetContext::random, Value::replication, Value::size, type, GetContext::type, Value::type, and GetContext::value.
Referenced by libgnunet_plugin_datastore_heap_init().
|
static |
Get a random item for replication.
Returns a single, not expired, random item from those with the highest replication counters. The item's replication counter is decremented by one IF it was positive before. Call 'proc' with all values ZERO or NULL if the datastore is empty.
cls | closure |
proc | function to call the value (once only). |
proc_cls | closure for proc |
Definition at line 555 of file plugin_datastore_heap.c.
References GNUNET_assert, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_CONTAINER_heap_walk_get_next(), GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, plugin, and value.
Referenced by libgnunet_plugin_datastore_heap_init().
|
static |
Get a random item for expiration.
Call 'proc' with all values ZERO or NULL if the datastore is empty.
cls | closure |
proc | function to call the value (once only). |
proc_cls | closure for proc |
Definition at line 608 of file plugin_datastore_heap.c.
References delete_value(), GNUNET_CONTAINER_heap_peek(), GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, plugin, and value.
Referenced by libgnunet_plugin_datastore_heap_init().
|
static |
Call the given processor on an item with zero anonymity.
cls | our "struct Plugin*" |
next_uid | return the result with lowest uid >= next_uid |
type | entries of which type should be considered? Must not be zero (ANY). |
proc | function to call on each matching value; will be called with NULL if no value matches |
proc_cls | closure for proc |
Definition at line 647 of file plugin_datastore_heap.c.
References ZeroAnonByType::array, ZeroAnonByType::array_pos, GNUNET_assert, GNUNET_BLOCK_TYPE_ANY, GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, ZeroAnonByType::next, plugin, type, ZeroAnonByType::type, and value.
Referenced by libgnunet_plugin_datastore_heap_init().
|
static |
Drop database.
Definition at line 693 of file plugin_datastore_heap.c.
Referenced by libgnunet_plugin_datastore_heap_init().
|
static |
Callback invoked to call callback on each value.
cls | the plugin |
key | unused |
val | the value |
Definition at line 725 of file plugin_datastore_heap.c.
References GNUNET_OK, key, GetAllContext::proc, and GetAllContext::proc_cls.
Referenced by heap_get_keys().
|
static |
Get all of the keys in the datastore.
cls | closure |
proc | function to call on each key |
proc_cls | closure for proc |
Definition at line 746 of file plugin_datastore_heap.c.
References GNUNET_CONTAINER_multihashmap_iterate(), plugin, GetAllContext::proc, GetAllContext::proc_cls, and return_value().
Referenced by libgnunet_plugin_datastore_heap_init().
|
static |
Obtain the matching value with the lowest uid >= next_uid.
cls | the 'struct GetContext' |
key | unused |
val | the 'struct Value' |
Definition at line 793 of file plugin_datastore_heap.c.
References RemoveContext::data, GNUNET_NO, GNUNET_YES, RemoveContext::size, value, and RemoveContext::value.
Referenced by heap_plugin_remove_key().
|
static |
Remove a particular key in the datastore.
cls | closure |
key | key for the content |
size | number of bytes in data |
data | content stored |
cont | continuation called with success or failure status |
cont_cls | continuation closure for cont |
Definition at line 820 of file plugin_datastore_heap.c.
References data, RemoveContext::data, delete_value(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_NO, GNUNET_OK, key, plugin, remove_iterator(), size, RemoveContext::size, and RemoveContext::value.
Referenced by libgnunet_plugin_datastore_heap_init().
void * libgnunet_plugin_datastore_heap_init | ( | void * | cls | ) |
Entry point for the plugin.
cls | the "struct GNUNET_DATASTORE_PluginEnvironment*" |
Definition at line 865 of file plugin_datastore_heap.c.
References _, Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_DATASTORE_PluginEnvironment::cls, env, GNUNET_BLOCK_PluginFunctions::get_key, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MAX, GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_INFO, GNUNET_log_from, GNUNET_new, GNUNET_OK, GNUNET_YES, heap_get_keys(), heap_plugin_drop(), heap_plugin_estimate_size(), heap_plugin_get_expiration(), heap_plugin_get_key(), heap_plugin_get_replication(), heap_plugin_get_zero_anonymity(), heap_plugin_put(), heap_plugin_remove_key(), and plugin.
|
static |
Callback invoked to free all value.
cls | the plugin |
key | unused |
val | the value |
Definition at line 911 of file plugin_datastore_heap.c.
References delete_value(), GNUNET_OK, plugin, and value.
Referenced by libgnunet_plugin_datastore_heap_done().
void * libgnunet_plugin_datastore_heap_done | ( | void * | cls | ) |
Exit point from the plugin.
cls | our "struct Plugin*" |
Definition at line 931 of file plugin_datastore_heap.c.
References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_DATASTORE_PluginFunctions::cls, free_value(), GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, and plugin.