GNUnet  0.10.x
Data Structures | Functions
fs_sharetree.c File Reference

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>
Include dependency graph for fs_sharetree.c:

Go to the source code of this file.

Data Structures

struct  KeywordCounter
 Entry for each unique keyword to track how often it occured. 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...
 

Detailed Description

code to manipulate the 'struct GNUNET_FS_ShareTreeItem' tree

Author
LRN
Christian Grothoff

Definition in file fs_sharetree.c.

Function Documentation

◆ add_to_keyword_counter()

static int add_to_keyword_counter ( void *  cls,
const char *  keyword,
int  is_mandatory 
)
static

Add the given keyword to the keyword statistics tracker.

Parameters
clsthe multihashmap we store the keyword counters in
keywordthe keyword to count
is_mandatoryignored
Returns
always GNUNET_OK

Definition at line 161 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().

162 {
163  struct GNUNET_CONTAINER_MultiHashMap *mcm = cls;
164  struct KeywordCounter *cnt;
165  struct GNUNET_HashCode hc;
166  size_t klen;
167 
168  klen = strlen (keyword) + 1;
169  GNUNET_CRYPTO_hash (keyword, klen - 1, &hc);
170  cnt = GNUNET_CONTAINER_multihashmap_get (mcm, &hc);
171  if (cnt == NULL)
172  {
173  cnt = GNUNET_malloc (sizeof (struct KeywordCounter) + klen);
174  cnt->value = (const char *) &cnt[1];
175  GNUNET_memcpy (&cnt[1], keyword, klen);
178  &hc, cnt,
180  }
181  cnt->count++;
182  return GNUNET_OK;
183 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * value
Keyword that was found.
Definition: fs_sharetree.c:53
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Entry for each unique keyword to track how often it occured.
Definition: fs_sharetree.c:37
Internal representation of the hash map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
#define GNUNET_memcpy(dst, src, n)
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
unsigned int count
How many files have this keyword?
Definition: fs_sharetree.c:58
A 512-bit hashcode.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_to_meta_counter()

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 
)
static

Function called on each meta data item.

Increments the respective counter.

Parameters
clsthe container multihashmap to update
plugin_namename of the plugin that produced this value; special values can be used (i.e. '<zlib>' for zlib being used in the main libextractor library and yielding meta data).
typelibextractor-type describing the meta data
formatbasic format information about data
data_mime_typemime-type of data (not of the original file); can be NULL (if mime-type is not known)
dataactual meta-data found
data_lennumber of bytes in data
Returns
0 to continue extracting / iterating

Definition at line 204 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, map, MetaCounter::plugin_name, plugin_name, MetaCounter::type, and type.

Referenced by share_tree_trim().

207 {
208  struct GNUNET_CONTAINER_MultiHashMap *map = cls;
209  struct GNUNET_HashCode key;
210  struct MetaCounter *cnt;
211 
212  GNUNET_CRYPTO_hash (data, data_len, &key);
214  if (NULL == cnt)
215  {
216  cnt = GNUNET_new (struct MetaCounter);
217  cnt->data = data;
218  cnt->data_size = data_len;
219  cnt->plugin_name = plugin_name;
220  cnt->type = type;
221  cnt->format = format;
225  &key, cnt,
227  }
228  cnt->count++;
229  return 0;
230 }
enum EXTRACTOR_MetaFormat format
Format of the data.
Definition: fs_sharetree.c:107
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
unsigned int count
How many files have meta entries matching this value? (type and format do not have to match)...
Definition: fs_sharetree.c:113
Internal representation of the hash map.
static struct GNUNET_CONTAINER_MultiPeerMap * map
Handle to the map used to store old latency values for peers.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
static char * plugin_name
Solver plugin name as string.
A 512-bit hashcode.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_HashCode key
The key used in the DHT.
const char * plugin_name
Name of the plugin that provided that piece of metadata.
Definition: fs_sharetree.c:82
enum EXTRACTOR_MetaType type
Type of the data.
Definition: fs_sharetree.c:102
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
Aggregate information we keep for meta data in each directory.
Definition: fs_sharetree.c:66
size_t data_size
Number of bytes in &#39;data&#39;.
Definition: fs_sharetree.c:97
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
const char * data_mime_type
MIME-type of the metadata itself.
Definition: fs_sharetree.c:87
uint32_t data
The data value.
const char * data
The actual meta data.
Definition: fs_sharetree.c:92
Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_high_frequency_keywords()

static int remove_high_frequency_keywords ( void *  cls,
const char *  keyword,
int  is_mandatory 
)
static

Remove keywords above the threshold.

