diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2022-06-01 20:01:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-01 20:01:52 +0300 |
commit | 7784a16cc7af8260bb8877873a60d7dc6d2c9e73 (patch) | |
tree | 28964e18f97bfee01977240981fb53333f95bc7e /web | |
parent | c261a771cc0c93fe4e9fbb83e1be141406d314be (diff) |
Dictionary with JudyHS and double linked list (#13032)
* dictionary internals isolation
* more dictionary cleanups
* added unit test
* we should use DICT internally
* disable cups in cmake
* implement DICTIONARY with Judy arrays
* operational JUDY implementation
* JUDY cleanup
* JUDY summary added
* JudyHS implementation with double linked list
* test negative searches too
* optimize destruction
* optimize set to insert first without lookup
* updated stats
* code cleanup; better organization; updated info
* more code cleanup and commenting
* more cleanup, renames and comments
* fix rename
* more cleanups
* use Judy.h from system paths
* added foreach traversal; added flag to add item in front; isolated locks to their own functions; destruction returns the number of bytes freed
* more comments; flags are now 16-bit
* completed unittesting
* addressed comments and added reference counters maintainance
* added unittest in main; tested removal of items in front, back and middle
* added read/write walkthrough and foreach; allowed walkthrough and foreach in write mode to delete the current element (used by cups.plugin); referenced counters removed from the API
* DICTFE.name should be const too
* added API calls for exposing all statistics
* dictionary flags as enum and reference counters as atomic operations
* more comments; improved error handling at unit tests
* added functions to allow unsafe access while traversing the dictionary with locks in place
* check for libcups in cmake
* added delete callback; implemented statsd with this dictionary
* added missing dfe_done()
* added alternative implementation with AVL
* added documentation
* added comments and warning about AVL
* dictionary walktrhough on new code
* simplified foreach; updated docs
* updated docs
* AVL is much faster without hashes
* AVL should follow DBENGINE
Diffstat (limited to 'web')
-rw-r--r-- | web/api/formatters/charts2json.c | 6 | ||||
-rw-r--r-- | web/api/formatters/json_wrapper.c | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/web/api/formatters/charts2json.c b/web/api/formatters/charts2json.c index b178cc5fd0..4325b65301 100644 --- a/web/api/formatters/charts2json.c +++ b/web/api/formatters/charts2json.c @@ -150,7 +150,9 @@ struct array_printer { BUFFER *wb; }; -int print_collector(void *entry, void *data) { +static int print_collector_callback(const char *name, void *entry, void *data) { + (void)name; + struct array_printer *ap = (struct array_printer *)data; BUFFER *wb = ap->wb; struct collector *col=(struct collector *) entry; @@ -187,6 +189,6 @@ void chartcollectors2json(RRDHOST *host, BUFFER *wb) { .c = 0, .wb = wb }; - dictionary_get_all(dict, print_collector, &ap); + dictionary_walkthrough_read(dict, print_collector_callback, &ap); dictionary_destroy(dict); } diff --git a/web/api/formatters/json_wrapper.c b/web/api/formatters/json_wrapper.c index 6478fee79d..7097a5b778 100644 --- a/web/api/formatters/json_wrapper.c +++ b/web/api/formatters/json_wrapper.c @@ -7,7 +7,9 @@ struct value_output { BUFFER *wb; }; -static int value_list_output(void *entry, void *data) { +static int value_list_output(const char *name, void *entry, void *data) { + (void)name; + struct value_output *ap = (struct value_output *)data; BUFFER *wb = ap->wb; char *output = (char *) entry; @@ -130,7 +132,7 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS int len = snprintfz(output, RRD_ID_LENGTH_MAX * 2 + 7, "[\"%s\",\"%s\"]", rd->id, rd->name); dictionary_set(dict, name, output, len+1); } - dictionary_get_all(dict, value_list_output, &co); + dictionary_walkthrough_read(dict, value_list_output, &co); dictionary_destroy(dict); co.c = 0; @@ -142,7 +144,7 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS dictionary_set(dict, name, output, len + 1); } - dictionary_get_all(dict, value_list_output, &co); + dictionary_walkthrough_read(dict, value_list_output, &co); dictionary_destroy(dict); RRDSET *st; @@ -165,7 +167,7 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS } } } - dictionary_get_all(dict, value_list_output, &co); + dictionary_walkthrough_read(dict, value_list_output, &co); dictionary_destroy(dict); buffer_strcat(wb, "],\n"); } |