diff options
| author | chenzizhan <[email protected]> | 2024-10-23 18:13:58 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2024-10-23 18:13:58 +0800 |
| commit | b883f51910cf155d99f1aa03847d5dac2e690f1d (patch) | |
| tree | ca7baf1cb66da5c6c8305699c52f415c2130b8de /src | |
| parent | e4f173ace47806a87274a3f7e8cec180ba3ab11c (diff) | |
fieldstat_histogram_fork->histogram_new
Diffstat (limited to 'src')
| -rw-r--r-- | src/cube.c | 9 | ||||
| -rw-r--r-- | src/fieldstat.c | 17 |
2 files changed, 10 insertions, 16 deletions
@@ -802,13 +802,18 @@ int cube_histogram_merge(struct cube *cube, int metric_id, const struct field *d const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); if (manifest == NULL || manifest->type != METRIC_TYPE_HISTOGRAM) { - printf("invalid metric id\n"); return FS_ERR_INVALID_METRIC_ID; } + // check if the parameters matches + if (src->lowest_discernible_value != manifest->parameters->hdr.lowest_trackable_value || + src->highest_trackable_value != manifest->parameters->hdr.highest_trackable_value || + src->significant_figures != manifest->parameters->hdr.significant_figures) { + return FS_ERR_INVALID_PARAM; + } + struct cell *cell_data = get_cell_in_cube_generic(cube, dimensions, n_dimensions); if (cell_data == NULL) { - printf("too many cells\n"); return FS_ERR_TOO_MANY_CELLS; } diff --git a/src/fieldstat.c b/src/fieldstat.c index d8ecc2f..703861b 100644 --- a/src/fieldstat.c +++ b/src/fieldstat.c @@ -240,21 +240,10 @@ void fieldstat_calibrate(const struct fieldstat *master, struct fieldstat *repli /* -------------------------------------------------------------------------- */ /* histogram fast batch transaction */ /* -------------------------------------------------------------------------- */ -struct histogram *fieldstat_histogram_fork(const struct fieldstat *instance, int cube_id, int metric_id) { - const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); - if (cube == NULL) { - return NULL; - } - - const struct metric_manifest *manifest = cube_get_metric_manifest_by_id(cube, metric_id); - if (manifest == NULL || manifest->type != METRIC_TYPE_HISTOGRAM) { - return NULL; - } - const struct histogram_parameters *parameters = &(manifest->parameters->hdr); - +struct histogram *histogram_new(long long lowest_trackable_value, long long highest_trackable_value, int significant_figures) { struct hdr_histogram* inner = NULL; - int ret = hdr_init(parameters->lowest_trackable_value, parameters->highest_trackable_value, parameters->significant_figures, &inner); - if (ret != 0) { + int ret = hdr_init(lowest_trackable_value, highest_trackable_value, significant_figures, &inner); + if (ret != 0) { return NULL; } |