Parameters
clsthe 'struct TrimContext' with the pos to remove the keywords from
keywordthe keyword to check
is_mandatoryignored
Returns
always GNUNET_OK

Definition at line 242 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, TrimContext::keywordcounter, GNUNET_FS_ShareTreeItem::ksk_uri, TrimContext::move_threshold, TrimContext::pos, tc, and KeywordCounter::value.

Referenced by share_tree_trim().

243 {
244  struct TrimContext *tc = cls;
245  struct KeywordCounter *counter;
246  struct GNUNET_HashCode hc;
247  size_t klen;
248 
249  klen = strlen (keyword) + 1;
250  GNUNET_CRYPTO_hash (keyword, klen - 1, &hc);
252  GNUNET_assert (NULL != counter);
253  if (counter->count < tc->move_threshold)
254  return GNUNET_OK;
256  counter->value);
257  return GNUNET_OK;
258 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * value
Keyword that was found.
Definition: fs_sharetree.c:53
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:417
struct GNUNET_FS_Uri * ksk_uri
Keywords for this file or directory (derived from metadata).
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
A structure that forms a singly-linked list that serves as a stack for metadata-processing function...
Definition: fs_sharetree.c:122
Entry for each unique keyword to track how often it occured.
Definition: fs_sharetree.c:37
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
struct GNUNET_CONTAINER_MultiHashMap * keywordcounter
Map from the hash over the keyword to an &#39;struct KeywordCounter *&#39; counter that says how often this k...
Definition: fs_sharetree.c:130
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
unsigned int count
How many files have this keyword?
Definition: fs_sharetree.c:58
A 512-bit hashcode.
struct GNUNET_FS_ShareTreeItem * pos
Position we are currently manipulating.
Definition: fs_sharetree.c:142
void GNUNET_FS_uri_ksk_remove_keyword(struct GNUNET_FS_Uri *uri, const char *keyword)
Remove the given keyword from the set of keywords represented by the URI.
Definition: fs_uri.c:779
unsigned int move_threshold
Number of times an item has to be found to be moved to the parent.
Definition: fs_sharetree.c:147
Here is the call graph for this function:
Here is the caller graph for this function:

◆ migrate_and_drop_keywords()

static int migrate_and_drop_keywords ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Move "frequent" keywords over to the target ksk uri, free the counters.

Parameters
clsthe 'struct TrimContext'
keykey of the entry
valuethe 'struct KeywordCounter'
Returns
GNUNET_YES (always)

Definition at line 271 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, TrimContext::keywordcounter, GNUNET_FS_ShareTreeItem::ksk_uri, TrimContext::move_threshold, TrimContext::pos, tc, and KeywordCounter::value.

Referenced by share_tree_trim().

272 {
273  struct TrimContext *tc = cls;
274  struct KeywordCounter *counter = value;
275 
276  if (counter->count >= tc->move_threshold)
277  {
278  if (NULL == tc->pos->ksk_uri)
279  tc->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &counter->value);
280  else
282  }
285  key,
286  counter));
287  GNUNET_free (counter);
288  return GNUNET_YES;
289 }
struct GNUNET_FS_Uri * GNUNET_FS_uri_ksk_create_from_args(unsigned int argc, const char **argv)
Create an FS URI from a user-supplied command line of keywords.
Definition: fs_uri.c:1146
void GNUNET_FS_uri_ksk_add_keyword(struct GNUNET_FS_Uri *uri, const char *keyword, int is_mandatory)
Add the given keyword to the set of keywords represented by the URI.
Definition: fs_uri.c:751
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * value
Keyword that was found.
Definition: fs_sharetree.c:53
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:417
struct GNUNET_FS_Uri * ksk_uri
Keywords for this file or directory (derived from metadata).
#define GNUNET_NO
Definition: gnunet_common.h:81
A structure that forms a singly-linked list that serves as a stack for metadata-processing function...
Definition: fs_sharetree.c:122
Entry for each unique keyword to track how often it occured.
Definition: fs_sharetree.c:37
struct GNUNET_CONTAINER_MultiHashMap * keywordcounter
Map from the hash over the keyword to an &#39;struct KeywordCounter *&#39; counter that says how often this k...
Definition: fs_sharetree.c:130
static char * value
Value of the record to add/remove.
unsigned int count
How many files have this keyword?
Definition: fs_sharetree.c:58
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_FS_ShareTreeItem * pos
Position we are currently manipulating.
Definition: fs_sharetree.c:142
#define GNUNET_YES
Definition: gnunet_common.h:80
unsigned int move_threshold
Number of times an item has to be found to be moved to the parent.
Definition: fs_sharetree.c:147
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ migrate_and_drop_metadata()

