diff options
| author | chenzizhan <[email protected]> | 2023-11-24 10:29:47 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2023-11-24 10:29:47 +0800 |
| commit | 87f568428725f6990ed140b669534dcf9737dc0d (patch) | |
| tree | 6f737dabd06e8d33989f6f8bbc1dcf5c6090c1e5 /src | |
| parent | b642487466f9e4664db7e59c1771422da72d410c (diff) | |
128 HASH topk bucket
Diffstat (limited to 'src')
| -rw-r--r-- | src/fieldstat.c | 5 | ||||
| -rw-r--r-- | src/tags/my_ut_hash.c | 12 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/fieldstat.c b/src/fieldstat.c index dcabddf..33f60de 100644 --- a/src/fieldstat.c +++ b/src/fieldstat.c @@ -585,6 +585,11 @@ int check_before_add(const struct fieldstat *instance, int cube_id, int metric_i int fieldstat_counter_incrby(struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long increment) { + +// todo: 可能可以在每次操作的时候,都和之前比一次cell id对应的tag,如果tag对上了,就沿用上次的cell id。 +// 也许吧。 +// 作为一个方案,看看情况 + int ret = check_before_add(instance, cube_id, metric_id, METRIC_TYPE_COUNTER); if (ret != FS_OK) { return ret; diff --git a/src/tags/my_ut_hash.c b/src/tags/my_ut_hash.c index b901e81..4038067 100644 --- a/src/tags/my_ut_hash.c +++ b/src/tags/my_ut_hash.c @@ -229,13 +229,13 @@ void tag_hash_key_free(struct tag_hash_key *tag_key) free(tag_key); } -// todo: 可能可以在每次操作的时候,都和之前比一次cell id对应的tag,如果tag对上了,就沿用上次的cell id。 -// 也许吧。 - -// FNV-1a hash (http://www.isthe.com/chongo/tech/comp/fnv/) unsigned tag_hash_key_cal_hash_val(const struct tag_hash_key *tag, unsigned seed) { - // return cal_tag_hash(tag->tags, tag->n_my_tag, seed); - return cal_tag_hash_xxhash(tag->tags, tag->n_my_tag, seed); + if (seed == 0) { // use default seed + return tag->hashv; + } + XXH128_hash_t hashv = cal_tag_hash_xxhash128(tag->tags, tag->n_my_tag, seed); + + return hashv.high64 ^ hashv.low64; } void build_dynamic_cell_key(const struct fieldstat_tag tags[], size_t n_tags, char **out_key, size_t *out_key_size) |
