code to manipulate the 'struct GNUNET_FS_ShareTreeItem' tree More...
#include "platform.h"
#include "gnunet_fs_service.h"
#include "gnunet_scheduler_lib.h"
#include <pthread.h>
Go to the source code of this file.
Data Structures | |
struct | KeywordCounter |
Entry for each unique keyword to track how often it occurred. More... | |
struct | MetaCounter |
Aggregate information we keep for meta data in each directory. More... | |
struct | TrimContext |
A structure that forms a singly-linked list that serves as a stack for metadata-processing function. More... | |
Functions | |
static int | add_to_keyword_counter (void *cls, const char *keyword, int is_mandatory) |
Add the given keyword to the keyword statistics tracker. More... | |
static int | add_to_meta_counter (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_len) |
Function called on each meta data item. More... | |
static int | remove_high_frequency_keywords (void *cls, const char *keyword, int is_mandatory) |
Remove keywords above the threshold. More... | |
static int | migrate_and_drop_keywords (void *cls, const struct GNUNET_HashCode *key, void *value) |
Move "frequent" keywords over to the target ksk uri, free the counters. More... | |
static int | migrate_and_drop_metadata (void *cls, const struct GNUNET_HashCode *key, void *value) |
Copy "frequent" metadata items over to the target metadata container, free the counters. More... | |
static void | share_tree_trim (struct TrimContext *tc, struct GNUNET_FS_ShareTreeItem *tree) |
Process a share item tree, moving frequent keywords up and copying frequent metadata up. More... | |
void | GNUNET_FS_share_tree_trim (struct GNUNET_FS_ShareTreeItem *toplevel) |
Process a share item tree, moving frequent keywords up and copying frequent metadata up. More... | |
void | GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel) |
Release memory of a share item tree. More... | |
code to manipulate the 'struct GNUNET_FS_ShareTreeItem' tree
Definition in file fs_sharetree.c.
|
static |
Add the given keyword to the keyword statistics tracker.
cls | the multihashmap we store the keyword counters in |
keyword | the keyword to count |
is_mandatory | ignored |
Definition at line 156 of file fs_sharetree.c.
References KeywordCounter::count, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, and KeywordCounter::value.
Referenced by share_tree_trim().
|
static |
Function called on each meta data item.
Increments the respective counter.
cls | the container multihashmap to update |
plugin_name | name of the plugin that produced this value; special values can be used (e.g. '<zlib>' for zlib being used in the main libextractor library and yielding meta data). |
type | libextractor-type describing the meta data |
format | basic format information about data |
data_mime_type | mime-type of data (not of the original file); can be NULL (if mime-type is not known) |
data | actual meta-data found |
data_len | number of bytes in data |
Definition at line 199 of file fs_sharetree.c.
References MetaCounter::count, data, MetaCounter::data, MetaCounter::data_mime_type, MetaCounter::data_size, MetaCounter::format, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_new, GNUNET_OK, key, map, plugin_name, MetaCounter::plugin_name, type, and MetaCounter::type.
Referenced by share_tree_trim().
|
static |
Remove keywords above the threshold.
cls | the 'struct TrimContext' with the pos to remove the keywords from |
keyword | the keyword to check |
is_mandatory | ignored |
Definition at line 239 of file fs_sharetree.c.
References KeywordCounter::count, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), GNUNET_FS_uri_ksk_remove_keyword(), GNUNET_OK, tc, and KeywordCounter::value.
Referenced by share_tree_trim().
|
static |
Move "frequent" keywords over to the target ksk uri, free the counters.
cls | the 'struct TrimContext' |
key | key of the entry |
value | the 'struct KeywordCounter' |
Definition at line 269 of file fs_sharetree.c.
References KeywordCounter::count, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_FS_uri_ksk_add_keyword(), GNUNET_FS_uri_ksk_create_from_args(), GNUNET_NO, GNUNET_YES, key, tc, value, and KeywordCounter::value.
Referenced by share_tree_trim().
|
static |
Copy "frequent" metadata items over to the target metadata container, free the counters.
cls | the 'struct TrimContext' |
key | key of the entry |
value | the 'struct KeywordCounter' |
Definition at line 303 of file fs_sharetree.c.
References MetaCounter::count, MetaCounter::data, MetaCounter::data_mime_type, MetaCounter::data_size, MetaCounter::format, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_FS_meta_data_create(), GNUNET_FS_meta_data_insert(), GNUNET_YES, key, MetaCounter::plugin_name, tc, MetaCounter::type, and value.
Referenced by share_tree_trim().
|
static |
Process a share item tree, moving frequent keywords up and copying frequent metadata up.
tc | trim context with hash maps to use |
tree | tree to trim |
Definition at line 337 of file fs_sharetree.c.
References add_to_keyword_counter(), add_to_meta_counter(), GNUNET_FS_ShareTreeItem::children_head, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, getenv(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_FS_meta_data_create(), GNUNET_FS_meta_data_insert(), GNUNET_FS_meta_data_iterate(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_dup(), GNUNET_FS_uri_ksk_get_keywords(), GNUNET_YES, GNUNET_FS_ShareTreeItem::is_directory, GNUNET_FS_ShareTreeItem::ksk_uri, GNUNET_FS_ShareTreeItem::meta, migrate_and_drop_keywords(), migrate_and_drop_metadata(), GNUNET_FS_ShareTreeItem::next, remove_high_frequency_keywords(), share_tree_trim(), GNUNET_FS_ShareTreeItem::short_filename, and tc.
Referenced by GNUNET_FS_share_tree_trim(), and share_tree_trim().