static int migrate_and_drop_metadata ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Copy "frequent" metadata items over to the target metadata container, free the counters.

Parameters
clsthe 'struct TrimContext'
keykey of the entry
valuethe 'struct KeywordCounter'
Returns
GNUNET_YES (always)

Definition at line 302 of file fs_sharetree.c.

References MetaCounter::count, MetaCounter::data, MetaCounter::data_mime_type, MetaCounter::data_size, MetaCounter::format, GNUNET_assert, GNUNET_CONTAINER_meta_data_create(), GNUNET_CONTAINER_meta_data_insert(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_YES, GNUNET_FS_ShareTreeItem::meta, TrimContext::metacounter, TrimContext::move_threshold, MetaCounter::plugin_name, TrimContext::pos, tc, MetaCounter::type, and KeywordCounter::value.

Referenced by share_tree_trim().

303 {
304  struct TrimContext *tc = cls;
305  struct MetaCounter *counter = value;
306 
307  if (counter->count >= tc->move_threshold)
308  {
309  if (NULL == tc->pos->meta)
312  counter->plugin_name,
313  counter->type,
314  counter->format,
315  counter->data_mime_type, counter->data,
316  counter->data_size);
317  }
320  key,
321  counter));
322  GNUNET_free (counter);
323  return GNUNET_YES;
324 }
enum EXTRACTOR_MetaFormat format
Format of the data.
Definition: fs_sharetree.c:107
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:417
struct GNUNET_CONTAINER_MultiHashMap * metacounter
Map from the hash over the metadata to an &#39;struct MetaCounter *&#39; counter that says how often this met...
Definition: fs_sharetree.c:137
A structure that forms a singly-linked list that serves as a stack for metadata-processing function...
Definition: fs_sharetree.c:122
unsigned int count
How many files have meta entries matching this value? (type and format do not have to match)...
Definition: fs_sharetree.c:113
static char * value
Value of the record to add/remove.
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_create(void)
Create a fresh meta data container.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
int GNUNET_CONTAINER_meta_data_insert(struct GNUNET_CONTAINER_MetaData *md, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_size)
Extend metadata.
const char * plugin_name
Name of the plugin that provided that piece of metadata.
Definition: fs_sharetree.c:82
enum EXTRACTOR_MetaType type
Type of the data.
Definition: fs_sharetree.c:102
struct GNUNET_FS_ShareTreeItem * pos
Position we are currently manipulating.
Definition: fs_sharetree.c:142
struct GNUNET_CONTAINER_MetaData * meta
Metadata for this file or directory.
Aggregate information we keep for meta data in each directory.
Definition: fs_sharetree.c:66
size_t data_size
Number of bytes in &#39;data&#39;.
Definition: fs_sharetree.c:97
#define GNUNET_YES
Definition: gnunet_common.h:80
const char * data_mime_type
MIME-type of the metadata itself.
Definition: fs_sharetree.c:87
unsigned int move_threshold
Number of times an item has to be found to be moved to the parent.
Definition: fs_sharetree.c:147
#define GNUNET_free(ptr)
Wrapper around free.
const char * data
The actual meta data.
Definition: fs_sharetree.c:92
Here is the call graph for this function:
Here is the caller graph for this function:

◆ share_tree_trim()

static void share_tree_trim ( struct TrimContext tc,
struct GNUNET_FS_ShareTreeItem tree 
)
static

Process a share item tree, moving frequent keywords up and copying frequent metadata up.

Parameters
tctrim context with hash maps to use
treetree to trim

Definition at line 335 of file fs_sharetree.c.

