X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fdictionary.h;h=f028dbb30e39f81b182e993237d243bac0f4557c;hb=5e3e00812270a051968e8a750e2ba9c92bae1a74;hp=9822b23c22c47efcb0ea831bf50c030554646d10;hpb=593c38de208f03e840c9632f64ff9d7e06313500;p=netdata.git diff --git a/src/dictionary.h b/src/dictionary.h old mode 100755 new mode 100644 index 9822b23c..f028dbb3 --- a/src/dictionary.h +++ b/src/dictionary.h @@ -1,29 +1,44 @@ -#include "web_buffer.h" - #ifndef NETDATA_DICTIONARY_H #define NETDATA_DICTIONARY_H 1 -typedef struct name_value { - avl avl; // the index - this has to be first! +struct dictionary_stats { + unsigned long long inserts; + unsigned long long deletes; + unsigned long long searches; + unsigned long long entries; +}; - uint32_t hash; // a simple hash to speed up searching - // we first compare hashes, and only if the hashes are equal we do string comparisons +typedef struct name_value { + avl avl; // the index - this has to be first! - char *name; - char *value; + uint32_t hash; // a simple hash to speed up searching + // we first compare hashes, and only if the hashes are equal we do string comparisons - struct name_value *next; + char *name; + void *value; } NAME_VALUE; typedef struct dictionary { - NAME_VALUE *values; - avl_tree values_index; - pthread_rwlock_t rwlock; + avl_tree values_index; + + uint8_t flags; + + struct dictionary_stats *stats; + netdata_rwlock_t *rwlock; } DICTIONARY; -extern DICTIONARY *dictionary_create(void); +#define DICTIONARY_FLAG_DEFAULT 0x00000000 +#define DICTIONARY_FLAG_SINGLE_THREADED 0x00000001 +#define DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE 0x00000002 +#define DICTIONARY_FLAG_NAME_LINK_DONT_CLONE 0x00000004 +#define DICTIONARY_FLAG_WITH_STATISTICS 0x00000008 + +extern DICTIONARY *dictionary_create(uint8_t flags); extern void dictionary_destroy(DICTIONARY *dict); extern void *dictionary_set(DICTIONARY *dict, const char *name, void *value, size_t value_len); extern void *dictionary_get(DICTIONARY *dict, const char *name); +extern int dictionary_del(DICTIONARY *dict, const char *name); + +extern int dictionary_get_all(DICTIONARY *dict, int (*callback)(void *entry, void *d), void *data); #endif /* NETDATA_DICTIONARY_H */