diff options
| author | chenzizhan <[email protected]> | 2024-07-09 10:10:42 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2024-07-09 10:12:18 +0800 |
| commit | de1125112fbbdb63760ffe12871224b201b4e898 (patch) | |
| tree | ff7a20ba5a43a6500ace15c5ac1fde0a396d1a82 | |
| parent | f528800db9257919dc19fbde09357c8881308955 (diff) | |
some todos about old codes
| -rw-r--r-- | include/fieldstat/fieldstat.h | 6 | ||||
| -rw-r--r-- | src/cube.c | 5 | ||||
| -rw-r--r-- | src/tags/heavy_keeper.c | 8 |
3 files changed, 12 insertions, 7 deletions
diff --git a/include/fieldstat/fieldstat.h b/include/fieldstat/fieldstat.h index 941b89c..d968526 100644 --- a/include/fieldstat/fieldstat.h +++ b/include/fieldstat/fieldstat.h @@ -36,9 +36,9 @@ enum sampling_mode { SAMPLING_MODE_TOPK, }; -struct fieldstat_tag { +struct field { const char *key; - enum fs_tag_type type; + enum field_type type; union{ long long value_longlong; double value_double; @@ -163,7 +163,7 @@ int fieldstat_merge(struct fieldstat *instance, const struct fieldstat *src); /* query */ /* -------------------------------------------------------------------------- */ -struct fieldstat_tag_list +struct field_list { struct fieldstat_tag *tag; size_t n_tag; @@ -147,6 +147,7 @@ static void tags2key(const struct fieldstat_tag tags[], size_t n_tags, char **ou struct fieldstat_tag *tag = NULL; size_t alloced_every_time = 1024; + char dynamic_mem[1024*4]; size_t remain_key_size = alloced_every_time; size_t total_key_size = alloced_every_time; char *dynamic_mem = (char *)malloc(total_key_size); @@ -244,6 +245,10 @@ int cube_manager_find(const struct cube_manager *pthis, const struct fieldstat_t { char *key; size_t key_len; + + fields_calculate_keylen; + // fields_calculate_key_length(identifier, ntag) 用下面的吧 + // fields2key_endeaver / try tags2key(identifier, n_tag, &key, &key_len); struct cube *node = NULL; diff --git a/src/tags/heavy_keeper.c b/src/tags/heavy_keeper.c index 4593f9e..a7c77c7 100644 --- a/src/tags/heavy_keeper.c +++ b/src/tags/heavy_keeper.c @@ -24,7 +24,7 @@ #include "exdata.h" #define FP_HASH_KEY 0 -#define INVALID_COUNT UINT64_MAX +#define INVALID_COUNT UINT64_MAX // TODO:改名为 NOT FIND #define MAX(a, b) (((a) > (b)) ? (a) : (b)) struct entry_data { // the value constitute of a sorted set entry @@ -287,12 +287,12 @@ static inline bool sorted_set_check_is_full(const struct sorted_set *ss) { return ss->heap->cur_size >= ss->heap->max_size; } - +// TODO: 所有count 都改成long long unsigned long long sorted_set_get_min_count(const struct sorted_set *ss) { heap *heap = ss->heap; if (heap->cur_size == 0) { - return INVALID_COUNT; + return INVALID_COUNT; // TODO: -1 } const heap_entry *ret = (heap_entry *)(heap->nodes[0]); @@ -582,7 +582,7 @@ int heavy_keeper_add(struct heavy_keeper *heavy_keeper, const char *key, size_t struct sorted_set *summary = heavy_keeper->top_K_heap; - unsigned long long int old_cnt = sorted_set_get_count(summary, key, key_len); + unsigned long long int old_cnt = sorted_set_get_count(summary, key, key_len); // todo: 改成 score bool not_in_sorted_set = (old_cnt == INVALID_COUNT); unsigned long long maxv = 0; uint64_t fp = cal_hash_val_with_seed(key, key_len, FP_HASH_KEY); |