References add_to_keyword_counter(), add_to_meta_counter(), GNUNET_FS_ShareTreeItem::children_head, EXTRACTOR_METAFORMAT_UTF8, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, getenv(), GNUNET_CONTAINER_meta_data_create(), GNUNET_CONTAINER_meta_data_insert(), GNUNET_CONTAINER_meta_data_iterate(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_dup(), GNUNET_FS_uri_ksk_get_keywords(), GNUNET_YES, GNUNET_FS_ShareTreeItem::is_directory, TrimContext::keywordcounter, GNUNET_FS_ShareTreeItem::ksk_uri, GNUNET_FS_ShareTreeItem::meta, TrimContext::metacounter, migrate_and_drop_keywords(), migrate_and_drop_metadata(), TrimContext::move_threshold, GNUNET_FS_ShareTreeItem::next, TrimContext::pos, remove_high_frequency_keywords(), and GNUNET_FS_ShareTreeItem::short_filename.

Referenced by GNUNET_FS_share_tree_trim().

337 {
338  struct GNUNET_FS_ShareTreeItem *pos;
339  unsigned int num_children;
340 
341  /* first, trim all children */
342  num_children = 0;
343  for (pos = tree->children_head; NULL != pos; pos = pos->next)
344  {
345  share_tree_trim (tc, pos);
346  num_children++;
347  }
348 
349  /* consider adding filename to directory meta data */
350  if (tree->is_directory == GNUNET_YES)
351  {
352  const char *user = getenv ("USER");
353  if ( (user == NULL) ||
354  (0 != strncasecmp (user, tree->short_filename, strlen(user))))
355  {
356  /* only use filename if it doesn't match $USER */
357  if (NULL == tree->meta)
359  GNUNET_CONTAINER_meta_data_insert (tree->meta, "<libgnunetfs>",
362  "text/plain", tree->short_filename,
363  strlen (tree->short_filename) + 1);
364  }
365  }
366 
367  if (1 >= num_children)
368  return; /* nothing to trim */
369 
370  /* now, count keywords and meta data in children */
371  for (pos = tree->children_head; NULL != pos; pos = pos->next)
372  {
373  if (NULL != pos->meta)
375  if (NULL != pos->ksk_uri)
377  }
378 
379  /* calculate threshold for moving keywords / meta data */
380  tc->move_threshold = 1 + (num_children / 2);
381 
382  /* remove high-frequency keywords from children */
383  for (pos = tree->children_head; NULL != pos; pos = pos->next)
384  {
385  tc->pos = pos;
386  if (NULL != pos->ksk_uri)
387  {
388  struct GNUNET_FS_Uri *ksk_uri_copy = GNUNET_FS_uri_dup (pos->ksk_uri);
390  GNUNET_FS_uri_destroy (ksk_uri_copy);
391  }
392  }
393 
394  /* add high-frequency meta data and keywords to parent */
395  tc->pos = tree;
398  tc);
401  tc);
402 }
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.
Definition: fs_sharetree.c:204
struct GNUNET_FS_Uri * ksk_uri
Keywords for this file or directory (derived from metadata).
0-terminated, UTF-8 encoded string.
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.
Definition: fs_sharetree.c:271
struct GNUNET_CONTAINER_MultiHashMap * metacounter
Map from the hash over the metadata to an &#39;struct MetaCounter *&#39; counter that says how often this met...
Definition: fs_sharetree.c:137
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:988
struct GNUNET_CONTAINER_MultiHashMap * keywordcounter
Map from the hash over the keyword to an &#39;struct KeywordCounter *&#39; counter that says how often this k...
Definition: fs_sharetree.c:130
struct GNUNET_FS_ShareTreeItem * next
This is a doubly-linked list.
int GNUNET_FS_uri_ksk_get_keywords(const struct GNUNET_FS_Uri *uri, GNUNET_FS_KeywordIterator iterator, void *iterator_cls)
Iterate over all keywords in this keyword URI.
Definition: fs_uri.c:719
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...
Definition: fs_sharetree.c:335
A node of a directory tree (produced by dirscanner)
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.
Definition: fs_sharetree.c:302
struct GNUNET_FS_ShareTreeItem * children_head
This is a doubly-linked tree NULL for files and empty directories.
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_create(void)
Create a fresh meta data container.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:670
int GNUNET_CONTAINER_meta_data_insert(struct GNUNET_CONTAINER_MetaData *md, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_size)
Extend metadata.
char * short_filename
Base name of the file/directory.
char * getenv()
int is_directory
GNUNET_YES if this is a directory
struct GNUNET_FS_ShareTreeItem * pos
Position we are currently manipulating.
Definition: fs_sharetree.c:142
static int add_to_keyword_counter(void *cls, const char *keyword, int is_mandatory)
Add the given keyword to the keyword statistics tracker.
Definition: fs_sharetree.c:161
struct GNUNET_CONTAINER_MetaData * meta
Metadata for this file or directory.
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:168
int GNUNET_CONTAINER_meta_data_iterate(const struct GNUNET_CONTAINER_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
Iterate over MD entries.
#define GNUNET_YES
Definition: gnunet_common.h:80
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
unsigned int move_threshold
Number of times an item has to be found to be moved to the parent.
Definition: fs_sharetree.c:147
static int remove_high_frequency_keywords(void *cls, const char *keyword, int is_mandatory)
Remove keywords above the threshold.
Definition: fs_sharetree.c:242
Here is the call graph for this function:
Here is the caller graph for this function: