diff options
| author | chenzizhan <[email protected]> | 2024-07-17 11:11:03 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2024-07-17 11:11:03 +0800 |
| commit | dccb4ce1fd92b1f142383e585487af08831264d3 (patch) | |
| tree | 4dbc24c2c4834d4590a84464daeffe1a9a55a64d /src | |
| parent | 6595cbbde1280b6c7d3c445697e39aa18fa9741f (diff) | |
fix ci
Diffstat (limited to 'src')
| -rw-r--r-- | src/cells/spread_sketch.c | 8 | ||||
| -rw-r--r-- | src/cube.c | 9 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/cells/spread_sketch.c b/src/cells/spread_sketch.c index fd1c06d..5d5dd72 100644 --- a/src/cells/spread_sketch.c +++ b/src/cells/spread_sketch.c @@ -540,6 +540,10 @@ void spread_sketch_list_keys(const struct spread_sketch *ss, char ***keys, size_ } double spread_sketch_get_cardinality(const struct spread_sketch *ss, const char *key, size_t key_len) { + if (spread_sketch_get0_exdata(ss, key, key_len) == NULL) { + return -1; + } + double est = spread_sketch_point_query(ss, key, key_len); return est; } @@ -575,6 +579,9 @@ struct spread_sketch *spread_sketch_copy(const struct spread_sketch *src) { dst->buckets = calloc(dst->depth * dst->width, sizeof(struct bucket)); dst->table = smart_ptr_table_new(); spread_sketch_set_exdata_schema(dst, src->scheme.new_fn, src->scheme.free_fn, src->scheme.merge_fn, src->scheme.reset_fn, src->scheme.copy_fn); + for (int i = 0; i < dst->depth * dst->width; i++) { + dst->buckets[i].sthll_register = hll_duplicate(src->buckets[i].sthll_register, src->precision); + } for (int i = 0; i < dst->depth * dst->width; i++) { if (src->buckets[i].content == NULL || src->buckets[i].content->dying) { @@ -585,7 +592,6 @@ struct spread_sketch *spread_sketch_copy(const struct spread_sketch *src) { if (dst->buckets[i].content->exdata == NULL) { dst->buckets[i].content->exdata = src->scheme.copy_fn(src->buckets[i].content->exdata); } - dst->buckets[i].sthll_register = hll_duplicate(src->buckets[i].sthll_register, dst->precision); } return dst; } @@ -943,7 +943,7 @@ int cube_counter_incrby(struct cube *cube, int metric_id, const struct field *di } if (cube->primary_metric_id == metric_id && cube->sampling_mode == SAMPLING_MODE_TOPK) { - if (increment <= 0) { + if (increment < 0) { return FS_ERR_INVALID_PARAM; } @@ -1299,9 +1299,12 @@ int cube_hll_get(const struct cube *cube, int metric_id, const struct field_list field_array_to_key(fields->field, fields->n_field, &dimension_in_string, &dimension_string_len); double hll_value = spread_sketch_get_cardinality(cube->spread_sketch, dimension_in_string, dimension_string_len); - *value = hll_value; - free(dimension_in_string); + if (hll_value < 0) { + return FS_ERR_INVALID_TAG; + } + + *value = hll_value; return FS_OK; } |
