From d6535f9695fe987b04fa41045fd74c508b338dad Mon Sep 17 00:00:00 2001 From: chenzizhan Date: Mon, 1 Jul 2024 15:08:46 +0800 Subject: fix ci because hll count change and metric config diff stop merging --- test/test_write_json_file.cpp | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) (limited to 'test/test_write_json_file.cpp') diff --git a/test/test_write_json_file.cpp b/test/test_write_json_file.cpp index 6d6131c..f4dd7f8 100644 --- a/test/test_write_json_file.cpp +++ b/test/test_write_json_file.cpp @@ -22,7 +22,7 @@ extern "C" { extern char *fs_easy_output_to_json(struct fieldstat_easy *fs, const struct timeval *timestamp, const struct timeval *timestamp_delta); } -static struct fieldstat_easy *get_hist_fieldstat_easy() +[[gnu::unused]] static struct fieldstat_easy *get_hist_fieldstat_easy() { struct fieldstat_tag global_tags[2]; struct fieldstat_tag cell_tags[2]; @@ -58,8 +58,7 @@ static struct fieldstat_easy *get_hist_fieldstat_easy() return fse; } -static struct fieldstat *get_hll_fieldsstat() -{ +static void write_hll(struct fieldstat *instance) { struct fieldstat_tag shared_tags[1]; shared_tags[0].key = "rule_id"; @@ -67,9 +66,6 @@ static struct fieldstat *get_hll_fieldsstat() shared_tags[0].value_longlong = 1; const char *hll_name[] = {"external_ip", "internal_ip", "acc_ip"}; - - struct fieldstat *instance = fieldstat_new(); - EXPECT_NE(nullptr, instance); int cube_id = fieldstat_create_cube(instance, shared_tags, 1, SAMPLING_MODE_COMPREHENSIVE, 100); @@ -85,15 +81,10 @@ static struct fieldstat *get_hll_fieldsstat() int ret = fieldstat_hll_add(instance, cube_id, hll_id, NULL, 0, ip_str, strlen(ip_str)); EXPECT_EQ(0, ret); } - } - - return instance; } - -static struct fieldstat *get_hist_fieldstat() -{ +void write_histogram(struct fieldstat *instance) { struct fieldstat_tag shared_tags[2]; struct fieldstat_tag cell_tags[2]; @@ -116,11 +107,8 @@ static struct fieldstat *get_hist_fieldstat() "bye/udp", "oth_mtd/udp"}; - struct fieldstat *instance = fieldstat_new(); - EXPECT_NE(nullptr, instance); int cube_id = fieldstat_create_cube(instance, shared_tags, 2, SAMPLING_MODE_COMPREHENSIVE, 100); - EXPECT_EQ(0, cube_id); for(unsigned int i = 0; i < sizeof(hist_names)/sizeof(hist_names[0]); i++) { @@ -131,8 +119,6 @@ static struct fieldstat *get_hist_fieldstat() fieldstat_hist_record(instance, cube_id, hist_id, cell_tags, 2, i*100 + j); } } - - return instance; } // static struct fieldstat_easy *get_table_fieldstat_easy() @@ -179,8 +165,7 @@ void fieldstat_easy_to_file(struct fieldstat_easy *fse, const char *file_path) fieldstat_easy_free(fse); // only by free to stop exporting } -static struct fieldstat *get_table_fieldstat() -{ +void write_table(struct fieldstat *instance) { struct fieldstat_tag shared_tags[2]; shared_tags[0].key = "policy_id"; shared_tags[0].type = TAG_INTEGER; @@ -200,12 +185,8 @@ static struct fieldstat *get_table_fieldstat() cell_tags.type = TAG_CSTRING; cell_tags.value_str = "true"; - struct fieldstat *instance = fieldstat_new(); - EXPECT_NE(nullptr, instance); - int cube_id = fieldstat_create_cube(instance, shared_tags, 2, SAMPLING_MODE_COMPREHENSIVE, 100); - EXPECT_EQ(0, cube_id); int counter_id_0 = fieldstat_register_counter(instance, "T_success_log"); @@ -218,8 +199,6 @@ static struct fieldstat *get_table_fieldstat() if(i < 5) fieldstat_counter_incrby(instance, cube_id, counter_id_1, &cell_tags, 1, 2); } - - return instance; } static int write_json_to_file(const char *filename, char *json_str) @@ -239,13 +218,11 @@ TEST(ExporterLocal, TableBuild) { struct timeval current = {100, 10000}; struct fieldstat *merger = fieldstat_new(); - struct fieldstat *hll = get_hll_fieldsstat(); - struct fieldstat *hist = get_hist_fieldstat(); - struct fieldstat *table = get_table_fieldstat(); - fieldstat_merge(merger, hll); - fieldstat_merge(merger, hist); - fieldstat_merge(merger, table); + write_hll(merger); + write_histogram(merger); + write_table(merger); + struct fieldstat_json_exporter *exporter = fieldstat_json_exporter_new(); fieldstat_json_exporter_enable_delta(exporter); char *str_json = fieldstat_json_exporter_export(exporter, merger, ¤t); -- cgit v1.2.3 From aff77f35e9a3d8c5c3a315c431b2da9a4e4da39d Mon Sep 17 00:00:00 2001 From: chenzizhan Date: Tue, 9 Jul 2024 11:41:37 +0800 Subject: rename tag->field; tag2key on stack --- include/fieldstat/fieldstat.h | 50 +- include/fieldstat/fieldstat_easy.h | 14 +- include/fieldstat/fieldstat_exporter.h | 2 +- my_ut_hash.txt | 4424 -------------------------------- readme_fieldstat_easy.md | 8 +- src/cube.c | 300 ++- src/cube.h | 32 +- src/exporter/cjson_exporter.c | 124 +- src/fieldstat.c | 82 +- src/fieldstat_easy.c | 18 +- src/tags/heavy_keeper.c | 6 +- test/profiling/main.c | 10 +- test/test_easy_fs.cpp | 24 +- test/test_empty_tags.cpp | 26 +- test/test_exporter_json.cpp | 144 +- test/test_fieldstat_exporter.py | 100 +- test/test_fuzz_test.cpp | 62 +- test/test_merge.cpp | 30 +- test/test_metric_counter.cpp | 28 +- test/test_metric_histogram.cpp | 6 +- test/test_metric_hll.cpp | 12 +- test/test_performance.cpp | 126 +- test/test_register_and_reset.cpp | 73 +- test/test_write_json_file.cpp | 18 +- test/utils.cpp | 148 +- test/utils.hpp | 28 +- 26 files changed, 762 insertions(+), 5133 deletions(-) delete mode 100644 my_ut_hash.txt (limited to 'test/test_write_json_file.cpp') diff --git a/include/fieldstat/fieldstat.h b/include/fieldstat/fieldstat.h index d968526..b7f79a6 100644 --- a/include/fieldstat/fieldstat.h +++ b/include/fieldstat/fieldstat.h @@ -24,7 +24,7 @@ enum metric_type METRIC_TYPE_HISTOGRAM, }; -enum fs_tag_type +enum field_type { TAG_INTEGER, TAG_DOUBLE, @@ -60,13 +60,13 @@ struct fieldstat *fieldstat_fork(const struct fieldstat *instance); int fieldstat_calibrate(const struct fieldstat *master, struct fieldstat *replica); /* * @brief add an cube to this instance. Cube represents an template with a user-defined set of cells and metrics. - * @param cube_identifier: tags that are shared by all cells in this cube. This is the key of the cube. Can be NULL. Must be unique. Shared_tags are ordered, which means that {"TAG_KEY": "123", "TAG_KEY2": "456"} and {"TAG_KEY2": "456", "TAG_KEY": "123"} are map to different cube. - * @param n_tag: number of shared tags. + * @param cube_identifier: fields that are shared by all cells in this cube. This is the key of the cube. Can be NULL. Must be unique. Shared_tags are ordered, which means that {"TAG_KEY": "123", "TAG_KEY2": "456"} and {"TAG_KEY2": "456", "TAG_KEY": "123"} are map to different cube. + * @param n_field: number of shared fields. * @param mode: sampling mode. Refer to enum sampling_mode. * @param max_n_cell: max number of samplings(cells) in each cube. When mode is TOPK, max_n_cell > 0, while in COMPREHENSIVE mode, max_n_cell can be 0, meaning that there is no limit. * @return cube id, if success; otherwise, return FS_ERR_NULL_HANDLER, or FS_ERR_INVALID_PARAM when (max_n_cell == 0 && mode == TOPK). return FS_ERR_INVALID_KEY when the cube_identifier is not unique. */ -int fieldstat_create_cube(struct fieldstat *instance, const struct fieldstat_tag *cube_identifier, size_t n_tag, enum sampling_mode mode, size_t max_n_cell); +int fieldstat_create_cube(struct fieldstat *instance, const struct field *cube_identifier, size_t cube_identifier_len, enum sampling_mode mode, size_t max_n_cell); /* @brief Change the topk cube primary metric id. When fieldstat_counter_add or fieldstat_counter_set are called on the primary metric, the topk record of such cell will be updated. @@ -118,14 +118,14 @@ int fieldstat_register_hist(struct fieldstat *instance, const char *metric_name, * In comprehensive mode, a full cube cannot be added any more cells. * In topk mode, every increment matters, so even the cube is full, the cell can also replace the least frequent cell. */ -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); +int fieldstat_counter_incrby(struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, size_t n_fields, long long increment); /* * @brief let the value of counter metric equal to value. Other annotations refer to fieldstat_counter_incrby. * @return Refer to fieldstat_counter_incrby. What's more, be cautious to call this function if the metric is a primary metric of a topk cube, * in such case, FS_ERR_INVALID_PARAM will be the output when the value is set to a smaller one(increment is negative). */ -int fieldstat_counter_set(struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long value); +int fieldstat_counter_set(struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, size_t n_fields, long long value); /* * @brief add a key to the hll metric of cell_id. HLL approximates the number of distinct elements in a set of `key`s. @@ -134,8 +134,8 @@ int fieldstat_counter_set(struct fieldstat *instance, int cube_id, int metric_id * @return FS_OK if success. FS_ERR_NULL_HANDLER, FS_ERR_INVALID_CUBE_ID, FS_ERR_INVALID_METRIC_ID if fail. * Since topk only support counter, FS_ERR_INVALID_PARAM is returned when the cube is topk. */ -int fieldstat_hll_add(struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, const char *key, size_t key_len); -int fieldstat_hll_add_tag(struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, const struct fieldstat_tag *tags_key, size_t n_tag_key); +int fieldstat_hll_add(struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, size_t n_fields, const char *key, size_t key_len); +int fieldstat_hll_add_field(struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, size_t n_fields, const struct field *item, size_t item_len); /* @@ -145,7 +145,7 @@ int fieldstat_hll_add_tag(struct fieldstat *instance, int cube_id, int metric_id * @return FS_OK if success. FS_ERR_NULL_HANDLER, FS_ERR_INVALID_CUBE_ID, FS_ERR_INVALID_METRIC_ID if fail. * FS_ERR_INVALID_PARAM when value is less than 0, or the cube is topk. */ -int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long value); +int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, size_t n_fields, long long value); /* * @brief Delete all the cells, also the content of every metrics. The cube and metrics are not deleted. Increase cell_version by 1. @@ -165,8 +165,8 @@ int fieldstat_merge(struct fieldstat *instance, const struct fieldstat *src); struct field_list { - struct fieldstat_tag *tag; - size_t n_tag; + struct field *field; + size_t n_field; }; /* @@ -181,7 +181,7 @@ void fieldstat_get_cubes(const struct fieldstat *instance, int **cube_ids, int * */ void fieldstat_get_metrics(const struct fieldstat *instance, int **metric_id_out, size_t *n_metric); -void fieldstat_get_metric_in_cell(const struct fieldstat *instance, int cube_id, const struct fieldstat_tag_list *tags, int **metric_id_out, size_t *n_metric_out); +void fieldstat_get_metric_in_cell(const struct fieldstat *instance, int cube_id, const struct field_list *fields, int **metric_id_out, size_t *n_metric_out); // query the name of the metric, return NULL if metric_id is invalid. const char *fieldstat_get_metric_name(const struct fieldstat *instance, int metric_id); @@ -190,20 +190,20 @@ const char *fieldstat_get_metric_name(const struct fieldstat *instance, int metr enum metric_type fieldstat_get_metric_type(const struct fieldstat *instance, int metric_id); /* - get the tags added to cube when calling fieldstat_counter_incrby, fieldstat_counter_set, fieldstat_hll_add, fieldstat_hist_record. + get the fields added to cube when calling fieldstat_counter_incrby, fieldstat_counter_set, fieldstat_hll_add, fieldstat_hist_record. */ -void fieldstat_cube_get_cells(const struct fieldstat *instance, int cube_id, struct fieldstat_tag_list **tag_list, size_t *n_cell); +void fieldstat_cube_get_cells(const struct fieldstat *instance, int cube_id, struct field_list **tag_list, size_t *n_cell); /* - get the tag of fieldstat_create_cube. User free them by calling fieldstat_tag_list_arr_free(struct fieldstat_tag_list *, 1) + get the field of fieldstat_create_cube. User free them by calling fieldstat_tag_list_arr_free(struct field_list *, 1) return NULL when ID is invalid. */ -struct fieldstat_tag_list *fieldstat_cube_get_tags(const struct fieldstat *instance, int cube_id); +struct field_list *fieldstat_cube_get_tags(const struct fieldstat *instance, int cube_id); /* - return a cube id corresponding to the shared tags. FS_ERR_INVALID_KEY is returned if the shared tags are not found. + return a cube id corresponding to the shared fields. FS_ERR_INVALID_KEY is returned if the shared fields are not found. */ -int fieldstat_find_cube(const struct fieldstat *instance, const struct fieldstat_tag *cube_identifier, size_t n_shared_tags); +int fieldstat_find_cube(const struct fieldstat *instance, const struct field *cube_identifier, size_t n_shared_tags); /* get the cell numbers in a cube. Return FS_ERR_INVALID_CUBE_ID if cube_id is invalid. @@ -214,24 +214,24 @@ int fieldstat_get_used_sampling(const struct fieldstat *instance, int cube_id); * @brief Get the value of a metric of a cell. * @param cube_id: cube id, previously returned by fieldstat_get_cubes. * @param metric_id: metric id, previously returned by fieldstat_get_max_metric_id. - * @param tags: previously returned by fieldstat_get_cells_used_by_metric. + * @param fields: previously returned by fieldstat_get_cells_used_by_metric. * @param value_out: the value of the metric. If the cell is not found, *value_out is set to 0. * @return FS_OK if success. FS_ERR_NULL_HANDLER, FS_ERR_INVALID_CUBE_ID, FS_ERR_INVALID_METRIC_ID if fail. */ -int fieldstat_counter_get(const struct fieldstat *instance, int cube_id, const struct fieldstat_tag_list *tags, int metric_id, long long *value); +int fieldstat_counter_get(const struct fieldstat *instance, int cube_id, const struct field_list *fields, int metric_id, long long *value); /* @brief Get an approximate count of the number of distinct elements in the cell. Other information refer to fieldstat_counter_get. @return >= 0 if success. FS_ERR_INVALID_PARAM if precision is invalid. */ -int fieldstat_hll_get(const struct fieldstat *instance, int cube_id, const struct fieldstat_tag_list *tags, int metric_id, double *value); -long long fieldstat_hist_value_at_percentile(const struct fieldstat *instance, int cube_id, const struct fieldstat_tag_list *tags, int metric_id, double percentile); -long long fieldstat_hist_count_le_value(const struct fieldstat *instance, int cube_id, const struct fieldstat_tag_list *tags, int metric_id, long long value); +int fieldstat_hll_get(const struct fieldstat *instance, int cube_id, const struct field_list *fields, int metric_id, double *value); +long long fieldstat_hist_value_at_percentile(const struct fieldstat *instance, int cube_id, const struct field_list *fields, int metric_id, double percentile); +long long fieldstat_hist_count_le_value(const struct fieldstat *instance, int cube_id, const struct field_list *fields, int metric_id, long long value); // get the base 64 encoded string of the serialized blob of a cell -void fieldstat_get_serialized_blob(const struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag_list *tags, char **blob, size_t *blob_size); +void fieldstat_get_serialized_blob(const struct fieldstat *instance, int cube_id, int metric_id, const struct field_list *fields, char **blob, size_t *blob_size); -void fieldstat_tag_list_arr_free(struct fieldstat_tag_list *tag_list, size_t n_cell); +void fieldstat_tag_list_arr_free(struct field_list *tag_list, size_t n_cell); #ifdef __cplusplus diff --git a/include/fieldstat/fieldstat_easy.h b/include/fieldstat/fieldstat_easy.h index 7403c3f..b0b70e9 100644 --- a/include/fieldstat/fieldstat_easy.h +++ b/include/fieldstat/fieldstat_easy.h @@ -13,9 +13,9 @@ struct fieldstat_easy; * new a fieldstat_easy instance. * @param max_thread_num: max thread number of this instance. * @param name: name of this instance. Will appear in output json. Can be NULL. - * @param tags: tags of this instance. Will appear in output json. Can be NULL. + * @param fields: fields of this instance. Will appear in output json. Can be NULL. */ -struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const char *name, const struct fieldstat_tag *tags, size_t n_tag); +struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const char *name, const struct field *fields, size_t n_field); /* * free a fieldstat_easy instance. */ @@ -67,19 +67,19 @@ void fieldstat_easy_output_array(struct fieldstat_easy *fse, char ***json_object */ int fieldstat_easy_output_array_and_reset(struct fieldstat_easy *fse, char ***json_objects, size_t *n_object); /* - * @brief let the value of counter metric of tags increase by `increment`. + * @brief let the value of counter metric of fields increase by `increment`. * @param thread_id: thread id. Must be in [0, max_thread_num). * @param metric_id: metric id, previously returned by fieldstat_easy_register_counter. * @param increment: increment of the counter metric. Can be negative. * return -1 also when the thread_id is out of range.FS_ERR_INVALID_METRIC_ID metric_id is not registered. */ -int fieldstat_easy_counter_incrby(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long increment); +int fieldstat_easy_counter_incrby(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct field *fields, size_t n_field, long long increment); /* - * @brief let the value of counter metric of tags equal to `value`. + * @brief let the value of counter metric of fields equal to `value`. * for other notes, see fieldstat_easy_counter_incrby. * The value will be output by summing each ones in different threads, exactly the same as values set by fieldstat_easy_counter_incrby. */ -int fieldstat_easy_counter_set(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long value); +int fieldstat_easy_counter_set(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct field *fields, size_t n_field, long long value); /* * @brief Add a value to the histogram metric of cell_id. Histogram will record the distribution of the values. The value bigger than highest_trackable_value will be set to highest_trackable_value. The value less than lowest_trackable_value will be tried to record, and, if succeed, remains in the record as -inf(most of the time) or 0(if value == 0) @@ -87,7 +87,7 @@ int fieldstat_easy_counter_set(struct fieldstat_easy *fse, int thread_id, int me * @return FS_OK if success. FS_ERR_NULL_HANDLER, FS_ERR_INVALID_CUBE_ID, FS_ERR_INVALID_METRIC_ID if fail. * return -1 also when the thread_id is out of range. */ -int fieldstat_easy_histogram_record(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long value); +int fieldstat_easy_histogram_record(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct field *fields, size_t n_field, long long value); #ifdef __cplusplus } diff --git a/include/fieldstat/fieldstat_exporter.h b/include/fieldstat/fieldstat_exporter.h index f7db70a..c11fdff 100644 --- a/include/fieldstat/fieldstat_exporter.h +++ b/include/fieldstat/fieldstat_exporter.h @@ -14,7 +14,7 @@ extern "C" struct fieldstat_json_exporter; struct fieldstat_json_exporter *fieldstat_json_exporter_new(); -void fieldstat_json_exporter_set_global_tag(struct fieldstat_json_exporter *exporter, const struct fieldstat_tag tag_list[], size_t n_tag); +void fieldstat_json_exporter_set_global_tag(struct fieldstat_json_exporter *exporter, const struct field tag_list[], size_t n_field); void fieldstat_json_exporter_set_name(struct fieldstat_json_exporter *exporter, const char *name); void fieldstat_json_exporter_free(struct fieldstat_json_exporter *exporter); diff --git a/my_ut_hash.txt b/my_ut_hash.txt deleted file mode 100644 index 115a4a8..0000000 --- a/my_ut_hash.txt +++ /dev/null @@ -1,4424 +0,0 @@ - -my_ut_hash.c.o: file format elf64-x86-64 - -Contents of section .text: - 0000 8b4710c3 66662e0f 1f840000 00000090 .G..ff.......... - 0010 41564155 41545553 4c8b7708 488b4608 AVAUATUSL.w.H.F. - 0020 4d85f675 1b4531ed 4885c041 0f95c55b M..u.E1.H..A...[ - 0030 4489e85d 415c415d 415ec30f 1f440000 D..]A\A]A^...D.. - 0040 4939c675 6a488b2e 488b1f45 31e4eb31 I9.ujH..H..E1..1 - 0050 83f80275 1b488b75 10488b7b 10e80000 ...u.H.u.H.{.... - 0060 000085c0 7549662e 0f1f8400 00000000 ....uIf......... - 0070 4983c401 4883c518 4883c318 4d39e674 I...H...H...M9.t - 0080 ae488b75 00488b3b e8000000 004189c5 .H.u.H.;.....A.. - 0090 85c0751b 8b43083b 45087513 83f80174 ..u..C.;E.u....t - 00a0 2785c075 ab488b45 10483943 1074c141 '..u.H.E.H9C.t.A - 00b0 bd010000 005b5d44 89e8415c 415d415e .....[]D..A\A]A^ - 00c0 c30f1f80 00000000 f20f1043 10660f2e ...........C.f.. - 00d0 45107adb 749aebd7 0f1f8400 00000000 E.z.t........... - 00e0 554889fd 534889f3 4883ec08 488b3ee8 UH..SH..H...H.>. - 00f0 00000000 48894500 8b430889 45088b43 ....H.E..C..E..C - 0100 0883f801 742285c0 743683f8 02750d48 ....t"..t6...u.H - 0110 8b7b10e8 00000000 48894510 4883c408 .{......H.E.H... - 0120 5b5dc30f 1f440000 f20f1043 10f20f11 []...D.....C.... - 0130 45104883 c4085b5d c30f1f80 00000000 E.H...[]........ - 0140 488b4310 48894510 4883c408 5b5dc390 H.C.H.E.H...[].. - 0150 4885ff74 5b415449 89fc5553 85f67e41 H..t[ATI..US..~A - 0160 8d46ff48 89fb488d 0440488d 6cc718eb .F.H..H..@H.l... - 0170 100f1f80 00000000 4883c318 4839eb74 ........H...H9.t - 0180 20488b3b e8000000 00837b08 0275e948 H.;......{..u.H - 0190 8b7b1048 83c318e8 00000000 4839eb75 .{.H........H9.u - 01a0 e05b4c89 e75d415c e9000000 000f1f00 .[L..]A\........ - 01b0 c366662e 0f1f8400 00000000 0f1f4000 .ff...........@. - 01c0 554889f5 534889fb 4883ec08 488b3648 UH..SH..H...H.6H - 01d0 8b3fe800 00000085 c075188b 53088b4d .?.......u..S..M - 01e0 0839ca75 1b83fa01 744e85d2 743a83fa .9.u....tN..t:.. - 01f0 02741d48 83c4085b 5dc3660f 1f440000 .t.H...[].f..D.. - 0200 4883c408 89d029c8 5b5dc30f 1f440000 H.....).[]...D.. - 0210 488b7510 488b7b10 4883c408 5b5de900 H.u.H.{.H...[].. - 0220 0000000f 1f440000 488b4310 2b4510eb .....D..H.C.+E.. - 0230 c20f1f80 00000000 f20f1043 10f20f5c ...........C...\ - 0240 4510f20f 2cc0ebab 0f1f8400 00000000 E...,........... - 0250 89f0c1e0 0429f02d 3b62e37e 8907c390 .....).-;b.~.... - 0260 8b074885 d2741d48 01f2660f 1f440000 ..H..t.H..f..D.. - 0270 0fbe0e48 83c60131 c869c093 01000148 ...H...1.i.....H - 0280 39f275ec 8907c366 0f1f8400 00000000 9.u....f........ - 0290 8b07c366 662e0f1f 84000000 00006690 ...ff.........f. - 02a0 41554154 554889f5 89d65348 89fb4883 AUATUH....SH..H. - 02b0 ec184c8d 64240c4c 89e7e800 00000048 ..L.d$.L.......H - 02c0 85ed7476 4883c310 488d446d 004c8d2c ..tvH...H.Dm.L., - 02d0 c3eb1e0f 1f440000 ba080000 004889de .....D.......H.. - 02e0 4c89e7e8 00000000 4883c318 4939dd74 L.......H...I9.t - 02f0 49488b6b f04889ef e8000000 004889ee IH.k.H.......H.. - 0300 4c89e748 89c2e800 0000008b 43f883f8 L..H........C... - 0310 0176c583 f80275d0 488b2b48 83c31848 .v....u.H.+H...H - 0320 89efe800 00000048 89ee4c89 e74889c2 .......H..L..H.. - 0330 e8000000 004939dd 75b74c89 e7e80000 .....I9.u.L..... - 0340 00004883 c4185b5d 415c415d c30f1f00 ..H...[]A\A].... - 0350 4157660f efc08d82 28442324 41564155 AWf.....(D#$AVAU - 0360 41545553 4881ec88 0000000f 29442450 ATUSH.......)D$P - 0370 0f294424 60894424 588d8277 caeb8589 .)D$`.D$X..w.... - 0380 54246081 c24f86c8 610f2944 24708b4c T$`..O..a.)D$p.L - 0390 24788944 245c660f 6f642450 89542464 $x.D$\f.od$P.T$d - 03a0 660f6f6c 24604189 cd0f2964 24200f29 f.ol$`A...)d$ .) - 03b0 6c243048 c7442440 00000000 894c2448 l$0H.D$@.....L$H - 03c0 4885f60f 84f70900 00488d5f 08488d04 H........H._.H.. - 03d0 76448b64 24208b6c 2424488d 04c34889 vD.d$ .l$$H...H. - 03e0 44241048 8d442420 48894424 080f1f00 D$.H.D$ H.D$.... - 03f0 4c8b7bf8 4c89ffe8 00000000 458d0c04 L.{.L.......E... - 0400 4883f80f 4989c60f 97c04183 f90f4489 H...I.....A...D. - 0410 4c24200f 97c209d0 0fb6c009 e8894424 L$ ...........D$ - 0420 244489e8 498d1406 4883fa0f 0f866603 $D..I...H.....f. - 0430 00004c89 fe4585ed 0f850206 00004b8d ..L..E........K. - 0440 04374c8d 48f04939 f10f82b9 00000044 .7L.H.I9.......D - 0450 8b442428 448b5424 2c4889f1 8b7c2430 .D$(D.T$,H...|$0 - 0460 448b5c24 340f1f00 691177ca eb854883 D.\$4...i.w...H. - 0470 c1104101 d06951f4 77caeb85 41c1c00d ..A..iQ.w...A... - 0480 4569c0b1 79379e41 01d26951 f877caeb Ei..y7.A..iQ.w.. - 0490 8541c1c2 0d4569d2 b179379e 01d76951 .A...Ei..y7...iQ - 04a0 fc77caeb 85c1c70d 69ffb179 379e4401 .w......i..y7.D. - 04b0 dac1c20d 4469dab1 79379e49 39c973a8 ....Di..y7.I9.s. - 04c0 897c2418 660f6e4c 24184929 f144895c .|$.f.nL$.I).D.\ - 04d0 2418660f 6e542418 4983e1f0 44894424 $.f.nT$.I...D.D$ - 04e0 18660f6e 4424184a 8d740e10 44895424 .f.nD$.J.t..D.T$ - 04f0 18660f6e 5c241866 0f62ca66 0f62c366 .f.n\$.f.b.f.b.f - 0500 0f6cc10f 11442428 4531ed48 39f00f87 .l...D$(E1.H9... - 0510 cc050000 8b0383f8 010f84a6 02000085 ................ - 0520 c00f84f9 03000083 f8020f85 e0030000 ................ - 0530 4c8b7308 4c89f7e8 00000000 448b6424 L.s.L.......D.d$ - 0540 204989c2 4d8d3c06 4101c448 83f80f0f I..M.<.A..H.... - 0550 97c04183 fc0f4489 64242041 0f97c044 ..A...D.d$ A...D - 0560 09c00fb6 c00b4424 2489c589 44242444 ......D$$...D$$D - 0570 89e8498d 14024883 fa0f0f86 00080000 ..I...H......... - 0580 4585ed0f 853f0700 004d8d57 f04d39f2 E....?...M.W.M9. - 0590 0f82b200 00008b54 24288b7c 242c4c89 .......T$(.|$,L. - 05a0 f08b7424 30448b5c 2434660f 1f440000 ..t$0D.\$4f..D.. - 05b0 690877ca eb854883 c01001ca 6948f477 i.w...H.....iH.w - 05c0 caeb85c1 c20d69d2 b179379e 01cf6948 ......i..y7...iH - 05d0 f877caeb 85c1c70d 69ffb179 379e01ce .w......i..y7... - 05e0 6948fc77 caeb85c1 c60d69f6 b179379e iH.w......i..y7. - 05f0 4401d9c1 c10d4469 d9b17937 9e4939c2 D.....Di..y7.I9. - 0600 73ae8974 2418660f 6e4c2418 4d29f244 s..t$.f.nL$.M).D - 0610 895c2418 660f6e64 24184983 e2f08954 .\$.f.nd$.I....T - 0620 2418660f 6e442418 4f8d7416 10897c24 $.f.nD$.O.t...|$ - 0630 18660f6e 6c241866 0f62cc66 0f62c566 .f.nl$.f.b.f.b.f - 0640 0f6cc10f 11442428 4531ed4d 39f70f87 .l...D$(E1.M9... - 0650 4c060000 0f1f4000 4883c318 483b5c24 L.....@.H...H;\$ - 0660 100f8589 fdffff8b 7424308d 86b16756 ........t$0...gV - 0670 1685ed0f 858f0400 00468d0c 20488b5c .........F.. H.\ - 0680 24084489 e883e00f 4183e50c 488d7318 $.D.....A...H.s. - 0690 746e6954 24383dae b2c2488d 48fc4101 tniT$8=...H.H.A. - 06a0 d141c1c9 0f4569c9 2febd427 4883f903 .A...Ei./..'H... - 06b0 76366954 243c3dae b2c24883 e8084101 v6iT$<=...H...A. - 06c0 d141c1c9 0f4569c9 2febd427 4883f803 .A...Ei./..'H... - 06d0 76166944 24403dae b2c24101 c141c1c9 v.iD$@=...A..A.. - 06e0 0f4569c9 2febd427 4889c848 8b5c2408 .Ei./..'H..H.\$. - 06f0 48c1e802 488d7483 1c48f7d8 488d0481 H...H.t..H..H... - 0700 4885c074 530fb616 69d2b167 56164101 H..tS...i..gV.A. - 0710 d141c1c1 0b4569c9 b179379e 4883e801 .A...Ei..y7.H... - 0720 74360fb6 560169d2 b1675616 4101d141 t6..V.i..gV.A..A - 0730 c1c10b45 69c9b179 379e4883 f8017418 ...Ei..y7.H...t. - 0740 0fb64602 69c0b167 56164101 c141c1c1 ..F.i..gV.A..A.. - 0750 0b4569c9 b179379e 4489c848 81c48800 .Ei..y7.D..H.... - 0760 0000c1e8 0f5b5d41 31c1415c 415d4169 .....[]A1.A\A]Ai - 0770 c177caeb 85415e41 5f4189c1 41c1e90d .w...A^A_A..A... - 0780 4431c869 c03daeb2 c289c2c1 ea1031d0 D1.i.=........1. - 0790 c30f1f80 00000000 488b7424 084c89f2 ........H.t$.L.. - 07a0 488d7c06 184c89fe e8000000 00448b6c H.|..L.......D.l - 07b0 24488b03 4501f544 896c2448 83f8010f $H..E..D.l$H.... - 07c0 855afdff ff8b4424 20448d60 0831c041 .Z....D$ D.`.1.A - 07d0 83fc0f44 89642420 0f97c00b 44242489 ...D.d$ ....D$$. - 07e0 c5894424 244489e8 488d5008 4883fa0f ..D$$D..H.P.H... - 07f0 0f867a05 00004c8d 73084585 ed0f85f5 ..z...L.s.E..... - 0800 03000049 39de0f87 af000000 8b742428 ...I9........t$( - 0810 8b7c242c 4c89f08b 4c243044 8b542434 .|$,L...L$0D.T$4 - 0820 691077ca eb854883 c01001d6 6950f477 i.w...H.....iP.w - 0830 caeb85c1 c60d69f6 b179379e 01d76950 ......i..y7...iP - 0840 f877caeb 85c1c70d 69ffb179 379e01d1 .w......i..y7... - 0850 6950fc77 caeb85c1 c10d69c9 b179379e iP.w......i..y7. - 0860 4401d2c1 c20d4469 d2b17937 9e4839d8 D.....Di..y7.H9. - 0870 76ae894c 2418660f 6e4c2418 4889d844 v..L$.f.nL$.H..D - 0880 89542418 660f6e74 24184c29 f0897424 .T$.f.nt$.L)..t$ - 0890 18660f6e 44241848 83e0f089 7c241866 .f.nD$.H....|$.f - 08a0 0f6e7c24 18660f62 ce4d8d74 0610660f .n|$.f.b.M.t..f. - 08b0 62c7660f 6cc10f11 44242848 8d531045 b.f.l...D$(H.S.E - 08c0 31ed4939 d60f838d fdffff48 8b442408 1.I9.......H.D$. - 08d0 4c29f24c 89f64989 d7488d78 184589fd L).L..I..H.x.E.. - 08e0 e8000000 0044897c 2448e969 fdffff90 .....D.|$H.i.... - 08f0 488b4308 48894414 388b4424 48448d68 H.C.H.D.8.D$HD.h - 0900 0844896c 2448662e 0f1f8400 00000000 .D.l$Hf......... - 0910 8b6c2424 448b6424 20e93afd ffff6690 .l$$D.d$ .:...f. - 0920 8b442420 8b542448 4c8d7308 4c8d7b10 .D$ .T$HL.s.L.{. - 0930 83c00848 8d4a0883 f80f8944 24200f97 ...H.J.....D$ .. - 0940 c00fb6c0 09442424 4889d048 83f90f76 .....D$$H..H...v - 0950 9f85d20f 85070200 004939de 0f87bc00 .........I9..... - 0960 00008b54 24288b7c 242c4c89 f0448b44 ...T$(.|$,L..D.D - 0970 2430448b 4c243466 0f1f8400 00000000 $0D.L$4f........ - 0980 690877ca eb854883 c0106970 f877caeb i.w...H...ip.w.. - 0990 8501ca69 48f477ca eb854401 c6c1c20d ...iH.w...D..... - 09a0 c1c60d69 d2b17937 9e01cf69 48fc77ca ...i..y7...iH.w. - 09b0 eb85c1c7 0d4469c6 b179379e 69ffb179 .....Di..y7.i..y - 09c0 379e4401 c9c1c10d 4469c9b1 79379e48 7.D.....Di..y7.H - 09d0 39d876ac 44894424 18660f6e 4c241848 9.v.D.D$.f.nL$.H - 09e0 89d84489 4c241866 0f6e7424 184c29f0 ..D.L$.f.nt$.L). - 09f0 89542418 660f6e44 24184883 e0f0897c .T$.f.nD$.H....| - 0a00 2418660f 6e7c2418 660f62ce 4d8d7406 $.f.n|$.f.b.M.t. - 0a10 10660f62 c7660f6c c10f1144 24284d39 .f.b.f.l...D$(M9 - 0a20 fe0f8209 01000044 8b6c2448 8b6c2424 .......D.l$H.l$$ - 0a30 448b6424 20e91efc ffff660f 1f440000 D.d$ .....f..D.. - 0a40 488b7424 08bd1000 000089ea 488d7c06 H.t$........H.|. - 0a50 184429ea 4c89fee8 00000000 69442438 .D).L.......iD$8 - 0a60 77caeb85 4189e803 442428c1 c00d442b w...A...D$(...D+ - 0a70 442448c7 44244800 00000069 c0b17937 D$H.D$H....i..y7 - 0a80 9e4b8d34 07894424 28694424 3c77caeb .K.4..D$(iD$..@...'... - 0730 00013f01 0c340000 00270000 00000140 ..?..4...'.....@ - 0740 010bbb00 00002700 00000001 41010c34 ......'.....A..4 - 0750 00000027 00000000 0142010c 34000000 ...'.....B..4... - 0760 27000000 00014301 0bbb0000 00270000 '.....C......'.. - 0770 00000144 010c3400 00002700 00000001 ...D..4...'..... - 0780 45010c34 00000000 0808c605 00000808 E..4............ - 0790 bb000000 08083400 00001e00 00000001 ......4......... - 07a0 2c010a61 00000000 00000000 0000000e ,..a............ - 07b0 00000000 00000001 9cfd0700 001f7461 ..............ta - 07c0 6700012c 013fb206 00000000 00000000 g..,.?.......... - 07d0 00002800 00000001 2c014d61 00000000 ..(.....,.Ma.... - 07e0 00000000 00000029 00000000 00000000 .......)........ - 07f0 810b0000 23015103 f3015400 002a0000 ....#.Q...T..*.. - 0800 00000123 01060000 00000000 00002d00 ...#..........-. - 0810 00000000 0000019c 6d080000 28000000 ........m...(... - 0820 00012301 2d6d0800 00000000 00000000 ..#.-m.......... - 0830 002b0000 00000000 00009026 00004a08 .+.........&..J. - 0840 00002301 5503f301 55002c00 00000000 ..#.U...U.,..... - 0850 0000006a 1e000029 00000000 00000000 ...j...)........ - 0860 90260000 23015503 f3015500 000808d1 .&..#.U...U..... - 0870 0500001e 00000000 01100116 6d080000 ............m... - 0880 00000000 00000000 86000000 00000000 ................ - 0890 019c1b09 00001f73 72630001 100143b2 .......src....C. - 08a0 06000000 00000000 0000002d 64737400 ...........-dst. - 08b0 0112011a 6d080000 00000000 00000000 ....m........... - 08c0 2e000000 00000000 002b0000 00000000 .........+...... - 08d0 00f60800 002d6900 011b0112 4c000000 .....-i.....L... - 08e0 00000000 00000000 2c000000 00000000 ........,....... - 08f0 00aa1e00 00002f00 00000000 0000009d ....../......... - 0900 2600000d 09000023 01550148 002c0000 &......#.U.H.,.. - 0910 00000000 00009d26 00000030 00000000 .......&...0.... - 0920 01ff0600 00000000 00000065 00000000 ...........e.... - 0930 00000001 9cea0900 00310000 000001ff .........1...... - 0940 47b20600 00000000 00000000 00326f75 G............2ou - 0950 740001ff 67ea0900 00000000 00000000 t...g........... - 0960 00310000 000001ff 74940700 00000000 .1......t....... - 0970 00000000 00330000 00000101 010c3400 .....3........4. - 0980 00000000 00000000 00003300 00000001 ..........3..... - 0990 08011bcb 05000000 00000000 00000034 ...............4 - 09a0 00000000 d5090000 2d690001 0b010e4c ........-i.....L - 09b0 00000000 00000000 00000022 00000000 ...........".... - 09c0 00000000 aa1e0000 23015507 7d007300 ........#.U.}.s. - 09d0 22481c00 00220000 00000000 00009d26 "H...".........& - 09e0 00002301 55027c00 00000808 cb050000 ..#.U.|......... - 09f0 30000000 0001ee06 00000000 00000000 0............... - 0a00 6e000000 00000000 019c850a 00003100 n.............1. - 0a10 00000001 ee2e6d08 00000000 00000000 ......m......... - 0a20 00003500 00000001 f71bcb05 00000000 ..5............. - 0a30 00000000 00002e00 00000000 00000025 ...............% - 0a40 00000000 00000077 0a000036 690001f8 .......w...6i... - 0a50 0e4c0000 00000000 00000000 00220000 .L...........".. - 0a60 00000000 0000aa1e 00002301 55077d00 ..........#.U.}. - 0a70 73002248 1c00002c 00000000 00000000 s."H...,........ - 0a80 9d260000 00370000 000001de 166d0800 .&...7.......m.. - 0a90 00000000 00000000 00440000 00000000 .........D...... - 0aa0 00019c15 0b000032 73726300 01de5c88 .......2src...\. - 0ab0 07000000 00000000 00000031 00000000 ...........1.... - 0ac0 01de6834 00000000 00000000 00000035 ..h4...........5 - 0ad0 00000000 01e01a6d 08000000 00000000 .......m........ - 0ae0 0000002f 00000000 00000000 9d260000 .../.........&.. - 0af0 fa0a0000 23015501 48002200 00000000 ....#.U.H."..... - 0b00 00000015 0b000023 01550276 00230154 .......#.U.v.#.T - 0b10 027c0000 00370000 000001d9 0e610000 .|...7.......a.. - 0b20 00000000 00000000 00070000 00000000 ................ - 0b30 00019c81 0b000031 00000000 01d935cb .......1......5. - 0b40 05000000 00000000 00000031 00000000 ...........1.... - 0b50 01d94234 00000000 00000000 00000029 ..B4...........) - 0b60 00000000 00000000 810b0000 23015503 ............#.U. - 0b70 f3015523 015403f3 01542301 51013000 ..U#.T...T#.Q.0. - 0b80 00370000 000001bd 0e610000 00000000 .7.......a...... - 0b90 00000000 009a0a00 00000000 00019c76 ...............v - 0ba0 1b000032 74616700 01bd38cb 05000000 ...2tag...8..... - 0bb0 00000000 00000031 00000000 01bd4434 .......1......D4 - 0bc0 00000000 00000000 00000031 00000000 ...........1.... - 0bd0 01bd5861 00000000 00000000 00000038 ..Xa...........8 - 0be0 00000000 01bf1373 03000003 91e07e34 .......s......~4 - 0bf0 00000000 141a0000 36690001 c20e4c00 ........6i....L. - 0c00 00000000 00000000 000039d3 1f000000 ..........9..... - 0c10 00000000 00000000 00000000 0001c409 ................ - 0c20 970f0000 3aff1f00 00000000 00000000 ....:........... - 0c30 003af21f 00000000 00000000 00003ae5 .:............:. - 0c40 1f000000 00000000 0000003b 0c200000 ...........;. .. - 0c50 00000000 3c0d2000 00000000 00000000 ....<. ......... - 0c60 003c1820 00000000 00000000 00003d38 .<. ..........=8 - 0c70 20000000 0000003d 0d00003e 39200000 ......=...>9 .. - 0c80 3ff62000 00000000 00000000 000a0000 ?. ............. - 0c90 00000002 a2081fb6 0c00003a 15210000 ...........:.!.. - 0ca0 00000000 00000000 3a082100 00000000 ........:.!..... - 0cb0 00000000 00003ff6 20000000 00000000 ......?. ....... - 0cc0 0000000a 00000000 0002a308 1fe40c00 ................ - 0cd0 00401521 00003a08 21000000 00000000 .@.!..:.!....... - 0ce0 00000000 3ff62000 00000000 00000000 ....?. ......... - 0cf0 000a0000 00000002 a4081f12 0d000040 ...............@ - 0d00 15210000 3a082100 00000000 00000000 .!..:.!......... - 0d10 000041f6 20000000 00000000 0000000a ..A. ........... - 0d20 00000000 0002a508 1f401521 00003a08 .........@.!..:. - 0d30 21000000 00000000 00000000 003f9d21 !............?.! - 0d40 00000000 00000000 00000200 00000000 ................ - 0d50 028d080d ad0d0000 3ac92100 00000000 ........:.!..... - 0d60 00000000 003abc21 00000000 00000000 .....:.!........ - 0d70 00003aaf 21000000 00000000 00000022 ..:.!.........." - 0d80 00000000 00000000 aa260000 2301550f .........&..#.U. - 0d90 7d000cff ffffff1a 91c87e06 22231823 }.........~."#.# - 0da0 0154027f 00230151 027e0000 003f9d21 .T...#.Q.~...?.! - 0db0 00000000 00000000 00000500 00000000 ................ - 0dc0 0293080d 250e0000 3ac92100 00000000 ....%...:.!..... - 0dd0 00000000 003abc21 00000000 00000000 .....:.!........ - 0de0 00003aaf 21000000 00000000 00000022 ..:.!.........." - 0df0 00000000 00000000 aa260000 2301550f .........&..#.U. - 0e00 7d000cff ffffff1a 91c87e06 22231823 }.........~."#.# - 0e10 0154027f 00230151 0a407d00 1c0cffff .T...#.Q.@}..... - 0e20 ffff1a00 003d2520 00000000 0000380f .....=% ......8. - 0e30 00003c2a 20000000 00000000 0000003f ..<* ..........? - 0e40 f6200000 00000000 00000000 09000000 . .............. - 0e50 00000295 081f750e 00003a15 21000000 ......u...:.!... - 0e60 00000000 0000003a 08210000 00000000 .......:.!...... - 0e70 00000000 0042f620 00000000 00000000 .....B. ........ - 0e80 00000800 00000000 00000000 15000000 ................ - 0e90 00000000 0296081f b70e0000 3a152100 ............:.!. - 0ea0 00000000 00000000 003a0821 00000000 .........:.!.... - 0eb0 00000000 00000042 f6200000 00000000 .......B. ...... - 0ec0 00000000 08000000 00000000 00001500 ................ - 0ed0 00000000 00000297 081ff90e 00003a15 ..............:. - 0ee0 21000000 00000000 0000003a 08210000 !..........:.!.. - 0ef0 00000000 00000000 0043f620 00000000 .........C. .... - 0f00 00000000 00000800 00000000 00000000 ................ - 0f10 15000000 00000000 0298081f 3a152100 ............:.!. - 0f20 00000000 00000000 003a0821 00000000 .........:.!.... - 0f30 00000000 00000000 419d2100 00000000 ........A.!..... - 0f40 00000000 00000000 00000002 ab080d3a ...............: - 0f50 c9210000 00000000 00000000 3abc2100 .!..........:.!. - 0f60 00000000 00000000 003aaf21 00000000 .........:.!.... - 0f70 00000000 00002200 00000000 000000aa ......"......... - 0f80 26000023 01550691 c87e0623 18230151 &..#.U...~.#.#.Q - 0f90 027e0000 00000039 d31f0000 00000000 .~.....9........ - 0fa0 00000000 00000000 000001ce 0d2c1300 .............,.. - 0fb0 003aff1f 00000000 00000000 00003af2 .:............:. - 0fc0 1f000000 00000000 0000003a e51f0000 ...........:.... - 0fd0 00000000 00000000 3b0c2000 00000000 ........;. ..... - 0fe0 003c0d20 00000000 00000000 00003c18 .<. ..........<. - 0ff0 20000000 00000000 0000003d 38200000 ..........=8 .. - 1000 00000000 ca100000 3e392000 003ff620 ........>9 ..?. - 1010 00000000 00000000 00000a00 00000000 ................ - 1020 02a2081f 43100000 3a152100 00000000 ....C...:.!..... - 1030 00000000 003a0821 00000000 00000000 .....:.!........ - 1040 0000003f f6200000 00000000 00000000 ...?. .......... - 1050 0a000000 000002a3 081f7110 00004015 ..........q...@. - 1060 2100003a 08210000 00000000 00000000 !..:.!.......... - 1070 003ff620 00000000 00000000 00000a00 .?. ............ - 1080 00000000 02a4081f 9f100000 40152100 ............@.!. - 1090 003a0821 00000000 00000000 00000041 .:.!...........A - 10a0 f6200000 00000000 00000000 0a000000 . .............. - 10b0 000002a5 081f4015 2100003a 08210000 ......@.!..:.!.. - 10c0 00000000 00000000 00003f9d 21000000 ..........?.!... - 10d0 00000000 00000000 00000000 0002ab08 ................ - 10e0 0d311100 003ac921 00000000 00000000 .1...:.!........ - 10f0 00003abc 21000000 00000000 0000003a ..:.!..........: - 1100 af210000 00000000 00000000 22000000 .!.........."... - 1110 00000000 00aa2600 00230155 0691c87e ......&..#.U...~ - 1120 06231823 0154027e 00230151 027f0000 .#.#.T.~.#.Q.... - 1130 003f9d21 00000000 00000000 00000400 .?.!............ - 1140 00000000 0293080d a9110000 3ac92100 ............:.!. - 1150 00000000 00000000 003abc21 00000000 .........:.!.... - 1160 00000000 00003aaf 21000000 00000000 ......:.!....... - 1170 00000022 00000000 00000000 aa260000 ...".........&.. - 1180 2301550f 7d000cff ffffff1a 91c87e06 #.U.}.........~. - 1190 22231823 0154027e 00230151 0a407d00 "#.#.T.~.#.Q.@}. - 11a0 1c0cffff ffff1a00 003d2520 00000000 .........=% .... - 11b0 0000bc12 00003c2a 20000000 00000000 ......<* ....... - 11c0 0000003f f6200000 00000000 00000000 ...?. .......... - 11d0 09000000 00000295 081ff911 00003a15 ..............:. - 11e0 21000000 00000000 0000003a 08210000 !..........:.!.. - 11f0 00000000 00000000 0042f620 00000000 .........B. .... - 1200 00000000 00000800 00000000 00000000 ................ - 1210 15000000 00000000 0296081f 3b120000 ............;... - 1220 3a152100 00000000 00000000 003a0821 :.!..........:.! - 1230 00000000 00000000 00000042 f6200000 ...........B. .. - 1240 00000000 00000000 08000000 00000000 ................ - 1250 00001500 00000000 00000297 081f7d12 ..............}. - 1260 00003a15 21000000 00000000 0000003a ..:.!..........: - 1270 08210000 00000000 00000000 0043f620 .!...........C. - 1280 00000000 00000000 00000800 00000000 ................ - 1290 00000000 15000000 00000000 0298081f ................ - 12a0 3a152100 00000000 00000000 003a0821 :.!..........:.! - 12b0 00000000 00000000 00000000 419d2100 ............A.!. - 12c0 00000000 00000000 00090000 00000002 ................ - 12d0 8d080d3a c9210000 00000000 00000000 ...:.!.......... - 12e0 3abc2100 00000000 00000000 003aaf21 :.!..........:.! - 12f0 00000000 00000000 00002200 00000000 .........."..... - 1300 000000aa 26000023 01550f7d 000cffff ....&..#.U.}.... - 1310 ffff1a91 c87e0622 23182301 54027e00 .....~."#.#.T.~. - 1320 23015104 91d87e06 00000000 39d31f00 #.Q...~.....9... - 1330 00000000 00000000 00040000 00000001 ................ - 1340 cb0d9e16 00003aff 1f000000 00000000 ......:......... - 1350 0000003a f21f0000 00000000 00000000 ...:............ - 1360 3ae51f00 00000000 00000000 003b0c20 :............;. - 1370 00000000 00003c0d 20000000 00000000 ......<. ....... - 1380 0000003c 18200000 00000000 00000000 ...<. .......... - 1390 3d382000 00000000 005f1400 003e3920 =8 ......_...>9 - 13a0 00003ff6 20000000 00000000 0000000d ..?. ........... - 13b0 00000000 0002a208 1fd81300 003a1521 .............:.! - 13c0 00000000 00000000 00003a08 21000000 ..........:.!... - 13d0 00000000 00000000 3ff62000 00000000 ........?. ..... - 13e0 00000000 000a0000 00000002 a3081f06 ................ - 13f0 14000040 15210000 3a082100 00000000 ...@.!..:.!..... - 1400 00000000 00003ff6 20000000 00000000 ......?. ....... - 1410 0000000a 00000000 0002a408 1f341400 .............4.. - 1420 00401521 00003a08 21000000 00000000 .@.!..:.!....... - 1430 00000000 41f62000 00000000 00000000 ....A. ......... - 1440 000a0000 00000002 a5081f40 15210000 ...........@.!.. - 1450 3a082100 00000000 00000000 0000003f :.!............? - 1460 9d210000 00000000 00000000 00000000 .!.............. - 1470 000002ab 080dc614 00003ac9 21000000 ..........:.!... - 1480 00000000 0000003a bc210000 00000000 .......:.!...... - 1490 00000000 3aaf2100 00000000 00000000 ....:.!......... - 14a0 00220000 00000000 0000aa26 00002301 .".........&..#. - 14b0 550691c8 7e062318 23015402 7e002301 U...~.#.#.T.~.#. - 14c0 51027f00 00003f9d 21000000 00000000 Q.....?.!....... - 14d0 00000004 00000000 00029308 0d3e1500 .............>.. - 14e0 003ac921 00000000 00000000 00003abc .:.!..........:. - 14f0 21000000 00000000 0000003a af210000 !..........:.!.. - 1500 00000000 00000000 22000000 00000000 ........"....... - 1510 00aa2600 00230155 0f7d000c ffffffff ..&..#.U.}...... - 1520 1a91c87e 06222318 23015402 7e002301 ...~."#.#.T.~.#. - 1530 510a407d 001c0cff ffffff1a 00003d25 Q.@}..........=% - 1540 20000000 00000051 1600003c 2a200000 ......Q...<* .. - 1550 00000000 00000000 3ff62000 00000000 ........?. ..... - 1560 00000000 00090000 00000002 95081f8e ................ - 1570 1500003a 15210000 00000000 00000000 ...:.!.......... - 1580 3a082100 00000000 00000000 000042f6 :.!...........B. - 1590 20000000 00000000 00000008 00000000 ............... - 15a0 00000000 00150000 00000000 00029608 ................ - 15b0 1fd01500 003a1521 00000000 00000000 .....:.!........ - 15c0 00003a08 21000000 00000000 00000000 ..:.!........... - 15d0 42f62000 00000000 00000000 00080000 B. ............. - 15e0 00000000 00000015 00000000 00000002 ................ - 15f0 97081f12 1600003a 15210000 00000000 .......:.!...... - 1600 00000000 3a082100 00000000 00000000 ....:.!......... - 1610 000043f6 20000000 00000000 00000008 ..C. ........... - 1620 00000000 00000000 00150000 00000000 ................ - 1630 00029808 1f3a1521 00000000 00000000 .....:.!........ - 1640 00003a08 21000000 00000000 00000000 ..:.!........... - 1650 00439d21 00000000 00000000 00000400 .C.!............ - 1660 00000000 00000000 10000000 00000000 ................ - 1670 028d080d 3ac92100 00000000 00000000 ....:.!......... - 1680 003abc21 00000000 00000000 00003aaf .:.!..........:. - 1690 21000000 00000000 00000000 000039d3 !.............9. - 16a0 1f000000 00000000 00000001 00000000 ................ - 16b0 0001c80d e7190000 3aff1f00 00000000 ........:....... - 16c0 00000000 003af21f 00000000 00000000 .....:.......... - 16d0 00003ae5 1f000000 00000000 0000003b ..:............; - 16e0 0c200000 00000000 3c0d2000 00000000 . ......<. ..... - 16f0 00000000 003c1820 00000000 00000000 .....<. ........ - 1700 0000429d 21000000 00000000 00000005 ..B.!........... - 1710 00000000 00000000 00090000 00000000 ................ - 1720 00028d08 0d511700 003ac921 00000000 .....Q...:.!.... - 1730 00000000 00003abc 21000000 00000000 ......:.!....... - 1740 0000003a af210000 00000000 00000000 ...:.!.......... - 1750 003d3820 00000000 00002018 00003e39 .=8 ...... ...>9 - 1760 2000003f f6200000 00000000 00000000 ..?. .......... - 1770 0d000000 000002a2 081f9917 00003a15 ..............:. - 1780 21000000 00000000 0000003a 08210000 !..........:.!.. - 1790 00000000 00000000 003ff620 00000000 .........?. .... - 17a0 00000000 00000a00 00000000 02a4081f ................ - 17b0 c7170000 40152100 003a0821 00000000 ....@.!..:.!.... - 17c0 00000000 0000003f f6200000 00000000 .......?. ...... - 17d0 00000000 0a000000 000002a3 081ff517 ................ - 17e0 00004015 2100003a 08210000 00000000 ..@.!..:.!...... - 17f0 00000000 0041f620 00000000 00000000 .....A. ........ - 1800 00001800 00000000 02a5081f 40152100 ............@.!. - 1810 003a0821 00000000 00000000 00000000 .:.!............ - 1820 3f9d2100 00000000 00000000 00000000 ?.!............. - 1830 00000002 ab080d7f 1800003a c9210000 ...........:.!.. - 1840 00000000 00000000 40bc2100 003aaf21 ........@.!..:.! - 1850 00000000 00000000 00002200 00000000 .........."..... - 1860 000000aa 26000023 01550691 c87e0623 ....&..#.U...~.# - 1870 18230154 027e0023 0151027f 0000003f .#.T.~.#.Q.....? - 1880 9d210000 00000000 00000000 03000000 .!.............. - 1890 00000293 080dd618 00003ac9 21000000 ..........:.!... - 18a0 00000000 0000003a bc210000 00000000 .......:.!...... - 18b0 00000000 3aaf2100 00000000 00000000 ....:.!......... - 18c0 00220000 00000000 0000aa26 00002301 .".........&..#. - 18d0 54027e00 00003b25 20000000 0000003c T.~...;% ......< - 18e0 2a200000 00000000 00000000 3ff62000 * ..........?. . - 18f0 00000000 00000000 00090000 00000002 ................ - 1900 95081f22 1900003a 15210000 00000000 ..."...:.!...... - 1910 00000000 3a082100 00000000 00000000 ....:.!......... - 1920 000042f6 20000000 00000000 00000008 ..B. ........... - 1930 00000000 00000000 00150000 00000000 ................ - 1940 00029608 1f641900 003a1521 00000000 .....d...:.!.... - 1950 00000000 00003a08 21000000 00000000 ......:.!....... - 1960 00000000 42f62000 00000000 00000000 ....B. ......... - 1970 00080000 00000000 00000015 00000000 ................ - 1980 00000002 97081fa6 1900003a 15210000 ...........:.!.. - 1990 00000000 00000000 3a082100 00000000 ........:.!..... - 19a0 00000000 000043f6 20000000 00000000 ......C. ....... - 19b0 00000008 00000000 00000000 00150000 ................ - 19c0 00000000 00029808 1f3a1521 00000000 .........:.!.... - 19d0 00000000 00003a08 21000000 00000000 ......:.!....... - 19e0 00000000 0000002f 00000000 00000000 ......./........ - 19f0 b5260000 ff190000 23015502 7f000022 .&......#.U...." - 1a00 00000000 00000000 b5260000 23015502 .........&..#.U. - 1a10 7e000000 39552000 00000000 00000000 ~...9U ......... - 1a20 00000000 00000001 c005971a 00003a74 ..............:t - 1a30 20000000 00000000 0000003a 67200000 ..........:g .. - 1a40 00000000 00000000 44000000 00458120 ........D....E. - 1a50 00000391 907f419d 21000000 00000000 ......A.!....... - 1a60 00000001 00000000 00027808 053ac921 ..........x..:.! - 1a70 00000000 00000000 00003abc 21000000 ..........:.!... - 1a80 00000000 0000003a af210000 00000000 .......:.!...... - 1a90 00000000 00000046 a01f0000 00000000 .......F........ - 1aa0 00000000 02000000 000001d6 0c3ab21f .............:.. - 1ab0 00000000 00000000 00004400 0000003c ..........D....< - 1ac0 bf1f0000 00000000 00000000 418f2000 ............A. . - 1ad0 00000000 00000000 00010000 00000002 ................ - 1ae0 c4080c3a c8200000 00000000 00000000 ...:. .......... - 1af0 3abb2000 00000000 00000000 003aae20 :. ..........:. - 1b00 00000000 00000000 00003aa1 20000000 ..........:. ... - 1b10 00000000 0000003f 23210000 00000000 .......?#!...... - 1b20 00000000 04000000 000002de 070d4d1b ..............M. - 1b30 00003a42 21000000 00000000 0000003a ..:B!..........: - 1b40 35210000 00000000 00000000 0041d620 5!...........A. - 1b50 00000000 00000000 00000400 00000000 ................ - 1b60 02e50710 3ae82000 00000000 00000000 ....:. ......... - 1b70 00000000 00003700 00000001 a10e6100 ......7.......a. - 1b80 00000000 00000000 0000ad00 00000000 ................ - 1b90 0000019c ca1c0000 31000000 0001a131 ........1......1 - 1ba0 cb050000 00000000 00000000 31000000 ............1... - 1bb0 0001a13e 34000000 00000000 00000000 ...>4........... - 1bc0 31000000 0001a152 61000000 00000000 1......Ra....... - 1bd0 00000000 38000000 0001a320 1f060000 ....8...... .... - 1be0 02914c2e 00000000 00000000 7b000000 ..L.........{... - 1bf0 00000000 961c0000 36690001 a60e4c00 ........6i....L. - 1c00 00000000 00000000 00002f00 00000000 ........../..... - 1c10 00000001 1d00002d 1c000023 0155027c .......-...#.U.| - 1c20 00230154 02730023 01510138 002f0000 .#.T.s.#.Q.8./.. - 1c30 00000000 0000b526 0000451c 00002301 .......&..E...#. - 1c40 55027600 002f0000 00000000 0000011d U.v../.......... - 1c50 0000631c 00002301 55027c00 23015402 ..c...#.U.|.#.T. - 1c60 7600002f 00000000 00000000 b5260000 v../.........&.. - 1c70 7b1c0000 23015502 76000022 00000000 {...#.U.v..".... - 1c80 00000000 011d0000 23015502 7c002301 ........#.U.|.#. - 1c90 54027600 00002f00 00000000 00000094 T.v.../......... - 1ca0 1d0000b5 1c000023 0155027c 00230154 .......#.U.|.#.T - 1cb0 03f30151 00220000 00000000 0000ca1c ...Q.".......... - 1cc0 00002301 55027c00 00003700 00000001 ..#.U.|...7..... - 1cd0 9c0e6100 00000000 00000000 00000300 ..a............. - 1ce0 00000000 0000019c fb1c0000 47000000 ............G... - 1cf0 00019c4e fb1c0000 01550008 083a0600 ...N.....U...:.. - 1d00 00300000 00000192 06000000 00000000 .0.............. - 1d10 00270000 00000000 00019c8e 1d000047 .'.............G - 1d20 00000000 01923d8e 1d000001 55326b65 ......=.....U2ke - 1d30 79000192 55fb0200 00000000 00000000 y...U........... - 1d40 00310000 00000192 61340000 00000000 .1......a4...... - 1d50 00000000 00350000 00000194 12610000 .....5.......a.. - 1d60 00000000 00000000 00480000 00000000 .........H...... - 1d70 00002200 00000000 00003669 00019511 ..".......6i.... - 1d80 34000000 00000000 00000000 00000808 4............... - 1d90 1f060000 30000000 00018d06 00000000 ....0........... - 1da0 00000000 0f000000 00000000 019ccf1d ................ - 1db0 00004700 00000001 8d3b8e1d 00000155 ..G......;.....U - 1dc0 47000000 00018d54 61000000 01540037 G......Ta....T.7 - 1dd0 00000000 016e054c 00000000 00000000 .....n.L........ - 1de0 00000088 00000000 00000001 9c6a1e00 .............j.. - 1df0 00326100 016e1c19 03000000 00000000 .2a..n.......... - 1e00 00000032 6200016e 2b190300 00000000 ...2b..n+....... - 1e10 00000000 00366161 00017021 88070000 .....6aa..p!.... - 1e20 00000000 00000000 36626200 01712188 ........6bb..q!. - 1e30 07000000 00000000 00000035 00000000 ...........5.... - 1e40 0172094c 00000000 00000000 0000002c .r.L..........., - 1e50 00000000 00000000 c2260000 49000000 .........&..I... - 1e60 00000000 00c22600 00004a00 00000001 ......&...J..... - 1e70 5f0601aa 1e00004b 00000000 015f2fcb _......K....._/. - 1e80 0500004b 00000000 015f3c34 0000004c ...K....._<4...L - 1e90 4d690001 640e4c00 00004c4d 74616700 Mi..d.L...LMtag. - 1ea0 01651fcb 05000000 00004a00 00000001 .e........J..... - 1eb0 4a0601d0 1e00004b 00000000 014a2acb J......K.....J*. - 1ec0 0500004e 73726300 014a4c88 07000000 ...Nsrc..JL..... - 1ed0 37000000 00011c05 4c000000 00000000 7.......L....... - 1ee0 00000000 c8000000 00000000 019c6f1f ..............o. - 1ef0 00003261 00011c31 b2060000 00000000 ..2a...1........ - 1f00 00000000 32620001 1c4fb206 00000000 ....2b...O...... - 1f10 00000000 00004400 00000036 69000125 ......D....6i..% - 1f20 11340000 00000000 00000000 00440000 .4...........D.. - 1f30 00004f00 00000001 26258807 00003500 ..O.....&%....5. - 1f40 00000001 27258807 00000000 00000000 ....'%.......... - 1f50 00002c00 00000000 000000c2 2600002c ..,.........&.., - 1f60 00000000 00000000 c2260000 00000037 .........&.....7 - 1f70 00000000 01170e61 00000000 00000000 .......a........ - 1f80 00000004 00000000 00000001 9ca01f00 ................ - 1f90 00470000 00000117 45b20600 00015500 .G......E.....U. - 1fa0 50000000 0002b508 1d660300 0003cd1f P........f...... - 1fb0 00002500 00000002 b5083fcd 1f000026 ..%.......?....& - 1fc0 68333200 02b7080d 08040000 00080880 h32............. - 1fd0 03000050 00000000 027f0801 41030000 ...P........A... - 1fe0 03492000 00250000 0000027f 081d4920 .I ..%........I - 1ff0 00002500 00000002 7f083019 03000051 ..%.......0....Q - 2000 6c656e00 027f083e 34000000 4c267000 len....>4...L&p. - 2010 02860817 35050000 27000000 00028708 ....5...'....... - 2020 1d400500 00523820 00002670 33320002 .@...R8 ..&p32.. - 2030 9408204f 20000000 4c270000 0000029f .. O ...L'...... - 2040 08214005 00000000 00080873 03000008 .!@........s.... - 2050 08150400 00500000 0000026f 081e4103 .....P.....o..A. - 2060 0000038f 20000025 00000000 026f0839 .... ..%.....o.9 - 2070 49200000 25000000 00026f08 50660300 I ..%.....o.Pf.. - 2080 00270000 00000271 08137303 00000050 .'.....q..s....P - 2090 00000000 02cb0701 08040000 01d62000 .............. . - 20a0 00516833 320002cb 07180804 00005170 .Qh32.........Qp - 20b0 74720002 cb072b35 05000051 6c656e00 tr....+5...Qlen. - 20c0 02cb0737 34000000 25000000 0002cb07 ...74...%....... - 20d0 4a360400 00005000 00000002 b0071008 J6....P......... - 20e0 04000001 f6200000 51683332 0002b007 ..... ..Qh32.... - 20f0 28080400 00005000 00000002 7a071008 (.....P.....z... - 2100 04000001 23210000 51616363 00027a07 ....#!..Qacc..z. - 2110 24080400 00250000 0000027a 07310804 $....%.....z.1.. - 2120 00000050 00000000 02460701 08040000 ...P.....F...... - 2130 03502100 00517074 72000246 07201903 .P!..Qptr..F. .. - 2140 00002500 00000002 46073336 04000000 ..%.....F.36.... - 2150 50000000 00023a07 1a080400 00037021 P.....:.......p! - 2160 00005170 74720002 3a073319 03000000 ..Qptr..:.3..... - 2170 50000000 00029806 10080400 00019d21 P..............! - 2180 00002500 00000002 98062719 03000026 ..%.......'....& - 2190 76616c00 029a060d 08040000 00500000 val..........P.. - 21a0 000002c8 050e6800 000001d7 21000025 ......h.....!..% - 21b0 00000000 02c8051f 68000000 51737263 ........h...Qsrc - 21c0 0002c805 31190300 00250000 000002c8 ....1....%...... - 21d0 053d3400 00000053 aa1e0000 00000000 .=4....S........ - 21e0 00000000 6f000000 00000000 019c6822 ....o.........h" - 21f0 00003ab7 1e000000 00000000 0000003a ..:............: - 2200 c31e0000 00000000 00000000 54aa1e00 ............T... - 2210 00000000 00000000 00010000 00000000 ................ - 2220 0000000d 00000000 00000001 4a065a22 ............J.Z" - 2230 00003ac3 1e000000 00000000 0000003a ..:............: - 2240 b71e0000 00000000 00000000 2c000000 ............,... - 2250 00000000 00ce2600 00002c00 00000000 ......&...,..... - 2260 000000ce 26000000 536a1e00 00000000 ....&...Sj...... - 2270 00000000 00610000 00000000 00019c22 .....a........." - 2280 2300003a 771e0000 00000000 00000000 #..:w........... - 2290 3a831e00 00000000 00000000 00556a1e :............Uj. - 22a0 00000000 0000015f 0640831e 00004077 ......._.@....@w - 22b0 1e00003d 8f1e0000 00000000 0b230000 ...=.........#.. - 22c0 3c901e00 00000000 00000000 00569a1e <............V.. - 22d0 00000000 00000000 00001b00 00000000 ................ - 22e0 00003c9b 1e000000 00000000 0000002c ..<............, - 22f0 00000000 00000000 90260000 2c000000 .........&..,... - 2300 00000000 00902600 00000029 00000000 ......&....).... - 2310 00000000 90260000 23015503 f3015500 .....&..#.U...U. - 2320 000053b8 06000000 00000000 0000003d ..S............= - 2330 03000000 00000001 9c902600 003ac606 ..........&..:.. - 2340 00000000 00000000 00003ad3 06000000 ..........:..... - 2350 00000000 0000003a e0060000 00000000 .......:........ - 2360 00000000 3aed0600 00000000 00000000 ....:........... - 2370 003efa06 00003e05 0700003e 12070000 .>....>....>.... - 2380 3e1f0700 003e2c07 00003e39 0700003e >....>,...>9...> - 2390 46070000 3e530700 003e6007 00003e6d F...>S...>`...>m - 23a0 0700003e 7a070000 3fb80600 00000000 ...>z...?....... - 23b0 00000000 00010000 00000001 32010674 ............2..t - 23c0 2600003a ed060000 00000000 00000000 &..:............ - 23d0 3ae00600 00000000 00000000 003ad306 :............:.. - 23e0 00000000 00000000 00003ac6 06000000 ..........:..... - 23f0 00000000 00000044 00000000 3cfa0600 .......D....<... - 2400 00000000 00000000 003c0507 00000000 .........<...... - 2410 00000000 00003c12 07000000 00000000 ......<......... - 2420 0000003c 1f070000 00000000 00000000 ...<............ - 2430 3c2c0700 00000000 00000000 003c3907 <,...........<9. - 2440 00000000 00000000 00003c46 07000000 ................. - 0020 00030e3a 0b3b0b39 0b491300 00042600 ...:.;.9.I....&. - 0030 49130000 0524000b 0b3e0b03 08000006 I....$...>...... - 0040 0f000b0b 00000737 00491300 00080f00 .......7.I...... - 0050 0b0b4913 00000913 01030e0b 0b3a0b3b ..I..........:.; - 0060 0b390b01 1300000a 0d00030e 3a0b3b0b .9..........:.;. - 0070 390b4913 380b0000 0b160003 0e3a0b3b 9.I.8........:.; - 0080 0b390b00 000c1300 030e3c19 00000d01 .9........<..... - 0090 01491301 1300000e 21004913 2f0b0000 .I......!.I./... - 00a0 0f340003 0e3a0b3b 0b390b49 133f193c .4...:.;.9.I.?.< - 00b0 19000010 21000000 11260000 00120401 ....!....&...... - 00c0 3e0b0b0b 49133a0b 3b05390b 01130000 >...I.:.;.9..... - 00d0 13280003 0e1c0b00 00141600 030e3a0b .(............:. - 00e0 3b05390b 49130000 15130103 0e0b0b3a ;.9.I..........: - 00f0 0b3b0539 0b011300 00160d00 030e3a0b .;.9..........:. - 0100 3b05390b 4913380b 0000170d 0003083a ;.9.I.8........: - 0110 0b3b0539 0b491338 0b000018 3400030e .;.9.I.8....4... - 0120 3a0b3b05 390b4913 88010b1c 0a000019 :.;.9.I......... - 0130 0401030e 3e0b0b0b 49133a0b 3b0b390b ....>...I.:.;.9. - 0140 01130000 1a17010b 0b3a0b3b 0b390b01 .........:.;.9.. - 0150 1300001b 0d00030e 3a0b3b0b 390b4913 ........:.;.9.I. - 0160 00001c0d 0003083a 0b3b0b39 0b491338 .......:.;.9.I.8 - 0170 0b00001d 0d004913 380b0000 1e2e013f ......I.8......? - 0180 19030e3a 0b3b0539 0b271949 13110112 ...:.;.9.'.I.... - 0190 07401897 42190113 00001f05 0003083a .@..B..........: - 01a0 0b3b0539 0b491302 17b74217 00002034 .;.9.I....B... 4 - 01b0 0003083a 0b3b0539 0b491302 18000021 ...:.;.9.I.....! - 01c0 3400030e 3a0b3b05 390b4913 02180000 4...:.;.9.I..... - 01d0 22898201 01110131 13000023 8a820100 "......1...#.... - 01e0 02189142 18000024 2e013f19 030e3a0b ...B...$..?...:. - 01f0 3b05390b 2719200b 01130000 25050003 ;.9.'. .....%... - 0200 0e3a0b3b 05390b49 13000026 34000308 .:.;.9.I...&4... - 0210 3a0b3b05 390b4913 00002734 00030e3a :.;.9.I...'4...: - 0220 0b3b0539 0b491300 00280500 030e3a0b .;.9.I...(....:. - 0230 3b05390b 49130217 b7421700 00298982 ;.9.I....B...).. - 0240 01011101 95421931 1300002a 2e013f19 .....B.1...*..?. - 0250 030e3a0b 3b05390b 27191101 12074018 ..:.;.9.'.....@. - 0260 97421901 1300002b 89820101 11019542 .B.....+.......B - 0270 19311301 1300002c 89820100 11013113 .1.....,......1. - 0280 00002d34 0003083a 0b3b0539 0b491302 ..-4...:.;.9.I.. - 0290 17b74217 00002e0b 01110112 07011300 ..B............. - 02a0 002f8982 01011101 31130113 0000302e ./......1.....0. - 02b0 013f1903 0e3a0b3b 0b390b27 19110112 .?...:.;.9.'.... - 02c0 07401897 42190113 00003105 00030e3a .@..B.....1....: - 02d0 0b3b0b39 0b491302 17b74217 00003205 .;.9.I....B...2. - 02e0 0003083a 0b3b0b39 0b491302 17b74217 ...:.;.9.I....B. - 02f0 00003334 00030e3a 0b3b0539 0b491302 ..34...:.;.9.I.. - 0300 17b74217 0000340b 01551701 13000035 ..B...4..U.....5 - 0310 3400030e 3a0b3b0b 390b4913 0217b742 4...:.;.9.I....B - 0320 17000036 34000308 3a0b3b0b 390b4913 ...64...:.;.9.I. - 0330 0217b742 17000037 2e013f19 030e3a0b ...B...7..?...:. - 0340 3b0b390b 27194913 11011207 40189742 ;.9.'.I.....@..B - 0350 19011300 00383400 030e3a0b 3b0b390b .....84...:.;.9. - 0360 49130218 0000391d 01311352 01b84205 I.....9..1.R..B. - 0370 5517580b 590b570b 01130000 3a050031 U.X.Y.W.....:..1 - 0380 130217b7 42170000 3b0b0131 13551700 ....B...;..1.U.. - 0390 003c3400 31130217 b7421700 003d0b01 .<4.1....B...=.. - 03a0 31135517 01130000 3e340031 1300003f 1.U.....>4.1...? - 03b0 1d013113 5201b842 05551758 0b590557 ..1.R..B.U.X.Y.W - 03c0 0b011300 00400500 31130000 411d0131 .....@..1...A..1 - 03d0 135201b8 42055517 580b5905 570b0000 .R..B.U.X.Y.W... - 03e0 421d0131 135201b8 42051101 1207580b B..1.R..B.....X. - 03f0 5905570b 01130000 431d0131 135201b8 Y.W.....C..1.R.. - 0400 42051101 1207580b 5905570b 0000440b B.....X.Y.W...D. - 0410 01551700 00453400 31130218 0000461d .U...E4.1.....F. - 0420 01311352 01b84205 5517580b 590b570b .1.R..B.U.X.Y.W. - 0430 00004705 00030e3a 0b3b0b39 0b491302 ..G....:.;.9.I.. - 0440 18000048 0b011101 12070000 49898201 ...H........I... - 0450 00110195 42193113 00004a2e 013f1903 ....B.1...J..?.. - 0460 0e3a0b3b 0b390b27 19200b01 1300004b .:.;.9.'. .....K - 0470 0500030e 3a0b3b0b 390b4913 00004c0b ....:.;.9.I...L. - 0480 0100004d 34000308 3a0b3b0b 390b4913 ...M4...:.;.9.I. - 0490 00004e05 0003083a 0b3b0b39 0b491300 ..N....:.;.9.I.. - 04a0 004f3400 030e3a0b 3b0b390b 49130000 .O4...:.;.9.I... - 04b0 502e0103 0e3a0b3b 05390b27 19491320 P....:.;.9.'.I. - 04c0 0b011300 00510500 03083a0b 3b05390b .....Q....:.;.9. - 04d0 49130000 520b0101 13000053 2e013113 I...R......S..1. - 04e0 11011207 40189742 19011300 00541d01 ....@..B.....T.. - 04f0 31135201 b8420511 01120758 0b590b57 1.R..B.....X.Y.W - 0500 0b011300 00551d01 31135517 580b590b .....U..1.U.X.Y. - 0510 570b0000 560b0131 13110112 07000057 W...V..1.......W - 0520 2e003f19 3c196e0e 030e3a0b 3b05390b ..?.<.n...:.;.9. - 0530 0000582e 003f193c 196e0e03 0e3a0b3b ..X..?.<.n...:.; - 0540 0b000059 2e003f19 3c196e0e 030e3a0b ...Y..?.<.n...:. - 0550 3b0b390b 000000 ;.9.... -Contents of section .debug_loc: - 0000 00000000 40130000 00000000 4b130000 ....@.......K... - 0010 00000000 0100554b 13000000 00000061 ......UK.......a - 0020 13000000 00000004 00f30155 9f000000 ...........U.... - 0030 00000000 00000000 00000000 00000000 ................ - 0040 00f00f00 00000000 00f90f00 00000000 ................ - 0050 00010055 f90f0000 00000000 fe0f0000 ...U............ - 0060 00000000 0400f301 559f0000 00000000 ........U....... - 0070 00000000 00000000 00000000 00000000 ................ - 0080 f00f0000 00000000 f60f0000 00000000 ................ - 0090 010054f6 0f000000 000000fd 0f000000 ..T............. - 00a0 00000001 0051fd0f 00000000 0000fe0f .....Q.......... - 00b0 00000000 00000400 f301549f 00000000 ..........T..... - 00c0 00000000 00000000 00000000 00000000 ................ - 00d0 00000000 00000000 0000c00f 00000000 ................ - 00e0 0000cd0f 00000000 00000100 55cd0f00 ............U... - 00f0 00000000 00ce0f00 00000000 00010053 ...............S - 0100 ce0f0000 00000000 d20f0000 00000000 ................ - 0110 010055d2 0f000000 000000d3 0f000000 ..U............. - 0120 00000004 00f30155 9fd30f00 00000000 .......U........ - 0130 00e80f00 00000000 00010053 e80f0000 ...........S.... - 0140 00000000 ec0f0000 00000000 010055ec ..............U. - 0150 0f000000 000000ed 0f000000 00000004 ................ - 0160 00f30155 9f000000 00000000 00000000 ...U............ - 0170 00000000 00000000 00000000 00000030 ...............0 - 0180 0f000000 0000003b 0f000000 00000001 .......;........ - 0190 00553b0f 00000000 0000650f 00000000 .U;.......e..... - 01a0 00000100 56650f00 00000000 00700f00 ....Ve.......p.. - 01b0 00000000 000400f3 01559f70 0f000000 .........U.p.... - 01c0 000000b3 0f000000 00000001 0056b30f .............V.. - 01d0 00000000 0000b60f 00000000 00000400 ................ - 01e0 f301559f 00000000 00000000 00000000 ..U............. - 01f0 00000000 00000000 00000000 0000470f ..............G. - 0200 00000000 00004b0f 00000000 00000100 ......K......... - 0210 504b0f00 00000000 006f0f00 00000000 PK.......o...... - 0220 0001005c 6f0f0000 00000000 700f0000 ...\o.......p... - 0230 00000000 01005070 0f000000 000000b5 ......Pp........ - 0240 0f000000 00000001 005cb50f 00000000 .........\...... - 0250 0000b60f 00000000 00000100 50000000 ............P... - 0260 00000000 00000000 00000000 00020000 ................ - 0270 00830f00 00000000 00850f00 00000000 ................ - 0280 00020030 9f8c0f00 00000000 00980f00 ...0............ - 0290 00000000 00010053 00000000 00000000 .......S........ - 02a0 00000000 00000000 00000000 0000c00e ................ - 02b0 00000000 0000ec0e 00000000 00000100 ................ - 02c0 55ec0e00 00000000 00200f00 00000000 U........ ...... - 02d0 00010056 200f0000 00000000 250f0000 ...V .......%... - 02e0 00000000 0400f301 559f0000 00000000 ........U....... - 02f0 00000000 00000000 00000000 00000000 ................ - 0300 c00e0000 00000000 f70e0000 00000000 ................ - 0310 010054f7 0e000000 00000000 0f000000 ..T............. - 0320 00000001 0053000f 00000000 0000250f .....S........%. - 0330 00000000 00000400 f301549f 00000000 ..........T..... - 0340 00000000 00000000 00000000 00000000 ................ - 0350 c00e0000 00000000 f70e0000 00000000 ................ - 0360 010051f7 0e000000 00000025 0f000000 ..Q........%.... - 0370 00000004 00f30151 9f000000 00000000 .......Q........ - 0380 00000000 00000000 000000c4 0e000000 ................ - 0390 000000f7 0e000000 00000001 00500000 .............P.. - 03a0 00000000 00000000 00000000 00000000 ................ - 03b0 0000fe0e 00000000 0000000f 00000000 ................ - 03c0 00000100 50000f00 00000000 00240f00 ....P........$.. - 03d0 00000000 0001005d 00000000 00000000 .......]........ - 03e0 00000000 00000000 0300fe0e 00000000 ................ - 03f0 0000000f 00000000 00000200 309f0000 ............0... - 0400 00000000 00000000 00000000 00000000 ................ - 0410 00000000 500e0000 00000000 770e0000 ....P.......w... - 0420 00000000 01005577 0e000000 000000b9 ......Uw........ - 0430 0e000000 00000001 0056b90e 00000000 .........V...... - 0440 0000be0e 00000000 00000400 f301559f ..............U. - 0450 00000000 00000000 00000000 00000000 ................ - 0460 00000000 00008a0e 00000000 00008a0e ................ - 0470 00000000 00000100 508a0e00 00000000 ........P....... - 0480 00bd0e00 00000000 0001005d bd0e0000 ...........].... - 0490 00000000 be0e0000 00000000 0300f301 ................ - 04a0 55000000 00000000 00000000 00000000 U............... - 04b0 00020000 008a0e00 00000000 008a0e00 ................ - 04c0 00000000 00020030 9f8a0e00 00000000 .......0........ - 04d0 009d0e00 00000000 0001005c 00000000 ...........\.... - 04e0 00000000 00000000 00000000 00000000 ................ - 04f0 0000000e 00000000 00000e0e 00000000 ................ - 0500 00000100 550e0e00 00000000 00260e00 ....U........&.. - 0510 00000000 00010056 260e0000 00000000 .......V&....... - 0520 440e0000 00000000 0400f301 559f0000 D...........U... - 0530 00000000 00000000 00000000 00000000 ................ - 0540 00000000 000e0000 00000000 130e0000 ................ - 0550 00000000 01005413 0e000000 00000043 ......T........C - 0560 0e000000 00000001 005c430e 00000000 .........\C..... - 0570 0000440e 00000000 00000400 f301549f ..D...........T. - 0580 00000000 00000000 00000000 00000000 ................ - 0590 00000000 00001d0e 00000000 0000220e ..............". - 05a0 00000000 00000100 50220e00 00000000 ........P"...... - 05b0 00400e00 00000000 00010053 400e0000 .@.........S@... - 05c0 00000000 440e0000 00000000 01005000 ....D.........P. - 05d0 00000000 00000000 00000000 00000000 ................ - 05e0 000000f0 0d000000 000000f6 0d000000 ................ - 05f0 00000001 0055f60d 00000000 0000f70d .....U.......... - 0600 00000000 00000400 f301559f 00000000 ..........U..... - 0610 00000000 00000000 00000000 00000000 ................ - 0620 f00d0000 00000000 f60d0000 00000000 ................ - 0630 010054f6 0d000000 000000f7 0d000000 ..T............. - 0640 00000004 00f30154 9f000000 00000000 .......T........ - 0650 00000000 00000000 00000000 00000050 ...............P - 0660 03000000 000000ed 03000000 00000001 ................ - 0670 0055ed03 00000000 0000ba0d 00000000 .U.............. - 0680 00000400 f301559f ba0d0000 00000000 ......U......... - 0690 ea0d0000 00000000 01005500 00000000 ..........U..... - 06a0 00000000 00000000 00000000 00000000 ................ - 06b0 00000050 03000000 000000ed 03000000 ...P............ - 06c0 00000001 0054ed03 00000000 0000ba0d .....T.......... - 06d0 00000000 00000400 f301549f ba0d0000 ..........T..... - 06e0 00000000 c40d0000 00000000 010054c4 ..............T. - 06f0 0d000000 000000ea 0d000000 00000004 ................ - 0700 00f30154 9f000000 00000000 00000000 ...T............ - 0710 00000000 00000000 00000000 00500300 .............P.. - 0720 00000000 00890300 00000000 00010051 ...............Q - 0730 89030000 00000000 ed030000 00000000 ................ - 0740 030091a0 7fed0300 00000000 00ba0d00 ................ - 0750 00000000 000400f3 01519fba 0d000000 .........Q...... - 0760 000000ea 0d000000 00000003 0091a07f ................ - 0770 00000000 00000000 00000000 00000000 ................ - 0780 02000000 c0030000 00000000 ed030000 ................ - 0790 00000000 0200309f ba0d0000 00000000 ......0......... - 07a0 ea0d0000 00000000 0200309f 00000000 ..........0..... - 07b0 00000000 00000000 00000000 00000000 ................ - 07c0 00010000 07040000 00000000 0a040000 ................ - 07d0 00000000 0100500a 04000000 00000014 ......P......... - 07e0 05000000 00000001 005e9107 00000000 .........^...... - 07f0 0000bc07 00000000 00000100 5e3a0a00 ............^:.. - 0800 00000000 00e60a00 00000000 0001005e ...............^ - 0810 00000000 00000000 00000000 00000000 ................ - 0820 00000001 00000000 07040000 00000000 ................ - 0830 14050000 00000000 01005f91 07000000 .........._..... - 0840 000000bc 07000000 00000001 005f3a0a ............._:. - 0850 00000000 0000450a 00000000 00000100 ......E......... - 0860 54450a00 00000000 00040b00 00000000 TE.............. - 0870 0001005f 00000000 00000000 00000000 ..._............ - 0880 00000000 00000001 00000704 00000000 ................ - 0890 00001405 00000000 00000300 91c87e91 ..............~. - 08a0 07000000 000000bc 07000000 00000003 ................ - 08b0 0091c87e 3a0a0000 00000000 040b0000 ...~:........... - 08c0 00000000 030091c8 7e000000 00000000 ........~....... - 08d0 00000000 00000000 00030000 00000000 ................ - 08e0 03030000 00000100 00000101 00070400 ................ - 08f0 00000000 003e0400 00000000 0001005f .....>........._ - 0900 3e040000 00000000 65040000 00000000 >.......e....... - 0910 01005465 04000000 00000072 04000000 ..Te.......r.... - 0920 00000001 00527204 00000000 00008704 .....Rr......... - 0930 00000000 00000300 72709fbb 04000000 ........rp...... - 0940 00000008 05000000 00000001 00520805 .............R.. - 0950 00000000 00001405 00000000 00000100 ................ - 0960 54910700 00000000 00bc0700 00000000 T............... - 0970 0001005f 3a0a0000 00000000 450a0000 ..._:.......E... - 0980 00000000 01005445 0a000000 000000d4 ......TE........ - 0990 0a000000 00000001 005fd40a 00000000 ........._...... - 09a0 0000f90a 00000000 00000100 54000000 ............T... - 09b0 00000000 00000000 00000000 00040000 ................ - 09c0 00000100 00000007 04000000 0000000a ................ - 09d0 04000000 00000006 007f0070 00229f0a ...........p.".. - 09e0 04000000 00000014 05000000 00000006 ................ - 09f0 007f007e 00229f91 07000000 000000bc ...~.".......... - 0a00 07000000 00000006 007f007e 00229f3a ...........~.".: - 0a10 0a000000 00000045 0a000000 00000006 .......E........ - 0a20 0074007e 00229f45 0a000000 000000e6 .t.~.".E........ - 0a30 0a000000 00000006 007f007e 00229f00 ...........~.".. - 0a40 00000000 00000000 00000000 00000008 ................ - 0a50 00000165 04000000 00000072 04000000 ...e.......r.... - 0a60 00000002 00720072 04000000 00000087 .....r.r........ - 0a70 04000000 00000002 00727000 00000000 .........rp..... - 0a80 00000000 00000000 00000008 01650400 .............e.. - 0a90 00000000 00870400 00000000 00010058 ...............X - 0aa0 00000000 00000000 00000000 00000000 ................ - 0ab0 0a018704 00000000 00009c04 00000000 ................ - 0ac0 00000100 5a000000 00000000 00000000 ....Z........... - 0ad0 00000000 000a019c 04000000 000000ae ................ - 0ae0 04000000 00000001 00550000 00000000 .........U...... - 0af0 00000000 00000000 00000a00 00000001 ................ - 0b00 ae040000 00000000 b1040000 00000000 ................ - 0b10 01005bb1 04000000 000000bb 04000000 ..[............. - 0b20 00000001 0051bb04 00000000 0000bb04 .....Q.......... - 0b30 00000000 00000100 5b000000 00000000 ........[....... - 0b40 00000000 00000000 00010091 07000000 ................ - 0b50 000000ad 07000000 00000001 005e0000 .............^.. - 0b60 00000000 00000000 00000000 00000100 ................ - 0b70 91070000 00000000 ad070000 00000000 ................ - 0b80 01005f00 00000000 00000000 00000000 .._............. - 0b90 00000001 00000091 07000000 000000ac ................ - 0ba0 07000000 00000009 00910070 00220888 ...........p.".. - 0bb0 1c9fac07 00000000 0000ad07 00000000 ................ - 0bc0 00000f00 7d000cff ffffff1a 91002208 ....}.........". - 0bd0 881c9f00 00000000 00000000 00000000 ................ - 0be0 00000002 00000000 003a0a00 00000000 .........:...... - 0bf0 00540a00 00000000 000b0040 7d001c0c .T.........@}... - 0c00 ffffffff 1a9f540a 00000000 00005b0a ......T.......[. - 0c10 00000000 00000100 515b0a00 00000000 ........Q[...... - 0c20 005c0a00 00000000 000b0040 7d001c0c .\.........@}... - 0c30 ffffffff 1a9f0000 00000000 00000000 ................ - 0c40 00000000 00000200 00003a0a 00000000 ..........:..... - 0c50 0000450a 00000000 00000100 54450a00 ..E.........TE.. - 0c60 00000000 005c0a00 00000000 0001005f .....\........._ - 0c70 00000000 00000000 00000000 00000000 ................ - 0c80 02000000 3a0a0000 00000000 5b0a0000 ....:.......[... - 0c90 00000000 09009100 70002208 881c9f5b ........p."....[ - 0ca0 0a000000 0000005c 0a000000 0000000f .......\........ - 0cb0 007d000c ffffffff 1a910022 08881c9f .}.........".... - 0cc0 00000000 00000000 00000000 00000000 ................ - 0cd0 02010101 01010100 5c0a0000 00000000 ........\....... - 0ce0 890a0000 00000000 040091f8 7e9f890a ............~... - 0cf0 00000000 0000a20a 00000000 00000400 ................ - 0d00 91fc7e9f a20a0000 00000000 bb0a0000 ..~............. - 0d10 00000000 04009180 7f9fbb0a 00000000 ................ - 0d20 0000d90a 00000000 00000400 91847f9f ................ - 0d30 00000000 00000000 00000000 00000000 ................ - 0d40 09025c0a 00000000 00006e0a 00000000 ..\.......n..... - 0d50 00000300 91f87e00 00000000 00000000 ......~......... - 0d60 00000000 00000009 00000101 025c0a00 .............\.. - 0d70 00000000 006b0a00 00000000 00030091 .....k.......... - 0d80 e87e6b0a 00000000 00006e0a 00000000 .~k.......n..... - 0d90 00000100 506e0a00 00000000 006e0a00 ....Pn.......n.. - 0da0 00000000 000a0070 0011b1f3 ddf1791e .......p......y. - 0db0 9f000000 00000000 00000000 00000000 ................ - 0dc0 00080289 0a000000 00000098 0a000000 ................ - 0dd0 00000003 0091fc7e 00000000 00000000 .......~........ - 0de0 00000000 00000000 08000001 0102890a ................ - 0df0 00000000 0000950a 00000000 00000300 ................ - 0e00 91ec7e95 0a000000 00000098 0a000000 ..~............. - 0e10 00000001 0050980a 00000000 0000980a .....P.......... - 0e20 00000000 00000a00 700011b1 f3ddf179 ........p......y - 0e30 1e9f0000 00000000 00000000 00000000 ................ - 0e40 00000802 a20a0000 00000000 b10a0000 ................ - 0e50 00000000 03009180 7f000000 00000000 ................ - 0e60 00000000 00000000 00080000 010102a2 ................ - 0e70 0a000000 000000ae 0a000000 00000003 ................ - 0e80 0091f07e ae0a0000 00000000 b10a0000 ...~............ - 0e90 00000000 010050b1 0a000000 000000b1 ......P......... - 0ea0 0a000000 0000000a 00700011 b1f3ddf1 .........p...... - 0eb0 791e9f00 00000000 00000000 00000000 y............... - 0ec0 00000008 02bb0a00 00000000 00ca0a00 ................ - 0ed0 00000000 00030091 847f0000 00000000 ................ - 0ee0 00000000 00000000 00000800 00010102 ................ - 0ef0 bb0a0000 00000000 c70a0000 00000000 ................ - 0f00 030091f4 7ec70a00 00000000 00ca0a00 ....~........... - 0f10 00000000 00010050 ca0a0000 00000000 .......P........ - 0f20 ca0a0000 00000000 0a007000 11b1f3dd ..........p..... - 0f30 f1791e9f 00000000 00000000 00000000 .y.............. - 0f40 00000000 00000000 e60a0000 00000000 ................ - 0f50 eb0a0000 00000000 010050eb 0a000000 ..........P..... - 0f60 000000fa 0a000000 00000001 005e0000 .............^.. - 0f70 00000000 00000000 00000000 00000000 ................ - 0f80 e60a0000 00000000 f90a0000 00000000 ................ - 0f90 01005400 00000000 00000000 00000000 ..T............. - 0fa0 00000000 00e60a00 00000000 00fa0a00 ................ - 0fb0 00000000 00040091 f87e9f00 00000000 .........~...... - 0fc0 00000000 00000000 00000000 00000000 ................ - 0fd0 00000000 00440500 00000000 00520500 .....D.......R.. - 0fe0 00000000 00010050 52050000 00000000 .......PR....... - 0ff0 89050000 00000000 01005ac4 0c000000 ..........Z..... - 1000 000000e3 0c000000 00000001 005a7e0d .............Z~. - 1010 00000000 0000990d 00000000 00000100 ................ - 1020 5a990d00 00000000 00ba0d00 00000000 Z............... - 1030 00030091 d87e0000 00000000 00000000 .....~.......... - 1040 00000000 00000000 00000000 44050000 ............D... - 1050 00000000 89050000 00000000 01005ec4 ..............^. - 1060 0c000000 00000010 0d000000 00000001 ................ - 1070 005e7e0d 00000000 0000ba0d 00000000 .^~............. - 1080 00000100 5e000000 00000000 00000000 ....^........... - 1090 00000000 00000000 00000044 05000000 ...........D.... - 10a0 00000054 06000000 00000003 0091c87e ...T...........~ - 10b0 980c0000 00000000 690d0000 00000000 ........i....... - 10c0 030091c8 7e7e0d00 00000000 00ba0d00 ....~~.......... - 10d0 00000000 00030091 c87e0000 00000000 .........~...... - 10e0 00000000 00000000 00000300 00000003 ................ - 10f0 03000000 00000100 00004405 00000000 ..........D..... - 1100 0000aa05 00000000 00000100 5eaa0500 ............^... - 1110 00000000 00ba0500 00000000 00010050 ...............P - 1120 ba050000 00000000 cc050000 00000000 ................ - 1130 03007070 9ffd0500 00000000 00480600 ..pp.........H.. - 1140 00000000 00010050 48060000 00000000 .......PH....... - 1150 54060000 00000000 01005e98 0c000000 T.........^..... - 1160 00000010 0d000000 00000001 005e640d .............^d. - 1170 00000000 0000690d 00000000 00000100 ......i......... - 1180 5e7e0d00 00000000 00ba0d00 00000000 ^~.............. - 1190 0001005e 00000000 00000000 00000000 ...^............ - 11a0 00000000 00000000 00000000 48050000 ............H... - 11b0 00000000 54060000 00000000 01005f98 ....T........._. - 11c0 0c000000 000000a8 0c000000 00000001 ................ - 11d0 005fc40c 00000000 0000690d 00000000 ._........i..... - 11e0 00000100 5f7e0d00 00000000 00ba0d00 ...._~.......... - 11f0 00000000 0001005f 00000000 00000000 ......._........ - 1200 00000000 00000000 08000001 aa050000 ................ - 1210 00000000 ba050000 00000000 02007000 ..............p. - 1220 ba050000 00000000 cc050000 00000000 ................ - 1230 02007070 00000000 00000000 00000000 ..pp............ - 1240 00000000 0801aa05 00000000 0000cc05 ................ - 1250 00000000 00000100 51000000 00000000 ........Q....... - 1260 00000000 00000000 000a01cc 05000000 ................ - 1270 000000de 05000000 00000001 00550000 .............U.. - 1280 00000000 00000000 00000000 00000a01 ................ - 1290 de050000 00000000 f0050000 00000000 ................ - 12a0 01005400 00000000 00000000 00000000 ..T............. - 12b0 0000000a 00000000 01f00500 00000000 ................ - 12c0 00f30500 00000000 0001005b f3050000 ...........[.... - 12d0 00000000 fd050000 00000000 010052fd ..............R. - 12e0 05000000 000000fd 05000000 00000001 ................ - 12f0 005b0000 00000000 00000000 00000000 .[.............. - 1300 00000000 a80c0000 00000000 ba0c0000 ................ - 1310 00000000 01005f00 00000000 00000000 ......_......... - 1320 00000000 00000000 00a80c00 00000000 ................ - 1330 00ba0c00 00000000 0001005e 00000000 ...........^.... - 1340 00000000 00000000 00000000 0000a80c ................ - 1350 00000000 0000ba0c 00000000 00000400 ................ - 1360 91f87e9f 00000000 00000000 00000000 ..~............. - 1370 00000000 01000000 0000c40c 00000000 ................ - 1380 0000dc0c 00000000 00000b00 407d001c ............@}.. - 1390 0cffffff ff1a9fdc 0c000000 000000e3 ................ - 13a0 0c000000 00000001 0051e30c 00000000 .........Q...... - 13b0 0000e40c 00000000 00000b00 407d001c ............@}.. - 13c0 0cffffff ff1a9f00 00000000 00000000 ................ - 13d0 00000000 00000001 00c40c00 00000000 ................ - 13e0 00e40c00 00000000 0001005e 00000000 ...........^.... - 13f0 00000000 00000000 00000000 01000000 ................ - 1400 c40c0000 00000000 e30c0000 00000000 ................ - 1410 09009100 70002208 881c9fe3 0c000000 ....p."......... - 1420 000000e4 0c000000 0000000f 007d000c .............}.. - 1430 ffffffff 1a910022 08881c9f 00000000 ......."........ - 1440 00000000 00000000 00000000 02010101 ................ - 1450 01010100 e40c0000 00000000 190d0000 ................ - 1460 00000000 040091f8 7e9f190d 00000000 ........~....... - 1470 0000320d 00000000 00000400 91fc7e9f ..2...........~. - 1480 320d0000 00000000 4b0d0000 00000000 2.......K....... - 1490 04009180 7f9f4b0d 00000000 0000690d ......K.......i. - 14a0 00000000 00000400 91847f9f 00000000 ................ - 14b0 00000000 00000000 00000000 0902e40c ................ - 14c0 00000000 0000f60c 00000000 00000300 ................ - 14d0 91f87e00 00000000 00000000 00000000 ..~............. - 14e0 00000009 00000101 02e40c00 00000000 ................ - 14f0 00f00c00 00000000 00030091 e87ef00c .............~.. - 1500 00000000 0000f60c 00000000 00000100 ................ - 1510 50f60c00 00000000 00f60c00 00000000 P............... - 1520 000a0070 0011b1f3 ddf1791e 9f000000 ...p......y..... - 1530 00000000 00000000 00000000 00080219 ................ - 1540 0d000000 00000028 0d000000 00000003 .......(........ - 1550 0091fc7e 00000000 00000000 00000000 ...~............ - 1560 00000000 08000001 0102190d 00000000 ................ - 1570 0000250d 00000000 00000300 91ec7e25 ..%...........~% - 1580 0d000000 00000028 0d000000 00000001 .......(........ - 1590 0050280d 00000000 0000280d 00000000 .P(.......(..... - 15a0 00000a00 700011b1 f3ddf179 1e9f0000 ....p......y.... - 15b0 00000000 00000000 00000000 00000802 ................ - 15c0 320d0000 00000000 410d0000 00000000 2.......A....... - 15d0 03009180 7f000000 00000000 00000000 ................ - 15e0 00000000 00080000 01010232 0d000000 ...........2.... - 15f0 0000003e 0d000000 00000003 0091f07e ...>...........~ - 1600 3e0d0000 00000000 410d0000 00000000 >.......A....... - 1610 01005041 0d000000 00000041 0d000000 ..PA.......A.... - 1620 0000000a 00700011 b1f3ddf1 791e9f00 .....p......y... - 1630 00000000 00000000 00000000 00000008 ................ - 1640 024b0d00 00000000 005a0d00 00000000 .K.......Z...... - 1650 00030091 847f0000 00000000 00000000 ................ - 1660 00000000 00000800 00010102 4b0d0000 ............K... - 1670 00000000 570d0000 00000000 030091f4 ....W........... - 1680 7e570d00 00000000 005a0d00 00000000 ~W.......Z...... - 1690 00010050 5a0d0000 00000000 5a0d0000 ...PZ.......Z... - 16a0 00000000 0a007000 11b1f3dd f1791e9f ......p......y.. - 16b0 00000000 00000000 00000000 00000000 ................ - 16c0 02000000 7e0d0000 00000000 990d0000 ....~........... - 16d0 00000000 01005a99 0d000000 0000009a ......Z......... - 16e0 0d000000 00000003 0091d87e 00000000 ...........~.... - 16f0 00000000 00000000 00000000 02007e0d ..............~. - 1700 00000000 00009a0d 00000000 00000100 ................ - 1710 5e000000 00000000 00000000 00000000 ^............... - 1720 00020000 007e0d00 00000000 00990d00 .....~.......... - 1730 00000000 00090091 00700022 08881c9f .........p.".... - 1740 990d0000 00000000 9a0d0000 00000000 ................ - 1750 0f007d00 0cffffff ff1a9100 2208881c ..}........."... - 1760 9f000000 00000000 00000000 00000000 ................ - 1770 00010000 000000c5 07000000 000000ef ................ - 1780 08000000 00000002 00389ff5 0b000000 .........8...... - 1790 00000098 0c000000 00000002 00389f69 .............8.i - 17a0 0d000000 0000007e 0d000000 00000002 .......~........ - 17b0 00389f00 00000000 00000000 00000000 .8.............. - 17c0 00000001 00000000 00c50700 00000000 ................ - 17d0 00ef0800 00000000 00030073 089ff50b ...........s.... - 17e0 00000000 0000980c 00000000 00000300 ................ - 17f0 73089f69 0d000000 0000007e 0d000000 s..i.......~.... - 1800 00000003 0073089f 00000000 00000000 .....s.......... - 1810 00000000 00000000 01000000 0000c507 ................ - 1820 00000000 0000ef08 00000000 00000300 ................ - 1830 91c87ef5 0b000000 00000098 0c000000 ..~............. - 1840 00000003 0091c87e 690d0000 00000000 .......~i....... - 1850 7e0d0000 00000000 030091c8 7e000000 ~...........~... - 1860 00000000 00000000 00000000 00040000 ................ - 1870 00000000 03030000 00000101 000000c5 ................ - 1880 07000000 00000003 08000000 00000003 ................ - 1890 0073089f 03080000 00000000 20080000 .s.......... ... - 18a0 00000000 01005e20 08000000 0000002a ......^ .......* - 18b0 08000000 00000001 00502a08 00000000 .........P*..... - 18c0 00003c08 00000000 00000300 70709f6d ..<.........pp.m - 18d0 08000000 0000007f 08000000 00000001 ................ - 18e0 0050bf08 00000000 0000ef08 00000000 .P.............. - 18f0 00000100 5ef50b00 00000000 00930c00 ....^........... - 1900 00000000 00030073 089f930c 00000000 .......s........ - 1910 0000980c 00000000 00000100 5e690d00 ............^i.. - 1920 00000000 007e0d00 00000000 00030073 .....~.........s - 1930 089f0000 00000000 00000000 00000000 ................ - 1940 00000500 00000000 c5070000 00000000 ................ - 1950 ef080000 00000000 03007310 9ff50b00 ..........s..... - 1960 00000000 00980c00 00000000 00030073 ...............s - 1970 109f690d 00000000 00007e0d 00000000 ..i.......~..... - 1980 00000300 73109f00 00000000 00000000 ....s........... - 1990 00000000 00000008 00000120 08000000 ........... .... - 19a0 0000002a 08000000 00000002 0070002a ...*.........p.* - 19b0 08000000 0000003c 08000000 00000002 .......<........ - 19c0 00707000 00000000 00000000 00000000 .pp............. - 19d0 00000008 01200800 00000000 003c0800 ..... .......<.. - 19e0 00000000 00010054 00000000 00000000 .......T........ - 19f0 00000000 00000000 0a013c08 00000000 ..........<..... - 1a00 00004e08 00000000 00000100 55000000 ..N.........U... - 1a10 00000000 00000000 00000000 000a014e ...............N - 1a20 08000000 00000060 08000000 00000001 .......`........ - 1a30 00520000 00000000 00000000 00000000 .R.............. - 1a40 00000a00 00000001 60080000 00000000 ........`....... - 1a50 63080000 00000000 01005a63 08000000 c.........Zc.... - 1a60 0000006d 08000000 00000001 00516d08 ...m.........Qm. - 1a70 00000000 00006d08 00000000 00000100 ......m......... - 1a80 5a000000 00000000 00000000 00000000 Z............... - 1a90 00000000 00d90800 00000000 00e40800 ................ - 1aa0 00000000 00010051 e4080000 00000000 .......Q........ - 1ab0 e5080000 00000000 01005f00 00000000 .........._..... - 1ac0 00000000 00000000 00000000 00d90800 ................ - 1ad0 00000000 00e50800 00000000 0001005e ...............^ - 1ae0 00000000 00000000 00000000 00000000 ................ - 1af0 0000d908 00000000 0000e508 00000000 ................ - 1b00 00000400 91f87e9f 00000000 00000000 ......~......... - 1b10 00000000 00000000 02000000 0000f50b ................ - 1b20 00000000 00000e0c 00000000 00000b00 ................ - 1b30 407d001c 0cffffff ff1a9f0e 0c000000 @}.............. - 1b40 00000015 0c000000 00000001 0051150c .............Q.. - 1b50 00000000 0000160c 00000000 00000b00 ................ - 1b60 407d001c 0cffffff ff1a9f00 00000000 @}.............. - 1b70 00000000 00000000 00000002 00f50b00 ................ - 1b80 00000000 00160c00 00000000 00030073 ...............s - 1b90 089f0000 00000000 00000000 00000000 ................ - 1ba0 00000200 0000f50b 00000000 0000150c ................ - 1bb0 00000000 00000900 91007000 2208881c ..........p."... - 1bc0 9f150c00 00000000 00160c00 00000000 ................ - 1bd0 000f007d 000cffff ffff1a91 00220888 ...}.........".. - 1be0 1c9f0000 00000000 00000000 00000000 ................ - 1bf0 00000201 01010101 0100160c 00000000 ................ - 1c00 0000480c 00000000 00000400 91f87e9f ..H...........~. - 1c10 480c0000 00000000 610c0000 00000000 H.......a....... - 1c20 040091fc 7e9f610c 00000000 00007a0c ....~.a.......z. - 1c30 00000000 00000400 91807f9f 7a0c0000 ............z... - 1c40 00000000 980c0000 00000000 04009184 ................ - 1c50 7f9f0000 00000000 00000000 00000000 ................ - 1c60 00000902 160c0000 00000000 390c0000 ............9... - 1c70 00000000 030091f8 7e000000 00000000 ........~....... - 1c80 00000000 00000000 00090000 01010216 ................ - 1c90 0c000000 00000033 0c000000 00000003 .......3........ - 1ca0 0091e87e 330c0000 00000000 390c0000 ...~3.......9... - 1cb0 00000000 01005039 0c000000 00000039 ......P9.......9 - 1cc0 0c000000 0000000a 00700011 b1f3ddf1 .........p...... - 1cd0 791e9f00 00000000 00000000 00000000 y............... - 1ce0 00000008 02480c00 00000000 00570c00 .....H.......W.. - 1cf0 00000000 00030091 fc7e0000 00000000 .........~...... - 1d00 00000000 00000000 00000800 00010102 ................ - 1d10 480c0000 00000000 540c0000 00000000 H.......T....... - 1d20 030091ec 7e540c00 00000000 00570c00 ....~T.......W.. - 1d30 00000000 00010050 570c0000 00000000 .......PW....... - 1d40 570c0000 00000000 0a007000 11b1f3dd W.........p..... - 1d50 f1791e9f 00000000 00000000 00000000 .y.............. - 1d60 00000000 0802610c 00000000 0000700c ......a.......p. - 1d70 00000000 00000300 91807f00 00000000 ................ - 1d80 00000000 00000000 00000008 00000101 ................ - 1d90 02610c00 00000000 006d0c00 00000000 .a.......m...... - 1da0 00030091 f07e6d0c 00000000 0000700c .....~m.......p. - 1db0 00000000 00000100 50700c00 00000000 ........Pp...... - 1dc0 00700c00 00000000 000a0070 0011b1f3 .p.........p.... - 1dd0 ddf1791e 9f000000 00000000 00000000 ..y............. - 1de0 00000000 0008027a 0c000000 00000089 .......z........ - 1df0 0c000000 00000003 0091847f 00000000 ................ - 1e00 00000000 00000000 00000000 08000001 ................ - 1e10 01027a0c 00000000 0000860c 00000000 ..z............. - 1e20 00000300 91f47e86 0c000000 00000089 ......~......... - 1e30 0c000000 00000001 0050890c 00000000 .........P...... - 1e40 0000890c 00000000 00000a00 700011b1 ............p... - 1e50 f3ddf179 1e9f0000 00000000 00000000 ...y............ - 1e60 00000000 00000200 690d0000 00000000 ........i....... - 1e70 7e0d0000 00000000 0200389f 00000000 ~.........8..... - 1e80 00000000 00000000 00000000 0200690d ..............i. - 1e90 00000000 00007e0d 00000000 00000300 ......~......... - 1ea0 73089f00 00000000 00000000 00000000 s............... - 1eb0 00000002 00690d00 00000000 007e0d00 .....i.......~.. - 1ec0 00000000 00090091 00700022 08881c9f .........p.".... - 1ed0 00000000 00000000 00000000 00000000 ................ - 1ee0 00020000 0000ef08 00000000 0000f908 ................ - 1ef0 00000000 00000200 389f2c09 00000000 ........8.,..... - 1f00 00003a0a 00000000 00000200 389f2b0b ..:.........8.+. - 1f10 00000000 0000f50b 00000000 00000200 ................ - 1f20 389f0000 00000000 00000000 00000000 8............... - 1f30 00000002 00000000 00000000 0001ef08 ................ - 1f40 00000000 0000f908 00000000 00000100 ................ - 1f50 5e2c0900 00000000 00590900 00000000 ^,.......Y...... - 1f60 0001005e fe090000 00000000 110a0000 ...^............ - 1f70 00000000 08007e00 70002223 109f110a ......~.p."#.... - 1f80 00000000 00001e0a 00000000 00000100 ................ - 1f90 5e5d0b00 00000000 00a10b00 00000000 ^].............. - 1fa0 0001005e a10b0000 00000000 f00b0000 ...^............ - 1fb0 00000000 03007308 9f000000 00000000 ......s......... - 1fc0 00000000 00000000 00000200 000000ef ................ - 1fd0 08000000 000000f9 08000000 00000003 ................ - 1fe0 0091c87e 2c090000 00000000 3a0a0000 ...~,.......:... - 1ff0 00000000 030091c8 7e2b0b00 00000000 ........~+...... - 2000 00f50b00 00000000 00030091 c87e0000 .............~.. - 2010 00000000 00000000 00000000 00000002 ................ - 2020 04000000 00030300 00000001 ef080000 ................ - 2030 00000000 f9080000 00000000 01005e2c ..............^, - 2040 09000000 00000059 09000000 00000001 .......Y........ - 2050 005e8009 00000000 00008a09 00000000 .^.............. - 2060 00000100 508a0900 00000000 00a90900 ....P........... - 2070 00000000 00030070 709fcf09 00000000 .......pp....... - 2080 0000e209 00000000 00000100 505d0b00 ............P].. - 2090 00000000 00a10b00 00000000 0001005e ...............^ - 20a0 a10b0000 00000000 f00b0000 00000000 ................ - 20b0 03007308 9f000000 00000000 00000000 ..s............. - 20c0 00000000 00000200 00000000 000000ef ................ - 20d0 08000000 000000f9 08000000 00000001 ................ - 20e0 005f3009 00000000 00003a0a 00000000 ._0.......:..... - 20f0 00000100 5f2b0b00 00000000 00380b00 ...._+.......8.. - 2100 00000000 0001005f 380b0000 00000000 ......._8....... - 2110 5d0b0000 00000000 03007310 9f5d0b00 ].........s..].. - 2120 00000000 00f50b00 00000000 0001005f ..............._ - 2130 00000000 00000000 00000000 00000000 ................ - 2140 0200ef08 00000000 0000f908 00000000 ................ - 2150 00000200 389f0000 00000000 00000000 ....8........... - 2160 00000000 00000200 ef080000 00000000 ................ - 2170 f9080000 00000000 01005e00 00000000 ..........^..... - 2180 00000000 00000000 00000002 000000ef ................ - 2190 08000000 000000f4 08000000 00000009 ................ - 21a0 00910070 00220888 1c9ff408 00000000 ...p.".......... - 21b0 0000f908 00000000 00000900 91007100 ..............q. - 21c0 2208881c 9f000000 00000000 00000000 "............... - 21d0 00000000 00080000 01800900 00000000 ................ - 21e0 008a0900 00000000 00020070 008a0900 ...........p.... - 21f0 00000000 00a90900 00000000 00020070 ...............p - 2200 70000000 00000000 00000000 00000000 p............... - 2210 00080180 09000000 000000a9 09000000 ................ - 2220 00000001 00510000 00000000 00000000 .....Q.......... - 2230 00000000 00000d0e 0e0fc209 00000000 ................ - 2240 0000c209 00000000 00000100 54c20900 ............T... - 2250 00000000 00c20900 00000000 00010058 ...............X - 2260 00000000 00000000 00000000 00000000 ................ - 2270 0a01a909 00000000 0000c209 00000000 ................ - 2280 00000100 55000000 00000000 00000000 ....U........... - 2290 00000000 00180000 000001c2 09000000 ................ - 22a0 000000c5 09000000 00000001 0059c509 .............Y.. - 22b0 00000000 0000cf09 00000000 00000100 ................ - 22c0 52cf0900 00000000 00cf0900 00000000 R............... - 22d0 00010059 00000000 00000000 00000000 ...Y............ - 22e0 00000000 0000380b 00000000 00004a0b ......8.......J. - 22f0 00000000 00000100 5f000000 00000000 ........_....... - 2300 00000000 00000000 00000038 0b000000 ...........8.... - 2310 0000004a 0b000000 00000004 0091f87e ...J...........~ - 2320 9f000000 00000000 00000000 00000000 ................ - 2330 00020000 005d0b00 00000000 00710b00 .....].......q.. - 2340 00000000 000b0040 71001c0c ffffffff .......@q....... - 2350 1a9f710b 00000000 00007a0b 00000000 ..q.......z..... - 2360 00000b00 4070001c 0cffffff ff1a9f00 ....@p.......... - 2370 00000000 00000000 00000000 00000002 ................ - 2380 005d0b00 00000000 007b0b00 00000000 .].......{...... - 2390 0001005e 00000000 00000000 00000000 ...^............ - 23a0 00000000 02005d0b 00000000 00007a0b ......].......z. - 23b0 00000000 00000900 91007000 2208881c ..........p."... - 23c0 9f000000 00000000 00000000 00000000 ................ - 23d0 00020101 01010101 007b0b00 00000000 .........{...... - 23e0 00a50b00 00000000 00040091 f87e9fa5 .............~.. - 23f0 0b000000 000000be 0b000000 00000004 ................ - 2400 0091fc7e 9fbe0b00 00000000 00d70b00 ...~............ - 2410 00000000 00040091 807f9fd7 0b000000 ................ - 2420 000000f5 0b000000 00000004 0091847f ................ - 2430 9f000000 00000000 00000000 00000000 ................ - 2440 0009027b 0b000000 0000008c 0b000000 ...{............ - 2450 00000003 0091f87e 00000000 00000000 .......~........ - 2460 00000000 00000000 09000001 01027b0b ..............{. - 2470 00000000 0000890b 00000000 00000300 ................ - 2480 91e87e89 0b000000 0000008c 0b000000 ..~............. - 2490 00000001 00508c0b 00000000 00008c0b .....P.......... - 24a0 00000000 00000a00 700011b1 f3ddf179 ........p......y - 24b0 1e9f0000 00000000 00000000 00000000 ................ - 24c0 00000802 a50b0000 00000000 b40b0000 ................ - 24d0 00000000 030091fc 7e000000 00000000 ........~....... - 24e0 00000000 00000000 00080000 010102a5 ................ - 24f0 0b000000 000000b1 0b000000 00000003 ................ - 2500 0091ec7e b10b0000 00000000 b40b0000 ...~............ - 2510 00000000 010050b4 0b000000 000000b4 ......P......... - 2520 0b000000 0000000a 00700011 b1f3ddf1 .........p...... - 2530 791e9f00 00000000 00000000 00000000 y............... - 2540 00000008 02be0b00 00000000 00cd0b00 ................ - 2550 00000000 00030091 807f0000 00000000 ................ - 2560 00000000 00000000 00000800 00010102 ................ - 2570 be0b0000 00000000 ca0b0000 00000000 ................ - 2580 030091f0 7eca0b00 00000000 00cd0b00 ....~........... - 2590 00000000 00010050 cd0b0000 00000000 .......P........ - 25a0 cd0b0000 00000000 0a007000 11b1f3dd ..........p..... - 25b0 f1791e9f 00000000 00000000 00000000 .y.............. - 25c0 00000000 0802d70b 00000000 0000e60b ................ - 25d0 00000000 00000300 91847f00 00000000 ................ - 25e0 00000000 00000000 00000008 00000101 ................ - 25f0 02d70b00 00000000 00e30b00 00000000 ................ - 2600 00030091 f47ee30b 00000000 0000e60b .....~.......... - 2610 00000000 00000100 50e60b00 00000000 ........P....... - 2620 00e60b00 00000000 000a0070 0011b1f3 ...........p.... - 2630 ddf1791e 9f000000 00000000 00000000 ..y............. - 2640 00000000 00000000 00000000 006b0300 .............k.. - 2650 00000000 00890300 00000000 00010051 ...............Q - 2660 89030000 00000000 ed030000 00000000 ................ - 2670 030091a0 7fed0300 00000000 00ba0d00 ................ - 2680 00000000 000400f3 01519fba 0d000000 .........Q...... - 2690 000000ea 0d000000 00000003 0091a07f ................ - 26a0 00000000 00000000 00000000 00000000 ................ - 26b0 00000000 00000000 00000000 6b030000 ............k... - 26c0 00000000 e8030000 00000000 040091e0 ................ - 26d0 7e9fe803 00000000 0000ed03 00000000 ~............... - 26e0 00000100 50ed0300 00000000 00ba0d00 ....P........... - 26f0 00000000 00030091 c87eba0d 00000000 .........~...... - 2700 0000cd0d 00000000 00000400 91e07e9f ..............~. - 2710 cd0d0000 00000000 dd0d0000 00000000 ................ - 2720 010050dd 0d000000 000000ea 0d000000 ..P............. - 2730 00000003 0091c87e 00000000 00000000 .......~........ - 2740 00000000 00000000 0100a003 00000000 ................ - 2750 0000c003 00000000 00000300 082c9f00 .............,.. - 2760 00000000 00000000 00000000 00000001 ................ - 2770 00a00300 00000000 00c00300 00000000 ................ - 2780 00040091 907f9f00 00000000 00000000 ................ - 2790 00000000 00000001 00a00300 00000000 ................ - 27a0 00c00300 00000000 00040091 e07e9f00 .............~.. - 27b0 00000000 00000000 00000000 00000001 ................ - 27c0 01000001 00000067 06000000 0000008e .......g........ - 27d0 07000000 00000003 0091c87e 040b0000 ...........~.... - 27e0 00000000 2b0b0000 00000000 030091c8 ....+........... - 27f0 7ed20d00 00000000 00dd0d00 00000000 ~............... - 2800 00010050 dd0d0000 00000000 ea0d0000 ...P............ - 2810 00000000 030091c8 7e000000 00000000 ........~....... - 2820 00000000 00000000 00000000 00000079 ...............y - 2830 06000000 0000007d 06000000 00000001 .......}........ - 2840 00507d06 00000000 0000a106 00000000 .P}............. - 2850 00000100 59260b00 00000000 002b0b00 ....Y&.......+.. - 2860 00000000 00010050 00000000 00000000 .......P........ - 2870 00000000 00000000 02017d06 00000000 ..........}..... - 2880 00008e07 00000000 00000200 309f0000 ............0... - 2890 00000000 00000000 00000000 00000100 ................ - 28a0 00020202 00020200 00020200 00020203 ................ - 28b0 7d060000 00000000 88060000 00000000 }............... - 28c0 0c009188 7f94040c ffffffff 1a9f8806 ................ - 28d0 00000000 0000ac06 00000000 00000100 ................ - 28e0 50ac0600 00000000 00cc0600 00000000 P............... - 28f0 00010052 00070000 00000000 1c070000 ...R............ - 2900 00000000 0100501c 07000000 00000020 ......P........ - 2910 07000000 00000003 00707f9f 20070000 .........p.. ... - 2920 00000000 3a070000 00000000 0100503a ....:.........P: - 2930 07000000 00000040 07000000 00000005 .......@........ - 2940 00700031 2e9f4007 00000000 00005807 .p.1..@.......X. - 2950 00000000 00000200 319f5807 00000000 ........1.X..... - 2960 00005807 00000000 00000200 309f0000 ..X.........0... - 2970 00000000 00000000 00000000 00000107 ................ - 2980 07070707 07030002 02020202 02037d06 ..............}. - 2990 00000000 00009206 00000000 00000400 ................ - 29a0 91f87e9f 92060000 00000000 b2060000 ..~............. - 29b0 00000000 040091fc 7e9fb206 00000000 ........~....... - 29c0 0000d206 00000000 00000400 91807f9f ................ - 29d0 d2060000 00000000 e8060000 00000000 ................ - 29e0 04009184 7f9f0007 00000000 00000507 ................ - 29f0 00000000 00000100 54050700 00000000 ........T....... - 2a00 00220700 00000000 00030074 019f2207 .".........t..". - 2a10 00000000 00004007 00000000 00000300 ......@......... - 2a20 74029f40 07000000 00000058 07000000 t..@.......X.... - 2a30 00000003 0074039f 00000000 00000000 .....t.......... - 2a40 00000000 00000000 01050500 00000005 ................ - 2a50 05000000 00050500 00000002 02000000 ................ - 2a60 00020200 00020200 00007d06 00000000 ..........}..... - 2a70 00009206 00000000 00000100 59920600 ............Y... - 2a80 00000000 00a10600 00000000 00100091 ................ - 2a90 f87e9404 11bddcca 957c1e79 00229fa1 .~.......|.y.".. - 2aa0 06000000 000000a5 06000000 00000001 ................ - 2ab0 0059ac06 00000000 0000b206 00000000 .Y.............. - 2ac0 00000100 59b20600 00000000 00c10600 ....Y........... - 2ad0 00000000 00100091 fc7e9404 11bddcca .........~...... - 2ae0 957c1e79 00229fc1 06000000 000000c5 .|.y.".......... - 2af0 06000000 00000001 0059cc06 00000000 .........Y...... - 2b00 0000d206 00000000 00000100 59d20600 ............Y... - 2b10 00000000 00dd0600 00000000 00100091 ................ - 2b20 807f9404 11bddcca 957c1e79 00229fdd .........|.y.".. - 2b30 06000000 000000e1 06000000 00000001 ................ - 2b40 0059e806 00000000 00000507 00000000 .Y.............. - 2b50 00000100 59050700 00000000 00110700 ....Y........... - 2b60 00000000 00110074 00940108 ff1a0cb1 .......t........ - 2b70 6756161e 7900229f 11070000 00000000 gV..y."......... - 2b80 15070000 00000000 0100591c 07000000 ..........Y..... - 2b90 00000022 07000000 00000001 00592207 ...".........Y". - 2ba0 00000000 00002f07 00000000 00001100 ....../......... - 2bb0 74019401 08ff1a0c b1675616 1e790022 t........gV..y." - 2bc0 9f3a0700 00000000 00400700 00000000 .:.......@...... - 2bd0 00010059 40070000 00000000 4d070000 ...Y@.......M... - 2be0 00000000 11007402 940108ff 1a0cb167 ......t........g - 2bf0 56161e79 00229f58 07000000 0000006a V..y.".X.......j - 2c00 07000000 00000001 00590000 00000000 .........Y...... - 2c10 00000000 00000000 00000205 02050205 ................ - 2c20 92060000 00000000 92060000 00000000 ................ - 2c30 0200309f b2060000 00000000 b2060000 ..0............. - 2c40 00000000 0200309f d2060000 00000000 ......0......... - 2c50 d2060000 00000000 0200309f 00000000 ..........0..... - 2c60 00000000 00000000 00000000 02050205 ................ - 2c70 02059206 00000000 00009206 00000000 ................ - 2c80 00000400 91f87e9f b2060000 00000000 ......~......... - 2c90 b2060000 00000000 040091fc 7e9fd206 ............~... - 2ca0 00000000 0000d206 00000000 00000400 ................ - 2cb0 91807f9f 00000000 00000000 00000000 ................ - 2cc0 00000000 04000000 00015807 00000000 ..........X..... - 2cd0 00007507 00000000 00000100 59750700 ..u.........Yu.. - 2ce0 00000000 008e0700 00000000 00010050 ...............P - 2cf0 8e070000 00000000 8e070000 00000000 ................ - 2d00 06007000 7100279f 00000000 00000000 ..p.q.'......... - 2d10 00000000 00000000 00000000 00000000 ................ - 2d20 a0020000 00000000 ba020000 00000000 ................ - 2d30 010055ba 02000000 000000c8 02000000 ..U............. - 2d40 00000001 0053c802 00000000 0000d302 .....S.......... - 2d50 00000000 00000300 73709fd3 02000000 ........sp...... - 2d60 0000004d 03000000 00000004 00f30155 ...M...........U - 2d70 9f000000 00000000 00000000 00000000 ................ - 2d80 00000000 000000a0 02000000 000000aa ................ - 2d90 02000000 00000001 0054aa02 00000000 .........T...... - 2da0 0000d302 00000000 00000100 56d30200 ............V... - 2db0 00000000 004d0300 00000000 000400f3 .....M.......... - 2dc0 01549f00 00000000 00000000 00000000 .T.............. - 2dd0 00000000 000000a0 02000000 000000be ................ - 2de0 02000000 00000001 0051be02 00000000 .........Q...... - 2df0 00004d03 00000000 00000400 f301519f ..M...........Q. - 2e00 00000000 00000000 00000000 00000000 ................ - 2e10 0200bf02 00000000 0000d302 00000000 ................ - 2e20 00000200 309f0000 00000000 00000000 ....0........... - 2e30 00000000 00000000 00006002 00000000 ..........`..... - 2e40 00006a02 00000000 00000100 546a0200 ..j.........Tj.. - 2e50 00000000 00870200 00000000 000400f3 ................ - 2e60 01549f00 00000000 00000000 00000000 .T.............. - 2e70 00000000 00000060 02000000 0000006a .......`.......j - 2e80 02000000 00000001 00516a02 00000000 .........Qj..... - 2e90 00008702 00000000 00000400 f301519f ..............Q. - 2ea0 00000000 00000000 00000000 00000000 ................ - 2eb0 00006202 00000000 00008702 00000000 ..b............. - 2ec0 00000100 50000000 00000000 00000000 ....P........... - 2ed0 00000000 00020000 00000162 02000000 ...........b.... - 2ee0 0000006a 02000000 00000002 00309f6a ...j.........0.j - 2ef0 02000000 00000077 02000000 00000007 .......w........ - 2f00 007400f3 01541c9f 77020000 00000000 .t...T..w....... - 2f10 7f020000 00000000 0800f301 54207400 ............T t. - 2f20 229f0000 00000000 00000000 00000000 "............... - 2f30 00000000 00000000 00000000 00000000 ................ - 2f40 0000c001 00000000 0000d201 00000000 ................ - 2f50 00000100 55d20100 00000000 00f80100 ....U........... - 2f60 00000000 00010053 f8010000 00000000 .......S........ - 2f70 fa010000 00000000 0400f301 559ffa01 ............U... - 2f80 00000000 00000902 00000000 00000100 ................ - 2f90 53090200 00000000 000b0200 00000000 S............... - 2fa0 000400f3 01559f0b 02000000 0000001d .....U.......... - 2fb0 02000000 00000001 00531d02 00000000 .........S...... - 2fc0 00002302 00000000 00000400 f301559f ..#...........U. - 2fd0 23020000 00000000 48020000 00000000 #.......H....... - 2fe0 01005300 00000000 00000000 00000000 ..S............. - 2ff0 00000000 00000000 00000000 00000000 ................ - 3000 000000c0 01000000 000000cf 01000000 ................ - 3010 00000001 0054cf01 00000000 0000f901 .....T.......... - 3020 00000000 00000100 56f90100 00000000 ........V....... - 3030 00fa0100 00000000 000400f3 01549ffa .............T.. - 3040 01000000 0000000a 02000000 00000001 ................ - 3050 00560a02 00000000 00000b02 00000000 .V.............. - 3060 00000400 f301549f 0b020000 00000000 ......T......... - 3070 1e020000 00000000 0100561e 02000000 ..........V..... - 3080 00000023 02000000 00000004 00f30154 ...#...........T - 3090 9f230200 00000000 00480200 00000000 .#.......H...... - 30a0 00010056 00000000 00000000 00000000 ...V............ - 30b0 00000000 02000000 00000000 00000000 ................ - 30c0 00000000 c0010000 00000000 d2010000 ................ - 30d0 00000000 010055d2 01000000 000000f8 ......U......... - 30e0 01000000 00000001 0053f801 00000000 .........S...... - 30f0 0000fa01 00000000 00000400 f301559f ..............U. - 3100 fa010000 00000000 09020000 00000000 ................ - 3110 01005309 02000000 0000000b 02000000 ..S............. - 3120 00000004 00f30155 9f0b0200 00000000 .......U........ - 3130 001d0200 00000000 00010053 1d020000 ...........S.... - 3140 00000000 23020000 00000000 0400f301 ....#........... - 3150 559f2302 00000000 00004802 00000000 U.#.......H..... - 3160 00000100 53000000 00000000 00000000 ....S........... - 3170 00000000 00030000 00000000 00000000 ................ - 3180 00000000 00c00100 00000000 00cf0100 ................ - 3190 00000000 00010054 cf010000 00000000 .......T........ - 31a0 f9010000 00000000 010056f9 01000000 ..........V..... - 31b0 000000fa 01000000 00000004 00f30154 ...............T - 31c0 9ffa0100 00000000 000a0200 00000000 ................ - 31d0 00010056 0a020000 00000000 0b020000 ...V............ - 31e0 00000000 0400f301 549f0b02 00000000 ........T....... - 31f0 00001e02 00000000 00000100 561e0200 ............V... - 3200 00000000 00230200 00000000 000400f3 .....#.......... - 3210 01549f23 02000000 00000048 02000000 .T.#.......H.... - 3220 00000001 00560000 00000000 00000000 .....V.......... - 3230 00000000 00000000 00000000 00000000 ................ - 3240 d7010000 00000000 f3010000 00000000 ................ - 3250 010050fa 01000000 00000006 02000000 ..P............. - 3260 00000001 00500b02 00000000 00002202 .....P........". - 3270 00000000 00000100 50230200 00000000 ........P#...... - 3280 002c0200 00000000 00010050 31020000 .,.........P1... - 3290 00000000 46020000 00000000 01005000 ....F.........P. - 32a0 00000000 00000000 00000000 00000000 ................ - 32b0 00000000 00000010 00000000 0000002f .............../ - 32c0 00000000 00000001 00552f00 00000000 .........U/..... - 32d0 00003b00 00000000 00000400 f301559f ..;...........U. - 32e0 3b000000 00000000 50000000 00000000 ;.......P....... - 32f0 01005550 00000000 000000d8 00000000 ..UP............ - 3300 00000004 00f30155 9f000000 00000000 .......U........ - 3310 00000000 00000000 00000000 00000000 ................ - 3320 00100000 00000000 002f0000 00000000 ........./...... - 3330 00010054 2f000000 00000000 3b000000 ...T/.......;... - 3340 00000000 0400f301 549f3b00 00000000 ........T.;..... - 3350 00005000 00000000 00000100 54500000 ..P.........TP.. - 3360 00000000 00d80000 00000000 000400f3 ................ - 3370 01549f00 00000000 00000000 00000000 .T.............. - 3380 00000000 00000050 00000000 000000af .......P........ - 3390 00000000 00000001 005cc100 00000000 .........\...... - 33a0 0000d800 00000000 00000100 5c000000 ............\... - 33b0 00000000 00000000 00000000 00000000 ................ - 33c0 00020000 00500000 00000000 00780000 .....P.......x.. - 33d0 00000000 00010056 78000000 00000000 .......Vx....... - 33e0 81000000 00000000 03007668 9f810000 ..........vh.... - 33f0 00000000 00af0000 00000000 00010056 ...............V - 3400 c1000000 00000000 d8000000 00000000 ................ - 3410 01005600 00000000 00000000 00000000 ..V............. - 3420 00000000 00000000 00000000 00000000 ................ - 3430 00e00000 00000000 00ef0000 00000000 ................ - 3440 00010055 ef000000 00000000 22010000 ...U........"... - 3450 00000000 01005622 01000000 00000023 ......V".......# - 3460 01000000 00000004 00f30155 9f230100 ...........U.#.. - 3470 00000000 00380100 00000000 00010056 .....8.........V - 3480 38010000 00000000 39010000 00000000 8.......9....... - 3490 0400f301 559f3901 00000000 00004e01 ....U.9.......N. - 34a0 00000000 00000100 564e0100 00000000 ........VN...... - 34b0 004f0100 00000000 000400f3 01559f00 .O...........U.. - 34c0 00000000 00000000 00000000 00000000 ................ - 34d0 00000000 00000000 00000000 00e00000 ................ - 34e0 00000000 00f30000 00000000 00010054 ...............T - 34f0 f3000000 00000000 21010000 00000000 ........!....... - 3500 01005321 01000000 00000023 01000000 ..S!.......#.... - 3510 00000004 00f30154 9f230100 00000000 .......T.#...... - 3520 00370100 00000000 00010053 37010000 .7.........S7... - 3530 00000000 39010000 00000000 0400f301 ....9........... - 3540 549f3901 00000000 00004d01 00000000 T.9.......M..... - 3550 00000100 534d0100 00000000 004f0100 ....SM.......O.. - 3560 00000000 000400f3 01549f00 00000000 .........T...... - 3570 00000000 00000000 00000000 010f0100 ................ - 3580 00000000 001c0100 00000000 00010053 ...............S - 3590 00000000 00000000 00000000 00000000 ................ - 35a0 00010f01 00000000 00001c01 00000000 ................ - 35b0 00000100 56000000 00000000 00000000 ....V........... - 35c0 00000000 00000000 00000000 00000050 ...............P - 35d0 01000000 00000071 01000000 00000001 .......q........ - 35e0 00557101 00000000 0000a801 00000000 .Uq............. - 35f0 00000100 5ca80100 00000000 00ac0100 ....\........... - 3600 00000000 00010055 ac010000 00000000 .......U........ - 3610 ad010000 00000000 0400f301 559fad01 ............U... - 3620 00000000 0000b101 00000000 00000100 ................ - 3630 55000000 00000000 00000000 00000000 U............... - 3640 00000000 00000050 01000000 00000071 .......P.......q - 3650 01000000 00000001 00547101 00000000 .........Tq..... - 3660 0000ad01 00000000 00000400 f301549f ..............T. - 3670 ad010000 00000000 b1010000 00000000 ................ - 3680 01005400 00000000 00000000 00000000 ..T............. - 3690 00000000 005a0100 00000000 00710100 .....Z.......q.. - 36a0 00000000 00020030 9f000000 00000000 .......0........ - 36b0 00000000 00000000 00000000 00010000 ................ - 36c0 00710100 00000000 007c0100 00000000 .q.......|...... - 36d0 00010053 7c010000 00000000 81010000 ...S|........... - 36e0 00000000 03007368 9f810100 00000000 ......sh........ - 36f0 00970100 00000000 00010053 97010000 ...........S.... - 3700 00000000 a1010000 00000000 03007368 ..............sh - 3710 9f000000 00000000 00000000 00000000 ................ - 3720 00000000 00000000 00000000 00000000 ................ - 3730 10000000 00000029 10000000 00000001 .......)........ - 3740 00552910 00000000 00007b10 00000000 .U).......{..... - 3750 00000100 567b1000 00000000 00c91200 ....V{.......... - 3760 00000000 000400f3 01559fc9 12000000 .........U...... - 3770 000000d0 12000000 00000001 0055d012 .............U.. - 3780 00000000 00003113 00000000 00000400 ......1......... - 3790 f301559f 31130000 00000000 38130000 ..U.1.......8... - 37a0 00000000 01005638 13000000 0000003d ......V8.......= - 37b0 13000000 00000004 00f30155 9f000000 ...........U.... - 37c0 00000000 00000000 00000000 00000000 ................ - 37d0 00000000 00000000 00001000 00000000 ................ - 37e0 00301000 00000000 00010054 30100000 .0.........T0... - 37f0 00000000 5c100000 00000000 0100535c ....\.........S\ - 3800 10000000 000000c9 12000000 00000004 ................ - 3810 00f30154 9fc91200 00000000 00d41200 ...T............ - 3820 00000000 00010054 d4120000 00000000 .......T........ - 3830 31130000 00000000 0400f301 549f3113 1...........T.1. - 3840 00000000 00003d13 00000000 00000100 ......=......... - 3850 53000000 00000000 00000000 00000000 S............... - 3860 00000000 00000000 00000000 10000000 ................ - 3870 00000030 10000000 00000001 00513010 ...0.........Q0. - 3880 00000000 00007b10 00000000 00000300 ......{......... - 3890 91b87f7b 10000000 000000c9 12000000 ...{............ - 38a0 00000004 00f30151 9fc91200 00000000 .......Q........ - 38b0 00d41200 00000000 00010051 d4120000 ...........Q.... - 38c0 00000000 3d130000 00000000 030091b8 ....=........... - 38d0 7f000000 00000000 00000000 00000000 ................ - 38e0 00000000 00000000 00000000 10000000 ................ - 38f0 00000030 10000000 00000001 00523010 ...0.........R0. - 3900 00000000 00007b10 00000000 00000300 ......{......... - 3910 91b07f7b 10000000 000000c9 12000000 ...{............ - 3920 00000004 00f30152 9fc91200 00000000 .......R........ - 3930 00d41200 00000000 00010052 d4120000 ...........R.... - 3940 00000000 3d130000 00000000 030091b0 ....=........... - 3950 7f000000 00000000 00000000 00000000 ................ - 3960 00000000 00000000 002c1000 00000000 .........,...... - 3970 00301000 00000000 00010052 30100000 .0.........R0... - 3980 00000000 7b100000 00000000 030091b0 ....{........... - 3990 7f7b1000 00000000 00c91200 00000000 .{.............. - 39a0 000400f3 01529f31 13000000 0000003d .....R.1.......= - 39b0 13000000 00000003 0091b07f 00000000 ................ - 39c0 00000000 00000000 00000000 00000000 ................ - 39d0 00000000 2c100000 00000000 30100000 ....,.......0... - 39e0 00000000 01005130 10000000 0000007b ......Q0.......{ - 39f0 10000000 00000003 0091b87f 7b100000 ............{... - 3a00 00000000 c9120000 00000000 0400f301 ................ - 3a10 519f3113 00000000 00003d13 00000000 Q.1.......=..... - 3a20 00000300 91b87f00 00000000 00000000 ................ - 3a30 00000000 00000000 00000000 0000002c ..............., - 3a40 10000000 00000030 10000000 00000001 .......0........ - 3a50 00543010 00000000 00005c10 00000000 .T0.......\..... - 3a60 00000100 535c1000 00000000 00c91200 ....S\.......... - 3a70 00000000 000400f3 01549f31 13000000 .........T.1.... - 3a80 0000003d 13000000 00000001 00530000 ...=.........S.. - 3a90 00000000 00000000 00000000 00000000 ................ - 3aa0 00000000 00002c10 00000000 00007b10 ......,.......{. - 3ab0 00000000 00000100 567b1000 00000000 ........V{...... - 3ac0 00c91200 00000000 000400f3 01559f31 .............U.1 - 3ad0 13000000 00000038 13000000 00000001 .......8........ - 3ae0 00563813 00000000 00003d13 00000000 .V8.......=..... - 3af0 00000400 f301559f 00000000 00000000 ......U......... - 3b00 00000000 00000000 03000000 2c100000 ............,... - 3b10 00000000 7b100000 00000000 0200309f ....{.........0. - 3b20 31130000 00000000 3d130000 00000000 1.......=....... - 3b30 0200309f 00000000 00000000 00000000 ..0............. - 3b40 00000000 04000000 00000000 00000000 ................ - 3b50 00000000 00000000 00002c10 00000000 ..........,..... - 3b60 00007b10 00000000 00000200 309f7b10 ..{.........0.{. - 3b70 00000000 00003011 00000000 00000300 ......0......... - 3b80 91947f78 11000000 000000b9 11000000 ...x............ - 3b90 00000003 0091947f b9110000 00000000 ................ - 3ba0 c1110000 00000000 010050c1 11000000 ..........P..... - 3bb0 00000032 12000000 00000003 0091947f ...2............ - 3bc0 32120000 00000000 3a120000 00000000 2.......:....... - 3bd0 0100503a 12000000 00000078 12000000 ..P:.......x.... - 3be0 00000003 0091947f 7d120000 00000000 ........}....... - 3bf0 a2120000 00000000 03009194 7fa21200 ................ - 3c00 00000000 00aa1200 00000000 00010050 ...............P - 3c10 aa120000 00000000 c9120000 00000000 ................ - 3c20 03009194 7f311300 00000000 003d1300 .....1.......=.. - 3c30 00000000 00020030 9f000000 00000000 .......0........ - 3c40 00000000 00000000 00050001 00000000 ................ - 3c50 0000002c 10000000 0000007b 10000000 ...,.......{.... - 3c60 00000002 00309f7b 10000000 000000a7 .....0.{........ - 3c70 10000000 00000003 0091f87e 78110000 ...........~x... - 3c80 00000000 78120000 00000000 030091f8 ....x........... - 3c90 7e7d1200 00000000 00c91200 00000000 ~}.............. - 3ca0 00030091 f87e3113 00000000 00003d13 .....~1.......=. - 3cb0 00000000 00000200 309f0000 00000000 ........0....... - 3cc0 00000000 00000000 00000600 00002c10 ..............,. - 3cd0 00000000 0000c912 00000000 00000400 ................ - 3ce0 0a00049f 31130000 00000000 3d130000 ....1.......=... - 3cf0 00000000 04000a00 049f0000 00000000 ................ - 3d00 00000000 00000000 00000700 00000000 ................ - 3d10 00000000 00002c10 00000000 00007b10 ......,.......{. - 3d20 00000000 00000400 0a00049f 7b100000 ............{... - 3d30 00000000 c7100000 00000000 010053c7 ..............S. - 3d40 10000000 000000f1 10000000 00000001 ................ - 3d50 005cf110 00000000 00003011 00000000 .\........0..... - 3d60 00000100 53781100 00000000 00c91200 ....Sx.......... - 3d70 00000000 00010053 31130000 00000000 .......S1....... - 3d80 3d130000 00000000 04000a00 049f0000 =............... - 3d90 00000000 00000000 00000000 00000000 ................ - 3da0 00000000 00000000 00000000 00000000 ................ - 3db0 00000000 00000000 39100000 00000000 ........9....... - 3dc0 3d100000 00000000 0100503d 10000000 =.........P=.... - 3dd0 0000006f 11000000 00000001 005d6f11 ...o.........]o. - 3de0 00000000 00007711 00000000 00000100 ......w......... - 3df0 55781100 00000000 00c11100 00000000 Ux.............. - 3e00 0001005d c1110000 00000000 d9110000 ...]............ - 3e10 00000000 010050da 11000000 000000e2 ......P......... - 3e20 11000000 00000001 0050e211 00000000 .........P...... - 3e30 00003a12 00000000 00000100 5d3a1200 ..:.........]:.. - 3e40 00000000 00511200 00000000 00010050 .....Q.........P - 3e50 52120000 00000000 5a120000 00000000 R.......Z....... - 3e60 0100505a 12000000 000000aa 12000000 ..PZ............ - 3e70 00000001 005daa12 00000000 0000c112 .....].......... - 3e80 00000000 00000100 50c21200 00000000 ........P....... - 3e90 00c91200 00000000 00010050 31130000 ...........P1... - 3ea0 00000000 3d130000 00000000 01005d00 ....=.........]. - 3eb0 00000000 00000000 00000000 00000001 ................ - 3ec0 00000000 01010000 00000000 00391000 .............9.. - 3ed0 00000000 007b1000 00000000 0004000a .....{.......... - 3ee0 00049fc7 10000000 000000de 10000000 ................ - 3ef0 00000001 005fde10 00000000 0000e610 ....._.......... - 3f00 00000000 00000400 7f80789f e6100000 ..........x..... - 3f10 00000000 f1100000 00000000 01005f16 .............._. - 3f20 11000000 0000001b 11000000 00000001 ................ - 3f30 00501b11 00000000 00003011 00000000 .P........0..... - 3f40 00000300 91807f31 13000000 0000003d .......1.......= - 3f50 13000000 00000004 000a0004 9f000000 ................ - 3f60 00000000 00000000 00000000 00020000 ................ - 3f70 00000039 10000000 0000007b 10000000 ...9.......{.... - 3f80 00000004 000a0004 9fd41000 00000000 ................ - 3f90 00f11000 00000000 0001005e 31130000 ...........^1... - 3fa0 00000000 3d130000 00000000 04000a00 ....=........... - 3fb0 049f0000 00000000 00000000 00000000 ................ - 3fc0 00000000 00000000 00000000 00000000 ................ - 3fd0 41100000 00000000 4c100000 00000000 A.......L....... - 3fe0 0100504c 10000000 000000c4 10000000 ..PL............ - 3ff0 00000001 005cc410 00000000 0000e510 .....\.......... - 4000 00000000 00000100 50e61000 00000000 ........P....... - 4010 00f11000 00000000 00010050 f1100000 ...........P.... - 4020 00000000 6d110000 00000000 01005c78 ....m.........\x - 4030 11000000 000000c9 12000000 00000001 ................ - 4040 005c3113 00000000 00003d13 00000000 .\1.......=..... - 4050 00000100 50000000 00000000 00000000 ....P........... - 4060 00000000 00000000 00000000 00000000 ................ - 4070 00991100 00000000 009d1100 00000000 ................ - 4080 00010050 9d110000 00000000 0b120000 ...P............ - 4090 00000000 01005f28 12000000 0000002b ......_(.......+ - 40a0 12000000 00000001 00502b12 00000000 .........P+..... - 40b0 00007d12 00000000 00000100 5f981200 ..}........._... - 40c0 00000000 009b1200 00000000 00010050 ...............P - 40d0 9b120000 00000000 c9120000 00000000 ................ - 40e0 01005f00 00000000 00000000 00000000 .._............. - 40f0 00000000 00000001 000100af 11000000 ................ - 4100 000000b2 11000000 00000001 0050b211 .............P.. - 4110 00000000 00000b12 00000000 00000300 ................ - 4120 91a87f28 12000000 0000007d 12000000 ...(.......}.... - 4130 00000002 00389f98 12000000 000000c9 .....8.......... - 4140 12000000 00000002 00389f00 00000000 .........8...... - 4150 00000000 00000000 000000 ........... -Contents of section .debug_aranges: - 0000 2c000000 02000000 00000800 00000000 ,............... - 0010 00000000 00000000 61130000 00000000 ........a....... - 0020 00000000 00000000 00000000 00000000 ................ -Contents of section .debug_ranges: - 0000 4b000000 00000000 b5000000 00000000 K............... - 0010 c8000000 00000000 d8000000 00000000 ................ - 0020 00000000 00000000 00000000 00000000 ................ - 0030 50000000 00000000 70000000 00000000 P.......p....... - 0040 81000000 00000000 b5000000 00000000 ................ - 0050 c8000000 00000000 d8000000 00000000 ................ - 0060 00000000 00000000 00000000 00000000 ................ - 0070 5a010000 00000000 5a010000 00000000 Z.......Z....... - 0080 5c010000 00000000 a1010000 00000000 \............... - 0090 a2010000 00000000 a5010000 00000000 ................ - 00a0 a8010000 00000000 b1010000 00000000 ................ - 00b0 00000000 00000000 00000000 00000000 ................ - 00c0 5a010000 00000000 5a010000 00000000 Z.......Z....... - 00d0 5c010000 00000000 a1010000 00000000 \............... - 00e0 00000000 00000000 00000000 00000000 ................ - 00f0 52030000 00000000 5c030000 00000000 R.......\....... - 0100 6b030000 00000000 c0030000 00000000 k............... - 0110 00000000 00000000 00000000 00000000 ................ - 0120 8e030000 00000000 92030000 00000000 ................ - 0130 96030000 00000000 9c030000 00000000 ................ - 0140 a0030000 00000000 c0030000 00000000 ................ - 0150 00000000 00000000 00000000 00000000 ................ - 0160 c0030000 00000000 07040000 00000000 ................ - 0170 07040000 00000000 68040000 00000000 ........h....... - 0180 68040000 00000000 87040000 00000000 h............... - 0190 87040000 00000000 9c040000 00000000 ................ - 01a0 9c040000 00000000 ae040000 00000000 ................ - 01b0 ae040000 00000000 44050000 00000000 ........D....... - 01c0 44050000 00000000 b0050000 00000000 D............... - 01d0 b0050000 00000000 cc050000 00000000 ................ - 01e0 cc050000 00000000 de050000 00000000 ................ - 01f0 de050000 00000000 f0050000 00000000 ................ - 0200 f0050000 00000000 67060000 00000000 ........g....... - 0210 98070000 00000000 c5070000 00000000 ................ - 0220 c5070000 00000000 20080000 00000000 ........ ....... - 0230 20080000 00000000 3c080000 00000000 .......<....... - 0240 3c080000 00000000 4e080000 00000000 <.......N....... - 0250 4e080000 00000000 60080000 00000000 N.......`....... - 0260 60080000 00000000 2c090000 00000000 `.......,....... - 0270 2c090000 00000000 80090000 00000000 ,............... - 0280 80090000 00000000 a9090000 00000000 ................ - 0290 a9090000 00000000 c2090000 00000000 ................ - 02a0 c2090000 00000000 c2090000 00000000 ................ - 02b0 c2090000 00000000 5c0a0000 00000000 ........\....... - 02c0 5c0a0000 00000000 890a0000 00000000 \............... - 02d0 890a0000 00000000 a20a0000 00000000 ................ - 02e0 a20a0000 00000000 bb0a0000 00000000 ................ - 02f0 bb0a0000 00000000 080b0000 00000000 ................ - 0300 300b0000 00000000 7b0b0000 00000000 0.......{....... - 0310 7b0b0000 00000000 a50b0000 00000000 {............... - 0320 a50b0000 00000000 be0b0000 00000000 ................ - 0330 be0b0000 00000000 d70b0000 00000000 ................ - 0340 d70b0000 00000000 160c0000 00000000 ................ - 0350 160c0000 00000000 480c0000 00000000 ........H....... - 0360 480c0000 00000000 610c0000 00000000 H.......a....... - 0370 610c0000 00000000 7a0c0000 00000000 a.......z....... - 0380 7a0c0000 00000000 e40c0000 00000000 z............... - 0390 e40c0000 00000000 190d0000 00000000 ................ - 03a0 190d0000 00000000 320d0000 00000000 ........2....... - 03b0 320d0000 00000000 4b0d0000 00000000 2.......K....... - 03c0 4b0d0000 00000000 d20d0000 00000000 K............... - 03d0 00000000 00000000 00000000 00000000 ................ - 03e0 fc030000 00000000 04040000 00000000 ................ - 03f0 07040000 00000000 07040000 00000000 ................ - 0400 07040000 00000000 68040000 00000000 ........h....... - 0410 68040000 00000000 87040000 00000000 h............... - 0420 87040000 00000000 9c040000 00000000 ................ - 0430 9c040000 00000000 ae040000 00000000 ................ - 0440 ae040000 00000000 14050000 00000000 ................ - 0450 98070000 00000000 b2070000 00000000 ................ - 0460 b4070000 00000000 bc070000 00000000 ................ - 0470 400a0000 00000000 5c0a0000 00000000 @.......\....... - 0480 5c0a0000 00000000 890a0000 00000000 \............... - 0490 890a0000 00000000 a20a0000 00000000 ................ - 04a0 a20a0000 00000000 bb0a0000 00000000 ................ - 04b0 bb0a0000 00000000 080b0000 00000000 ................ - 04c0 00000000 00000000 00000000 00000000 ................ - 04d0 fc030000 00000000 04040000 00000000 ................ - 04e0 07040000 00000000 68040000 00000000 ........h....... - 04f0 68040000 00000000 87040000 00000000 h............... - 0500 87040000 00000000 9c040000 00000000 ................ - 0510 9c040000 00000000 ae040000 00000000 ................ - 0520 ae040000 00000000 14050000 00000000 ................ - 0530 98070000 00000000 b2070000 00000000 ................ - 0540 b4070000 00000000 bc070000 00000000 ................ - 0550 400a0000 00000000 5c0a0000 00000000 @.......\....... - 0560 5c0a0000 00000000 890a0000 00000000 \............... - 0570 890a0000 00000000 a20a0000 00000000 ................ - 0580 a20a0000 00000000 bb0a0000 00000000 ................ - 0590 bb0a0000 00000000 080b0000 00000000 ................ - 05a0 00000000 00000000 00000000 00000000 ................ - 05b0 68040000 00000000 68040000 00000000 h.......h....... - 05c0 68040000 00000000 87040000 00000000 h............... - 05d0 87040000 00000000 9c040000 00000000 ................ - 05e0 9c040000 00000000 ae040000 00000000 ................ - 05f0 ae040000 00000000 08050000 00000000 ................ - 0600 00000000 00000000 00000000 00000000 ................ - 0610 68040000 00000000 75040000 00000000 h.......u....... - 0620 7c040000 00000000 87040000 00000000 |............... - 0630 00000000 00000000 00000000 00000000 ................ - 0640 75040000 00000000 7c040000 00000000 u.......|....... - 0650 87040000 00000000 8a040000 00000000 ................ - 0660 91040000 00000000 9c040000 00000000 ................ - 0670 00000000 00000000 00000000 00000000 ................ - 0680 8a040000 00000000 91040000 00000000 ................ - 0690 9c040000 00000000 9e040000 00000000 ................ - 06a0 a5040000 00000000 ae040000 00000000 ................ - 06b0 00000000 00000000 00000000 00000000 ................ - 06c0 9e040000 00000000 a5040000 00000000 ................ - 06d0 ae040000 00000000 bb040000 00000000 ................ - 06e0 00000000 00000000 00000000 00000000 ................ - 06f0 98070000 00000000 98070000 00000000 ................ - 0700 9d070000 00000000 a0070000 00000000 ................ - 0710 a5070000 00000000 ad070000 00000000 ................ - 0720 00000000 00000000 00000000 00000000 ................ - 0730 400a0000 00000000 400a0000 00000000 @.......@....... - 0740 540a0000 00000000 5c0a0000 00000000 T.......\....... - 0750 00000000 00000000 00000000 00000000 ................ - 0760 5c0a0000 00000000 5c0a0000 00000000 \.......\....... - 0770 5c0a0000 00000000 640a0000 00000000 \.......d....... - 0780 670a0000 00000000 6e0a0000 00000000 g.......n....... - 0790 7b0a0000 00000000 810a0000 00000000 {............... - 07a0 850a0000 00000000 890a0000 00000000 ................ - 07b0 890a0000 00000000 a20a0000 00000000 ................ - 07c0 a20a0000 00000000 bb0a0000 00000000 ................ - 07d0 bb0a0000 00000000 d40a0000 00000000 ................ - 07e0 00000000 00000000 00000000 00000000 ................ - 07f0 5c0a0000 00000000 640a0000 00000000 \.......d....... - 0800 670a0000 00000000 6e0a0000 00000000 g.......n....... - 0810 7b0a0000 00000000 810a0000 00000000 {............... - 0820 00000000 00000000 00000000 00000000 ................ - 0830 e60a0000 00000000 ee0a0000 00000000 ................ - 0840 f10a0000 00000000 fa0a0000 00000000 ................ - 0850 00000000 00000000 00000000 00000000 ................ - 0860 3c050000 00000000 41050000 00000000 <.......A....... - 0870 44050000 00000000 44050000 00000000 D.......D....... - 0880 44050000 00000000 b0050000 00000000 D............... - 0890 b0050000 00000000 cc050000 00000000 ................ - 08a0 cc050000 00000000 de050000 00000000 ................ - 08b0 de050000 00000000 f0050000 00000000 ................ - 08c0 f0050000 00000000 58060000 00000000 ........X....... - 08d0 a00c0000 00000000 e40c0000 00000000 ................ - 08e0 e40c0000 00000000 190d0000 00000000 ................ - 08f0 190d0000 00000000 320d0000 00000000 ........2....... - 0900 320d0000 00000000 4b0d0000 00000000 2.......K....... - 0910 4b0d0000 00000000 700d0000 00000000 K.......p....... - 0920 800d0000 00000000 d20d0000 00000000 ................ - 0930 00000000 00000000 00000000 00000000 ................ - 0940 3c050000 00000000 41050000 00000000 <.......A....... - 0950 44050000 00000000 b0050000 00000000 D............... - 0960 b0050000 00000000 cc050000 00000000 ................ - 0970 cc050000 00000000 de050000 00000000 ................ - 0980 de050000 00000000 f0050000 00000000 ................ - 0990 f0050000 00000000 58060000 00000000 ........X....... - 09a0 a00c0000 00000000 e40c0000 00000000 ................ - 09b0 e40c0000 00000000 190d0000 00000000 ................ - 09c0 190d0000 00000000 320d0000 00000000 ........2....... - 09d0 320d0000 00000000 4b0d0000 00000000 2.......K....... - 09e0 4b0d0000 00000000 700d0000 00000000 K.......p....... - 09f0 800d0000 00000000 d20d0000 00000000 ................ - 0a00 00000000 00000000 00000000 00000000 ................ - 0a10 b0050000 00000000 b0050000 00000000 ................ - 0a20 b0050000 00000000 cc050000 00000000 ................ - 0a30 cc050000 00000000 de050000 00000000 ................ - 0a40 de050000 00000000 f0050000 00000000 ................ - 0a50 f0050000 00000000 48060000 00000000 ........H....... - 0a60 00000000 00000000 00000000 00000000 ................ - 0a70 b0050000 00000000 bc050000 00000000 ................ - 0a80 c3050000 00000000 cc050000 00000000 ................ - 0a90 00000000 00000000 00000000 00000000 ................ - 0aa0 bc050000 00000000 c3050000 00000000 ................ - 0ab0 cc050000 00000000 ce050000 00000000 ................ - 0ac0 d5050000 00000000 de050000 00000000 ................ - 0ad0 00000000 00000000 00000000 00000000 ................ - 0ae0 ce050000 00000000 d5050000 00000000 ................ - 0af0 de050000 00000000 e0050000 00000000 ................ - 0b00 e7050000 00000000 f0050000 00000000 ................ - 0b10 00000000 00000000 00000000 00000000 ................ - 0b20 e0050000 00000000 e7050000 00000000 ................ - 0b30 f0050000 00000000 fd050000 00000000 ................ - 0b40 00000000 00000000 00000000 00000000 ................ - 0b50 a00c0000 00000000 a50c0000 00000000 ................ - 0b60 a80c0000 00000000 ae0c0000 00000000 ................ - 0b70 b10c0000 00000000 ba0c0000 00000000 ................ - 0b80 00000000 00000000 00000000 00000000 ................ - 0b90 c80c0000 00000000 c80c0000 00000000 ................ - 0ba0 dc0c0000 00000000 e40c0000 00000000 ................ - 0bb0 00000000 00000000 00000000 00000000 ................ - 0bc0 e40c0000 00000000 e40c0000 00000000 ................ - 0bd0 e40c0000 00000000 f00c0000 00000000 ................ - 0be0 f30c0000 00000000 f60c0000 00000000 ................ - 0bf0 070d0000 00000000 0d0d0000 00000000 ................ - 0c00 150d0000 00000000 190d0000 00000000 ................ - 0c10 190d0000 00000000 320d0000 00000000 ........2....... - 0c20 320d0000 00000000 4b0d0000 00000000 2.......K....... - 0c30 4b0d0000 00000000 640d0000 00000000 K.......d....... - 0c40 00000000 00000000 00000000 00000000 ................ - 0c50 e40c0000 00000000 f00c0000 00000000 ................ - 0c60 f30c0000 00000000 f60c0000 00000000 ................ - 0c70 070d0000 00000000 0d0d0000 00000000 ................ - 0c80 00000000 00000000 00000000 00000000 ................ - 0c90 800d0000 00000000 800d0000 00000000 ................ - 0ca0 850d0000 00000000 8d0d0000 00000000 ................ - 0cb0 920d0000 00000000 9a0d0000 00000000 ................ - 0cc0 00000000 00000000 00000000 00000000 ................ - 0cd0 c5070000 00000000 c5070000 00000000 ................ - 0ce0 c5070000 00000000 20080000 00000000 ........ ....... - 0cf0 20080000 00000000 3c080000 00000000 .......<....... - 0d00 3c080000 00000000 4e080000 00000000 <.......N....... - 0d10 4e080000 00000000 60080000 00000000 N.......`....... - 0d20 60080000 00000000 f0080000 00000000 `............... - 0d30 f9080000 00000000 20090000 00000000 ........ ....... - 0d40 4f0b0000 00000000 600b0000 00000000 O.......`....... - 0d50 f80b0000 00000000 160c0000 00000000 ................ - 0d60 160c0000 00000000 480c0000 00000000 ........H....... - 0d70 480c0000 00000000 610c0000 00000000 H.......a....... - 0d80 610c0000 00000000 7a0c0000 00000000 a.......z....... - 0d90 7a0c0000 00000000 a00c0000 00000000 z............... - 0da0 700d0000 00000000 800d0000 00000000 p............... - 0db0 00000000 00000000 00000000 00000000 ................ - 0dc0 20080000 00000000 20080000 00000000 ....... ....... - 0dd0 20080000 00000000 3c080000 00000000 .......<....... - 0de0 3c080000 00000000 4e080000 00000000 <.......N....... - 0df0 4e080000 00000000 60080000 00000000 N.......`....... - 0e00 60080000 00000000 bf080000 00000000 `............... - 0e10 00000000 00000000 00000000 00000000 ................ - 0e20 20080000 00000000 2c080000 00000000 .......,....... - 0e30 33080000 00000000 3c080000 00000000 3.......<....... - 0e40 00000000 00000000 00000000 00000000 ................ - 0e50 2c080000 00000000 33080000 00000000 ,.......3....... - 0e60 3c080000 00000000 3e080000 00000000 <.......>....... - 0e70 45080000 00000000 4e080000 00000000 E.......N....... - 0e80 00000000 00000000 00000000 00000000 ................ - 0e90 3e080000 00000000 45080000 00000000 >.......E....... - 0ea0 4e080000 00000000 50080000 00000000 N.......P....... - 0eb0 57080000 00000000 60080000 00000000 W.......`....... - 0ec0 00000000 00000000 00000000 00000000 ................ - 0ed0 50080000 00000000 57080000 00000000 P.......W....... - 0ee0 60080000 00000000 6d080000 00000000 `.......m....... - 0ef0 00000000 00000000 00000000 00000000 ................ - 0f00 cb080000 00000000 d0080000 00000000 ................ - 0f10 d3080000 00000000 d6080000 00000000 ................ - 0f20 d9080000 00000000 dd080000 00000000 ................ - 0f30 e0080000 00000000 e5080000 00000000 ................ - 0f40 00000000 00000000 00000000 00000000 ................ - 0f50 f80b0000 00000000 f80b0000 00000000 ................ - 0f60 0e0c0000 00000000 160c0000 00000000 ................ - 0f70 00000000 00000000 00000000 00000000 ................ - 0f80 160c0000 00000000 160c0000 00000000 ................ - 0f90 160c0000 00000000 160c0000 00000000 ................ - 0fa0 270c0000 00000000 330c0000 00000000 '.......3....... - 0fb0 360c0000 00000000 480c0000 00000000 6.......H....... - 0fc0 480c0000 00000000 610c0000 00000000 H.......a....... - 0fd0 610c0000 00000000 7a0c0000 00000000 a.......z....... - 0fe0 7a0c0000 00000000 930c0000 00000000 z............... - 0ff0 00000000 00000000 00000000 00000000 ................ - 1000 160c0000 00000000 160c0000 00000000 ................ - 1010 270c0000 00000000 330c0000 00000000 '.......3....... - 1020 360c0000 00000000 440c0000 00000000 6.......D....... - 1030 00000000 00000000 00000000 00000000 ................ - 1040 f0080000 00000000 f9080000 00000000 ................ - 1050 20090000 00000000 2c090000 00000000 .......,....... - 1060 2c090000 00000000 80090000 00000000 ,............... - 1070 80090000 00000000 a9090000 00000000 ................ - 1080 a9090000 00000000 c2090000 00000000 ................ - 1090 c2090000 00000000 c2090000 00000000 ................ - 10a0 c2090000 00000000 400a0000 00000000 ........@....... - 10b0 300b0000 00000000 4f0b0000 00000000 0.......O....... - 10c0 600b0000 00000000 7b0b0000 00000000 `.......{....... - 10d0 7b0b0000 00000000 a50b0000 00000000 {............... - 10e0 a50b0000 00000000 be0b0000 00000000 ................ - 10f0 be0b0000 00000000 d70b0000 00000000 ................ - 1100 d70b0000 00000000 f80b0000 00000000 ................ - 1110 00000000 00000000 00000000 00000000 ................ - 1120 80090000 00000000 80090000 00000000 ................ - 1130 80090000 00000000 a9090000 00000000 ................ - 1140 a9090000 00000000 c2090000 00000000 ................ - 1150 c2090000 00000000 c2090000 00000000 ................ - 1160 c2090000 00000000 1e0a0000 00000000 ................ - 1170 00000000 00000000 00000000 00000000 ................ - 1180 80090000 00000000 8a090000 00000000 ................ - 1190 91090000 00000000 93090000 00000000 ................ - 11a0 9d090000 00000000 a0090000 00000000 ................ - 11b0 a3090000 00000000 a9090000 00000000 ................ - 11c0 00000000 00000000 00000000 00000000 ................ - 11d0 8a090000 00000000 91090000 00000000 ................ - 11e0 9a090000 00000000 9d090000 00000000 ................ - 11f0 a0090000 00000000 a3090000 00000000 ................ - 1200 b5090000 00000000 bc090000 00000000 ................ - 1210 c2090000 00000000 c2090000 00000000 ................ - 1220 00000000 00000000 00000000 00000000 ................ - 1230 93090000 00000000 9a090000 00000000 ................ - 1240 a9090000 00000000 ab090000 00000000 ................ - 1250 b2090000 00000000 b5090000 00000000 ................ - 1260 bc090000 00000000 c2090000 00000000 ................ - 1270 00000000 00000000 00000000 00000000 ................ - 1280 ab090000 00000000 b2090000 00000000 ................ - 1290 c2090000 00000000 cf090000 00000000 ................ - 12a0 00000000 00000000 00000000 00000000 ................ - 12b0 300b0000 00000000 350b0000 00000000 0.......5....... - 12c0 380b0000 00000000 3e0b0000 00000000 8.......>....... - 12d0 410b0000 00000000 4a0b0000 00000000 A.......J....... - 12e0 00000000 00000000 00000000 00000000 ................ - 12f0 600b0000 00000000 600b0000 00000000 `.......`....... - 1300 710b0000 00000000 740b0000 00000000 q.......t....... - 1310 760b0000 00000000 7b0b0000 00000000 v.......{....... - 1320 00000000 00000000 00000000 00000000 ................ - 1330 7b0b0000 00000000 7b0b0000 00000000 {.......{....... - 1340 7b0b0000 00000000 830b0000 00000000 {............... - 1350 850b0000 00000000 8c0b0000 00000000 ................ - 1360 980b0000 00000000 9e0b0000 00000000 ................ - 1370 a10b0000 00000000 a50b0000 00000000 ................ - 1380 a50b0000 00000000 be0b0000 00000000 ................ - 1390 be0b0000 00000000 d70b0000 00000000 ................ - 13a0 d70b0000 00000000 f00b0000 00000000 ................ - 13b0 00000000 00000000 00000000 00000000 ................ - 13c0 7b0b0000 00000000 830b0000 00000000 {............... - 13d0 850b0000 00000000 8c0b0000 00000000 ................ - 13e0 980b0000 00000000 9e0b0000 00000000 ................ - 13f0 00000000 00000000 00000000 00000000 ................ - 1400 67060000 00000000 5b070000 00000000 g.......[....... - 1410 62070000 00000000 65070000 00000000 b.......e....... - 1420 67070000 00000000 6a070000 00000000 g.......j....... - 1430 6e070000 00000000 75070000 00000000 n.......u....... - 1440 79070000 00000000 90070000 00000000 y............... - 1450 080b0000 00000000 300b0000 00000000 ........0....... - 1460 d20d0000 00000000 ea0d0000 00000000 ................ - 1470 00000000 00000000 00000000 00000000 ................ - 1480 7d060000 00000000 5b070000 00000000 }.......[....... - 1490 62070000 00000000 65070000 00000000 b.......e....... - 14a0 67070000 00000000 6a070000 00000000 g.......j....... - 14b0 6e070000 00000000 75070000 00000000 n.......u....... - 14c0 79070000 00000000 90070000 00000000 y............... - 14d0 00000000 00000000 00000000 00000000 ................ - 14e0 92060000 00000000 92060000 00000000 ................ - 14f0 b2060000 00000000 b2060000 00000000 ................ - 1500 d2060000 00000000 d2060000 00000000 ................ - 1510 00000000 00000000 00000000 00000000 ................ - 1520 58070000 00000000 5b070000 00000000 X.......[....... - 1530 62070000 00000000 65070000 00000000 b.......e....... - 1540 67070000 00000000 6a070000 00000000 g.......j....... - 1550 6e070000 00000000 75070000 00000000 n.......u....... - 1560 79070000 00000000 90070000 00000000 y............... - 1570 00000000 00000000 00000000 00000000 ................ - 1580 fe0e0000 00000000 fe0e0000 00000000 ................ - 1590 000f0000 00000000 1a0f0000 00000000 ................ - 15a0 00000000 00000000 00000000 00000000 ................ - 15b0 24100000 00000000 62110000 00000000 $.......b....... - 15c0 66110000 00000000 69110000 00000000 f.......i....... - 15d0 73110000 00000000 c9120000 00000000 s............... - 15e0 31130000 00000000 3d130000 00000000 1.......=....... - 15f0 00000000 00000000 00000000 00000000 ................ - 1600 24100000 00000000 2c100000 00000000 $.......,....... - 1610 2c100000 00000000 62110000 00000000 ,.......b....... - 1620 66110000 00000000 69110000 00000000 f.......i....... - 1630 73110000 00000000 c9120000 00000000 s............... - 1640 31130000 00000000 3d130000 00000000 1.......=....... - 1650 00000000 00000000 00000000 00000000 ................ -Contents of section .debug_line: - 0000 18190000 0200ce01 00000101 fb0e0d00 ................ - 0010 01010101 00000001 0000012f 686f6d65 .........../home - 0020 2f636865 6e7a697a 68616e2f 68656176 /chenzizhan/heav - 0030 796b6565 70657263 7a7a2f46 69656c64 ykeeperczz/Field - 0040 53746174 2f737263 2f746167 73002f68 Stat/src/tags./h - 0050 6f6d652f 6368656e 7a697a68 616e2f68 ome/chenzizhan/h - 0060 65617679 6b656570 6572637a 7a2f4669 eavykeeperczz/Fi - 0070 656c6453 7461742f 76656e64 6f72732f eldStat/vendors/ - 0080 78786861 7368002f 7573722f 6c69622f xxhash./usr/lib/ - 0090 6763632f 7838365f 36342d72 65646861 gcc/x86_64-redha - 00a0 742d6c69 6e75782f 382f696e 636c7564 t-linux/8/includ - 00b0 65002f75 73722f69 6e636c75 64652f62 e./usr/include/b - 00c0 69747300 2f757372 2f696e63 6c756465 its./usr/include - 00d0 2f626974 732f7479 70657300 2f757372 /bits/types./usr - 00e0 2f696e63 6c756465 002f686f 6d652f63 /include./home/c - 00f0 68656e7a 697a6861 6e2f6865 6176796b henzizhan/heavyk - 0100 65657065 72637a7a 2f466965 6c645374 eeperczz/FieldSt - 0110 61742f69 6e636c75 64652f66 69656c64 at/include/field - 0120 73746174 00006d79 5f75745f 68617368 stat..my_ut_hash - 0130 2e630001 00007878 68617368 2e680002 .c....xxhash.h.. - 0140 00007374 64646566 2e680003 00007479 ..stddef.h....ty - 0150 7065732e 68000400 00737472 7563745f pes.h....struct_ - 0160 46494c45 2e680005 00004649 4c452e68 FILE.h....FILE.h - 0170 00050000 73746469 6f2e6800 06000073 ....stdio.h....s - 0180 79735f65 72726c69 73742e68 00040000 ys_errlist.h.... - 0190 73746469 6e742d75 696e746e 2e680004 stdint-uintn.h.. - 01a0 00006669 656c6473 7461742e 68000700 ..fieldstat.h... - 01b0 00737464 6c69622e 68000600 00737472 .stdlib.h....str - 01c0 696e672e 68000600 003c6275 696c742d ing.h................. - 01e0 00000000 00031701 05051305 17060105 ................ - 01f0 013d06cb 05051305 01061105 0a830508 .=.............. - 0200 82051a00 02040158 05010326 9e050506 .......X...&.... - 0210 035e0812 05080601 0511af05 09030958 .^.............X - 0220 05110603 0c580515 06010514 c8d60529 .....X.........) - 0230 00020402 06036b01 052a0002 04020601 ......k..*...... - 0240 05180002 0402064a 00020402 064a0505 .......J.....J.. - 0250 00020402 4a050906 59131305 0d060105 ....J...Y....... - 0260 0ce40509 064d0512 0601050c 3c050906 .....M......<... - 0270 5b051192 05140601 03799e05 01031b66 [........y.....f - 0280 05110603 71082e05 14060105 01060316 ....q........... - 0290 08740505 13050106 110511bb 3c050f58 .t..........<..X - 02a0 0505064b 05150601 05103c05 05063d05 ...K......<...=. - 02b0 0f060105 053c0506 06d2050d 030d0105 .....<.......... - 02c0 1f060105 1d90050d 064b0601 05011758 .........K.....X - 02d0 20050d06 03776605 25060105 2058050d ....wf.%... X.. - 02e0 06590501 061a5820 050d0603 74820527 .Y....X ....t..' - 02f0 06010522 4a050d06 4b050106 030b0158 ..."J...K......X - 0300 20063105 05130508 06010501 57051506 .1.........W... - 0310 5c050106 0e050532 05260608 ac051501 \......2.&...... - 0320 0505064a 05090659 1383050c 0601050d ...J...Y........ - 0330 06670682 05260654 05150105 05060158 .g...&.T.......X - 0340 06190501 06130505 1f05013d 05053b82 ...........=..;. - 0350 050106f6 05051313 13050106 0f0513bd ................ - 0360 3c3c0505 06590508 06010505 064d050b <<...Y.......M.. - 0370 06010517 3c05083c 0505064e 05010603 ....<..<...N.... - 0380 0ad65820 05090603 73740501 06030d01 ..X ....st...... - 0390 05190373 4a2e0501 030d2e20 20050d06 ...sJ...... ... - 03a0 62051406 01050186 5805141c 050d069a b.......X....... - 03b0 05270601 4a050d06 bc052506 01d60501 .'..J.....%..... - 03c0 0603109e 05051305 31060105 29740501 ........1...)t.. - 03d0 75063105 05130512 06010505 062f050a u.1........../.. - 03e0 01051801 05050601 05090002 040306d7 ................ - 03f0 051c0002 04030601 050f0002 04037405 ..............t. - 0400 09000204 03062f05 0f000204 03060105 ....../......... - 0410 25000204 03066405 18000204 03010505 %.....d......... - 0420 00020403 06010002 04035806 16051706 ..........X..... - 0430 0105012f 06a10505 13051606 0105012f .../.........../ - 0440 06d90505 13130501 06100505 8405012c ..............., - 0450 05058482 065a050a 01051501 05050601 .....Z.......... - 0460 90050d06 0309f2f3 05200002 04020376 ......... .....v - 0470 01051500 02040201 05050002 0402064a ...............J - 0480 0509065a 08910518 06010509 3c050d06 ...Z........<... - 0490 03099e08 bb052003 73010515 01050506 ...... .s....... - 04a0 01580603 1401050c 06010501 8306d905 .X.............. - 04b0 05131305 01061004 02050503 b40f2e05 ................ - 04c0 274b0401 050103cb 70660402 051e0603 'K......pf...... - 04d0 b10fe405 05141305 27069f05 174b0510 ........'....K.. - 04e0 6705174b 05056206 5913050c 0603d67a g..K..b.Y......z - 04f0 01051703 aa054a05 05064b13 050c0603 ......J...K..... - 0500 d47a0105 1703ac05 66050506 4c050e03 .z......f...L... - 0510 d07a0105 0514050c 060108e4 05050603 .z.............. - 0520 af050106 01040105 150603c9 70010505 ............p... - 0530 06010228 12050906 84040205 1d0603c5 ...(............ - 0540 0fba0536 4b040105 0903ba70 4a040205 ...6K......pJ... - 0550 010603bb 0f3c0505 14050917 13140536 .....<.........6 - 0560 06133c05 1d490509 06590536 0601051d ..<..I...Y.6.... - 0570 58051a3c 05090668 05120601 051c3c05 X..<...h......<. - 0580 0c4a0509 06a4050c 0601051d 0375ba05 .J...........u.. - 0590 09060317 4a051606 01050c4a 90050d06 ....J......J.... - 05a0 08850511 13060105 0506039a 7d0103de ............}... - 05b0 7e011303 af7e0103 d2010105 1003de01 ~....~.......... - 05c0 01050514 05120601 05099e05 05063d05 ..............=. - 05d0 12061105 0a750505 064b0509 06010505 .....u...K...... - 05e0 06032574 0601054a 0603ff01 01051113 ..%t...J........ - 05f0 06010505 0603997d 0103de7e 011303af .......}...~.... - 0600 7e0103d2 01010510 03de0101 05051405 ~............... - 0610 09060105 05063d05 12061105 0a750505 ......=......u.. - 0620 064b0509 06010505 06032574 0601054a .K........%t...J - 0630 06038002 01051113 06010505 0603987d ...............} - 0640 0103de7e 011303af 7e0103d2 01010510 ...~....~....... - 0650 03de0101 05051405 09060105 05062f05 ............../. - 0660 12061105 0a750505 063d0509 06010505 .....u...=...... - 0670 06032566 0601054a 06038102 01051113 ..%f...J........ - 0680 06010505 0603977d 0103de7e 011303af .......}...~.... - 0690 7e0103d2 01010510 03de0101 05051405 ~............... - 06a0 09060105 05063d05 0a060105 05063d05 ......=.......=. - 06b0 09060105 05060325 74060105 4a060382 .......%t...J... - 06c0 02010515 13050d06 01024d12 05090616 ..........M..... - 06d0 050c0601 ba040105 0906039b 70010517 ............p... - 06e0 06010509 2e050d06 03090890 0402051d ................ - 06f0 0603bb0f ba040105 0d03c570 58040205 ...........pX... - 0700 010603b1 0f3c0505 14050917 13051d06 .....<.......... - 0710 01050906 4c051d06 0105363d 74051d49 ....L.....6=t..I - 0720 05090659 05360601 051d7405 1a3c0509 ...Y.6....t..<.. - 0730 06a00512 0601051c 3c050c4a 050906a4 ........<..J.... - 0740 050c0601 05090603 0c900516 0601050c ................ - 0750 4a90050d 06089305 11130601 05050603 J............... - 0760 9a7d0103 de7e0113 03af7e01 03d20101 .}...~....~..... - 0770 051003de 01010505 14051206 0105099e ................ - 0780 0505062f 05120611 050a7505 05063d05 .../......u...=. - 0790 09060105 05060325 66060105 4a0603ff .......%f...J... - 07a0 01010511 13060105 05060399 7d0103de ............}... - 07b0 7e011303 af7e0103 d2010105 1003de01 ~....~.......... - 07c0 01050514 05090601 0505062f 05120611 .........../.... - 07d0 050a7505 05063d05 09060105 05060325 ..u...=........% - 07e0 66060105 4a060380 02010511 13060105 f...J........... - 07f0 05060398 7d0103de 7e011303 af7e0103 ....}...~....~.. - 0800 d2010105 1003de01 01050514 05090601 ................ - 0810 0505062f 05120611 050a7505 05063d05 .../......u...=. - 0820 09060105 05060325 66060105 4a060381 .......%f...J... - 0830 02010511 13060105 05060397 7d0103de ............}... - 0840 7e011303 af7e0103 d2010105 1003de01 ~....~.......... - 0850 01050514 05090601 0505063d 050a0601 ...........=.... - 0860 0505063d 05090601 05050603 25740601 ...=........%t.. - 0870 054a0603 82020105 1513050d 0601024b .J.............K - 0880 12050906 16050c06 01f20401 05200002 ............. .. - 0890 04020603 98700105 15000204 02010505 .....p.......... - 08a0 00020402 064a0603 14ac0402 051d03df .....J.......... - 08b0 0f010505 1414050d 06500508 037a6605 .........P...zf. - 08c0 05060309 82050906 01050506 4c050103 ............L... - 08d0 877e0105 05030d01 05140105 05150509 .~.............. - 08e0 13050f06 13050d57 05090667 050f0105 .......W...g.... - 08f0 0d9f0105 0103e87e 01050514 05091506 .......~........ - 0900 01050d06 03930101 01051106 83050d49 ...............I - 0910 3c4a0674 13050f10 050d6701 050103e8 .,..X..K. K.. - 14e0 4f051803 793c0505 063d1314 15051b06 O...y<...=...... - 14f0 01051958 0505063e 05010613 4a3c06cb ...X...>....J<.. - 1500 05051305 08060105 05066905 10061305 ..........i..... - 1510 1b490505 064b0508 06010501 99053e52 .I...K........>R - 1520 05010378 3c050506 52053e06 01050103 ...x<...R.>..... - 1530 784a053e 28050103 7866053e 52050506 xJ.>(...xf.>R... - 1540 83050a01 05150105 09000204 03670525 .............g.% - 1550 00020403 06010509 00020403 4a052500 ............J.%. - 1560 02040390 05090002 04037405 2c000204 ..........t.,... - 1570 03065705 15000204 03010505 00020403 ..W............. - 1580 06010669 05130601 05014b66 4a064005 ...i......KfJ.@. - 1590 0513050c 06010505 064b050c 06010505 .........K...... - 15a0 063d0508 06010509 0659050e 06010509 .=.......Y...... - 15b0 06750501 06530547 52050103 784a0547 .u...S.GR...xJ.G - 15c0 28050506 74050106 03780105 47283c05 (...t....x..G(<. - 15d0 0103783c 05475205 0a590547 3b050506 ..x<.GR..Y.G;... - 15e0 3d14050a 01051501 050a0610 05090002 =............... - 15f0 04030631 052e0002 04030601 05090002 ...1............ - 1600 04034a05 2e000204 03580509 00020403 ..J......X...... - 1610 74052400 02040306 57051500 02040301 t.$.....W....... - 1620 05050002 04030601 05015b66 4a06bd05 ..........[fJ... - 1630 05130501 06110537 67050157 05372105 .......7g..W.7!. - 1640 105a0537 3a050506 3d051806 0105104b .Z.7:...=......K - 1650 05135705 05065913 05170601 05050668 ..W...Y........h - 1660 05080601 05090659 05010603 09010513 .......Y........ - 1670 03775805 01030982 2e050906 03792005 .wX..........y . - 1680 2d060105 134a052d 2e051390 0509064b -....J.-.......K - 1690 050e0105 19010658 050d0002 0403064b .......X.......K - 16a0 052a0002 0403064a 00020403 82050d00 .*.....J........ - 16b0 02040374 052c0002 04030681 05190002 ...t.,.......... - 16c0 04030105 09000204 03060105 017a582e .............zX. - 16d0 06af0505 13050106 11050821 05014905 ...........!..I. - 16e0 083d0505 06310501 063d0505 1f050906 .=...1...=...... - 16f0 9c0505bc 0501063d 05051f58 05530600 .......=...X.S.. - 1700 09020000 00000000 00001605 05140553 ...............S - 1710 0610050c 304a3c58 05010600 09020000 ....0J: - 0: 8b 47 10 mov 0x10(%rdi),%eax - 3: c3 retq - 4: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) - b: 00 00 00 00 - f: 90 nop - -0000000000000010 : - 10: 41 56 push %r14 - 12: 41 55 push %r13 - 14: 41 54 push %r12 - 16: 55 push %rbp - 17: 53 push %rbx - 18: 4c 8b 77 08 mov 0x8(%rdi),%r14 - 1c: 48 8b 46 08 mov 0x8(%rsi),%rax - 20: 4d 85 f6 test %r14,%r14 - 23: 75 1b jne 40 - 25: 45 31 ed xor %r13d,%r13d - 28: 48 85 c0 test %rax,%rax - 2b: 41 0f 95 c5 setne %r13b - 2f: 5b pop %rbx - 30: 44 89 e8 mov %r13d,%eax - 33: 5d pop %rbp - 34: 41 5c pop %r12 - 36: 41 5d pop %r13 - 38: 41 5e pop %r14 - 3a: c3 retq - 3b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) - 40: 49 39 c6 cmp %rax,%r14 - 43: 75 6a jne af - 45: 48 8b 2e mov (%rsi),%rbp - 48: 48 8b 1f mov (%rdi),%rbx - 4b: 45 31 e4 xor %r12d,%r12d - 4e: eb 31 jmp 81 - 50: 83 f8 02 cmp $0x2,%eax - 53: 75 1b jne 70 - 55: 48 8b 75 10 mov 0x10(%rbp),%rsi - 59: 48 8b 7b 10 mov 0x10(%rbx),%rdi - 5d: e8 00 00 00 00 callq 62 - 62: 85 c0 test %eax,%eax - 64: 75 49 jne af - 66: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1) - 6d: 00 00 00 - 70: 49 83 c4 01 add $0x1,%r12 - 74: 48 83 c5 18 add $0x18,%rbp - 78: 48 83 c3 18 add $0x18,%rbx - 7c: 4d 39 e6 cmp %r12,%r14 - 7f: 74 ae je 2f - 81: 48 8b 75 00 mov 0x0(%rbp),%rsi - 85: 48 8b 3b mov (%rbx),%rdi - 88: e8 00 00 00 00 callq 8d - 8d: 41 89 c5 mov %eax,%r13d - 90: 85 c0 test %eax,%eax - 92: 75 1b jne af - 94: 8b 43 08 mov 0x8(%rbx),%eax - 97: 3b 45 08 cmp 0x8(%rbp),%eax - 9a: 75 13 jne af - 9c: 83 f8 01 cmp $0x1,%eax - 9f: 74 27 je c8 - a1: 85 c0 test %eax,%eax - a3: 75 ab jne 50 - a5: 48 8b 45 10 mov 0x10(%rbp),%rax - a9: 48 39 43 10 cmp %rax,0x10(%rbx) - ad: 74 c1 je 70 - af: 41 bd 01 00 00 00 mov $0x1,%r13d - b5: 5b pop %rbx - b6: 5d pop %rbp - b7: 44 89 e8 mov %r13d,%eax - ba: 41 5c pop %r12 - bc: 41 5d pop %r13 - be: 41 5e pop %r14 - c0: c3 retq - c1: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) - c8: f2 0f 10 43 10 movsd 0x10(%rbx),%xmm0 - cd: 66 0f 2e 45 10 ucomisd 0x10(%rbp),%xmm0 - d2: 7a db jp af - d4: 74 9a je 70 - d6: eb d7 jmp af - d8: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) - df: 00 - -00000000000000e0 : - e0: 55 push %rbp - e1: 48 89 fd mov %rdi,%rbp - e4: 53 push %rbx - e5: 48 89 f3 mov %rsi,%rbx - e8: 48 83 ec 08 sub $0x8,%rsp - ec: 48 8b 3e mov (%rsi),%rdi - ef: e8 00 00 00 00 callq f4 - f4: 48 89 45 00 mov %rax,0x0(%rbp) - f8: 8b 43 08 mov 0x8(%rbx),%eax - fb: 89 45 08 mov %eax,0x8(%rbp) - fe: 8b 43 08 mov 0x8(%rbx),%eax - 101: 83 f8 01 cmp $0x1,%eax - 104: 74 22 je 128 - 106: 85 c0 test %eax,%eax - 108: 74 36 je 140 - 10a: 83 f8 02 cmp $0x2,%eax - 10d: 75 0d jne 11c - 10f: 48 8b 7b 10 mov 0x10(%rbx),%rdi - 113: e8 00 00 00 00 callq 118 - 118: 48 89 45 10 mov %rax,0x10(%rbp) - 11c: 48 83 c4 08 add $0x8,%rsp - 120: 5b pop %rbx - 121: 5d pop %rbp - 122: c3 retq - 123: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) - 128: f2 0f 10 43 10 movsd 0x10(%rbx),%xmm0 - 12d: f2 0f 11 45 10 movsd %xmm0,0x10(%rbp) - 132: 48 83 c4 08 add $0x8,%rsp - 136: 5b pop %rbx - 137: 5d pop %rbp - 138: c3 retq - 139: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) - 140: 48 8b 43 10 mov 0x10(%rbx),%rax - 144: 48 89 45 10 mov %rax,0x10(%rbp) - 148: 48 83 c4 08 add $0x8,%rsp - 14c: 5b pop %rbx - 14d: 5d pop %rbp - 14e: c3 retq - 14f: 90 nop - -0000000000000150 : - 150: 48 85 ff test %rdi,%rdi - 153: 74 5b je 1b0 - 155: 41 54 push %r12 - 157: 49 89 fc mov %rdi,%r12 - 15a: 55 push %rbp - 15b: 53 push %rbx - 15c: 85 f6 test %esi,%esi - 15e: 7e 41 jle 1a1 - 160: 8d 46 ff lea -0x1(%rsi),%eax - 163: 48 89 fb mov %rdi,%rbx - 166: 48 8d 04 40 lea (%rax,%rax,2),%rax - 16a: 48 8d 6c c7 18 lea 0x18(%rdi,%rax,8),%rbp - 16f: eb 10 jmp 181 - 171: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) - 178: 48 83 c3 18 add $0x18,%rbx - 17c: 48 39 eb cmp %rbp,%rbx - 17f: 74 20 je 1a1 - 181: 48 8b 3b mov (%rbx),%rdi - 184: e8 00 00 00 00 callq 189 - 189: 83 7b 08 02 cmpl $0x2,0x8(%rbx) - 18d: 75 e9 jne 178 - 18f: 48 8b 7b 10 mov 0x10(%rbx),%rdi - 193: 48 83 c3 18 add $0x18,%rbx - 197: e8 00 00 00 00 callq 19c - 19c: 48 39 eb cmp %rbp,%rbx - 19f: 75 e0 jne 181 - 1a1: 5b pop %rbx - 1a2: 4c 89 e7 mov %r12,%rdi - 1a5: 5d pop %rbp - 1a6: 41 5c pop %r12 - 1a8: e9 00 00 00 00 jmpq 1ad - 1ad: 0f 1f 00 nopl (%rax) - 1b0: c3 retq - 1b1: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) - 1b8: 00 00 00 00 - 1bc: 0f 1f 40 00 nopl 0x0(%rax) - -00000000000001c0 : - 1c0: 55 push %rbp - 1c1: 48 89 f5 mov %rsi,%rbp - 1c4: 53 push %rbx - 1c5: 48 89 fb mov %rdi,%rbx - 1c8: 48 83 ec 08 sub $0x8,%rsp - 1cc: 48 8b 36 mov (%rsi),%rsi - 1cf: 48 8b 3f mov (%rdi),%rdi - 1d2: e8 00 00 00 00 callq 1d7 - 1d7: 85 c0 test %eax,%eax - 1d9: 75 18 jne 1f3 - 1db: 8b 53 08 mov 0x8(%rbx),%edx - 1de: 8b 4d 08 mov 0x8(%rbp),%ecx - 1e1: 39 ca cmp %ecx,%edx - 1e3: 75 1b jne 200 - 1e5: 83 fa 01 cmp $0x1,%edx - 1e8: 74 4e je 238 - 1ea: 85 d2 test %edx,%edx - 1ec: 74 3a je 228 - 1ee: 83 fa 02 cmp $0x2,%edx - 1f1: 74 1d je 210 - 1f3: 48 83 c4 08 add $0x8,%rsp - 1f7: 5b pop %rbx - 1f8: 5d pop %rbp - 1f9: c3 retq - 1fa: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) - 200: 48 83 c4 08 add $0x8,%rsp - 204: 89 d0 mov %edx,%eax - 206: 29 c8 sub %ecx,%eax - 208: 5b pop %rbx - 209: 5d pop %rbp - 20a: c3 retq - 20b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) - 210: 48 8b 75 10 mov 0x10(%rbp),%rsi - 214: 48 8b 7b 10 mov 0x10(%rbx),%rdi - 218: 48 83 c4 08 add $0x8,%rsp - 21c: 5b pop %rbx - 21d: 5d pop %rbp - 21e: e9 00 00 00 00 jmpq 223 - 223: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) - 228: 48 8b 43 10 mov 0x10(%rbx),%rax - 22c: 2b 45 10 sub 0x10(%rbp),%eax - 22f: eb c2 jmp 1f3 - 231: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) - 238: f2 0f 10 43 10 movsd 0x10(%rbx),%xmm0 - 23d: f2 0f 5c 45 10 subsd 0x10(%rbp),%xmm0 - 242: f2 0f 2c c0 cvttsd2si %xmm0,%eax - 246: eb ab jmp 1f3 - 248: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) - 24f: 00 - -0000000000000250 : - 250: 89 f0 mov %esi,%eax - 252: c1 e0 04 shl $0x4,%eax - 255: 29 f0 sub %esi,%eax - 257: 2d 3b 62 e3 7e sub $0x7ee3623b,%eax - 25c: 89 07 mov %eax,(%rdi) - 25e: c3 retq - 25f: 90 nop - -0000000000000260 : - 260: 8b 07 mov (%rdi),%eax - 262: 48 85 d2 test %rdx,%rdx - 265: 74 1d je 284 - 267: 48 01 f2 add %rsi,%rdx - 26a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) - 270: 0f be 0e movsbl (%rsi),%ecx - 273: 48 83 c6 01 add $0x1,%rsi - 277: 31 c8 xor %ecx,%eax - 279: 69 c0 93 01 00 01 imul $0x1000193,%eax,%eax - 27f: 48 39 f2 cmp %rsi,%rdx - 282: 75 ec jne 270 - 284: 89 07 mov %eax,(%rdi) - 286: c3 retq - 287: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1) - 28e: 00 00 - -0000000000000290 : - 290: 8b 07 mov (%rdi),%eax - 292: c3 retq - 293: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) - 29a: 00 00 00 00 - 29e: 66 90 xchg %ax,%ax - -00000000000002a0 : - 2a0: 41 55 push %r13 - 2a2: 41 54 push %r12 - 2a4: 55 push %rbp - 2a5: 48 89 f5 mov %rsi,%rbp - 2a8: 89 d6 mov %edx,%esi - 2aa: 53 push %rbx - 2ab: 48 89 fb mov %rdi,%rbx - 2ae: 48 83 ec 18 sub $0x18,%rsp - 2b2: 4c 8d 64 24 0c lea 0xc(%rsp),%r12 - 2b7: 4c 89 e7 mov %r12,%rdi - 2ba: e8 00 00 00 00 callq 2bf - 2bf: 48 85 ed test %rbp,%rbp - 2c2: 74 76 je 33a - 2c4: 48 83 c3 10 add $0x10,%rbx - 2c8: 48 8d 44 6d 00 lea 0x0(%rbp,%rbp,2),%rax - 2cd: 4c 8d 2c c3 lea (%rbx,%rax,8),%r13 - 2d1: eb 1e jmp 2f1 - 2d3: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) - 2d8: ba 08 00 00 00 mov $0x8,%edx - 2dd: 48 89 de mov %rbx,%rsi - 2e0: 4c 89 e7 mov %r12,%rdi - 2e3: e8 00 00 00 00 callq 2e8 - 2e8: 48 83 c3 18 add $0x18,%rbx - 2ec: 49 39 dd cmp %rbx,%r13 - 2ef: 74 49 je 33a - 2f1: 48 8b 6b f0 mov -0x10(%rbx),%rbp - 2f5: 48 89 ef mov %rbp,%rdi - 2f8: e8 00 00 00 00 callq 2fd - 2fd: 48 89 ee mov %rbp,%rsi - 300: 4c 89 e7 mov %r12,%rdi - 303: 48 89 c2 mov %rax,%rdx - 306: e8 00 00 00 00 callq 30b - 30b: 8b 43 f8 mov -0x8(%rbx),%eax - 30e: 83 f8 01 cmp $0x1,%eax - 311: 76 c5 jbe 2d8 - 313: 83 f8 02 cmp $0x2,%eax - 316: 75 d0 jne 2e8 - 318: 48 8b 2b mov (%rbx),%rbp - 31b: 48 83 c3 18 add $0x18,%rbx - 31f: 48 89 ef mov %rbp,%rdi - 322: e8 00 00 00 00 callq 327 - 327: 48 89 ee mov %rbp,%rsi - 32a: 4c 89 e7 mov %r12,%rdi - 32d: 48 89 c2 mov %rax,%rdx - 330: e8 00 00 00 00 callq 335 - 335: 49 39 dd cmp %rbx,%r13 - 338: 75 b7 jne 2f1 - 33a: 4c 89 e7 mov %r12,%rdi - 33d: e8 00 00 00 00 callq 342 - 342: 48 83 c4 18 add $0x18,%rsp - 346: 5b pop %rbx - 347: 5d pop %rbp - 348: 41 5c pop %r12 - 34a: 41 5d pop %r13 - 34c: c3 retq - 34d: 0f 1f 00 nopl (%rax) - -0000000000000350 : - 350: 41 57 push %r15 - 352: 66 0f ef c0 pxor %xmm0,%xmm0 - 356: 8d 82 28 44 23 24 lea 0x24234428(%rdx),%eax - 35c: 41 56 push %r14 - 35e: 41 55 push %r13 - 360: 41 54 push %r12 - 362: 55 push %rbp - 363: 53 push %rbx - 364: 48 81 ec 88 00 00 00 sub $0x88,%rsp - 36b: 0f 29 44 24 50 movaps %xmm0,0x50(%rsp) - 370: 0f 29 44 24 60 movaps %xmm0,0x60(%rsp) - 375: 89 44 24 58 mov %eax,0x58(%rsp) - 379: 8d 82 77 ca eb 85 lea -0x7a143589(%rdx),%eax - 37f: 89 54 24 60 mov %edx,0x60(%rsp) - 383: 81 c2 4f 86 c8 61 add $0x61c8864f,%edx - 389: 0f 29 44 24 70 movaps %xmm0,0x70(%rsp) - 38e: 8b 4c 24 78 mov 0x78(%rsp),%ecx - 392: 89 44 24 5c mov %eax,0x5c(%rsp) - 396: 66 0f 6f 64 24 50 movdqa 0x50(%rsp),%xmm4 - 39c: 89 54 24 64 mov %edx,0x64(%rsp) - 3a0: 66 0f 6f 6c 24 60 movdqa 0x60(%rsp),%xmm5 - 3a6: 41 89 cd mov %ecx,%r13d - 3a9: 0f 29 64 24 20 movaps %xmm4,0x20(%rsp) - 3ae: 0f 29 6c 24 30 movaps %xmm5,0x30(%rsp) - 3b3: 48 c7 44 24 40 00 00 movq $0x0,0x40(%rsp) - 3ba: 00 00 - 3bc: 89 4c 24 48 mov %ecx,0x48(%rsp) - 3c0: 48 85 f6 test %rsi,%rsi - 3c3: 0f 84 f7 09 00 00 je dc0 - 3c9: 48 8d 5f 08 lea 0x8(%rdi),%rbx - 3cd: 48 8d 04 76 lea (%rsi,%rsi,2),%rax - 3d1: 44 8b 64 24 20 mov 0x20(%rsp),%r12d - 3d6: 8b 6c 24 24 mov 0x24(%rsp),%ebp - 3da: 48 8d 04 c3 lea (%rbx,%rax,8),%rax - 3de: 48 89 44 24 10 mov %rax,0x10(%rsp) - 3e3: 48 8d 44 24 20 lea 0x20(%rsp),%rax - 3e8: 48 89 44 24 08 mov %rax,0x8(%rsp) - 3ed: 0f 1f 00 nopl (%rax) - 3f0: 4c 8b 7b f8 mov -0x8(%rbx),%r15 - 3f4: 4c 89 ff mov %r15,%rdi - 3f7: e8 00 00 00 00 callq 3fc - 3fc: 45 8d 0c 04 lea (%r12,%rax,1),%r9d - 400: 48 83 f8 0f cmp $0xf,%rax - 404: 49 89 c6 mov %rax,%r14 - 407: 0f 97 c0 seta %al - 40a: 41 83 f9 0f cmp $0xf,%r9d - 40e: 44 89 4c 24 20 mov %r9d,0x20(%rsp) - 413: 0f 97 c2 seta %dl - 416: 09 d0 or %edx,%eax - 418: 0f b6 c0 movzbl %al,%eax - 41b: 09 e8 or %ebp,%eax - 41d: 89 44 24 24 mov %eax,0x24(%rsp) - 421: 44 89 e8 mov %r13d,%eax - 424: 49 8d 14 06 lea (%r14,%rax,1),%rdx - 428: 48 83 fa 0f cmp $0xf,%rdx - 42c: 0f 86 66 03 00 00 jbe 798 - 432: 4c 89 fe mov %r15,%rsi - 435: 45 85 ed test %r13d,%r13d - 438: 0f 85 02 06 00 00 jne a40 - 43e: 4b 8d 04 37 lea (%r15,%r14,1),%rax - 442: 4c 8d 48 f0 lea -0x10(%rax),%r9 - 446: 49 39 f1 cmp %rsi,%r9 - 449: 0f 82 b9 00 00 00 jb 508 - 44f: 44 8b 44 24 28 mov 0x28(%rsp),%r8d - 454: 44 8b 54 24 2c mov 0x2c(%rsp),%r10d - 459: 48 89 f1 mov %rsi,%rcx - 45c: 8b 7c 24 30 mov 0x30(%rsp),%edi - 460: 44 8b 5c 24 34 mov 0x34(%rsp),%r11d - 465: 0f 1f 00 nopl (%rax) - 468: 69 11 77 ca eb 85 imul $0x85ebca77,(%rcx),%edx - 46e: 48 83 c1 10 add $0x10,%rcx - 472: 41 01 d0 add %edx,%r8d - 475: 69 51 f4 77 ca eb 85 imul $0x85ebca77,-0xc(%rcx),%edx - 47c: 41 c1 c0 0d rol $0xd,%r8d - 480: 45 69 c0 b1 79 37 9e imul $0x9e3779b1,%r8d,%r8d - 487: 41 01 d2 add %edx,%r10d - 48a: 69 51 f8 77 ca eb 85 imul $0x85ebca77,-0x8(%rcx),%edx - 491: 41 c1 c2 0d rol $0xd,%r10d - 495: 45 69 d2 b1 79 37 9e imul $0x9e3779b1,%r10d,%r10d - 49c: 01 d7 add %edx,%edi - 49e: 69 51 fc 77 ca eb 85 imul $0x85ebca77,-0x4(%rcx),%edx - 4a5: c1 c7 0d rol $0xd,%edi - 4a8: 69 ff b1 79 37 9e imul $0x9e3779b1,%edi,%edi - 4ae: 44 01 da add %r11d,%edx - 4b1: c1 c2 0d rol $0xd,%edx - 4b4: 44 69 da b1 79 37 9e imul $0x9e3779b1,%edx,%r11d - 4bb: 49 39 c9 cmp %rcx,%r9 - 4be: 73 a8 jae 468 - 4c0: 89 7c 24 18 mov %edi,0x18(%rsp) - 4c4: 66 0f 6e 4c 24 18 movd 0x18(%rsp),%xmm1 - 4ca: 49 29 f1 sub %rsi,%r9 - 4cd: 44 89 5c 24 18 mov %r11d,0x18(%rsp) - 4d2: 66 0f 6e 54 24 18 movd 0x18(%rsp),%xmm2 - 4d8: 49 83 e1 f0 and $0xfffffffffffffff0,%r9 - 4dc: 44 89 44 24 18 mov %r8d,0x18(%rsp) - 4e1: 66 0f 6e 44 24 18 movd 0x18(%rsp),%xmm0 - 4e7: 4a 8d 74 0e 10 lea 0x10(%rsi,%r9,1),%rsi - 4ec: 44 89 54 24 18 mov %r10d,0x18(%rsp) - 4f1: 66 0f 6e 5c 24 18 movd 0x18(%rsp),%xmm3 - 4f7: 66 0f 62 ca punpckldq %xmm2,%xmm1 - 4fb: 66 0f 62 c3 punpckldq %xmm3,%xmm0 - 4ff: 66 0f 6c c1 punpcklqdq %xmm1,%xmm0 - 503: 0f 11 44 24 28 movups %xmm0,0x28(%rsp) - 508: 45 31 ed xor %r13d,%r13d - 50b: 48 39 f0 cmp %rsi,%rax - 50e: 0f 87 cc 05 00 00 ja ae0 - 514: 8b 03 mov (%rbx),%eax - 516: 83 f8 01 cmp $0x1,%eax - 519: 0f 84 a6 02 00 00 je 7c5 - 51f: 85 c0 test %eax,%eax - 521: 0f 84 f9 03 00 00 je 920 - 527: 83 f8 02 cmp $0x2,%eax - 52a: 0f 85 e0 03 00 00 jne 910 - 530: 4c 8b 73 08 mov 0x8(%rbx),%r14 - 534: 4c 89 f7 mov %r14,%rdi - 537: e8 00 00 00 00 callq 53c - 53c: 44 8b 64 24 20 mov 0x20(%rsp),%r12d - 541: 49 89 c2 mov %rax,%r10 - 544: 4d 8d 3c 06 lea (%r14,%rax,1),%r15 - 548: 41 01 c4 add %eax,%r12d - 54b: 48 83 f8 0f cmp $0xf,%rax - 54f: 0f 97 c0 seta %al - 552: 41 83 fc 0f cmp $0xf,%r12d - 556: 44 89 64 24 20 mov %r12d,0x20(%rsp) - 55b: 41 0f 97 c0 seta %r8b - 55f: 44 09 c0 or %r8d,%eax - 562: 0f b6 c0 movzbl %al,%eax - 565: 0b 44 24 24 or 0x24(%rsp),%eax - 569: 89 c5 mov %eax,%ebp - 56b: 89 44 24 24 mov %eax,0x24(%rsp) - 56f: 44 89 e8 mov %r13d,%eax - 572: 49 8d 14 02 lea (%r10,%rax,1),%rdx - 576: 48 83 fa 0f cmp $0xf,%rdx - 57a: 0f 86 00 08 00 00 jbe d80 - 580: 45 85 ed test %r13d,%r13d - 583: 0f 85 3f 07 00 00 jne cc8 - 589: 4d 8d 57 f0 lea -0x10(%r15),%r10 - 58d: 4d 39 f2 cmp %r14,%r10 - 590: 0f 82 b2 00 00 00 jb 648 - 596: 8b 54 24 28 mov 0x28(%rsp),%edx - 59a: 8b 7c 24 2c mov 0x2c(%rsp),%edi - 59e: 4c 89 f0 mov %r14,%rax - 5a1: 8b 74 24 30 mov 0x30(%rsp),%esi - 5a5: 44 8b 5c 24 34 mov 0x34(%rsp),%r11d - 5aa: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) - 5b0: 69 08 77 ca eb 85 imul $0x85ebca77,(%rax),%ecx - 5b6: 48 83 c0 10 add $0x10,%rax - 5ba: 01 ca add %ecx,%edx - 5bc: 69 48 f4 77 ca eb 85 imul $0x85ebca77,-0xc(%rax),%ecx - 5c3: c1 c2 0d rol $0xd,%edx - 5c6: 69 d2 b1 79 37 9e imul $0x9e3779b1,%edx,%edx - 5cc: 01 cf add %ecx,%edi - 5ce: 69 48 f8 77 ca eb 85 imul $0x85ebca77,-0x8(%rax),%ecx - 5d5: c1 c7 0d rol $0xd,%edi - 5d8: 69 ff b1 79 37 9e imul $0x9e3779b1,%edi,%edi - 5de: 01 ce add %ecx,%esi - 5e0: 69 48 fc 77 ca eb 85 imul $0x85ebca77,-0x4(%rax),%ecx - 5e7: c1 c6 0d rol $0xd,%esi - 5ea: 69 f6 b1 79 37 9e imul $0x9e3779b1,%esi,%esi - 5f0: 44 01 d9 add %r11d,%ecx - 5f3: c1 c1 0d rol $0xd,%ecx - 5f6: 44 69 d9 b1 79 37 9e imul $0x9e3779b1,%ecx,%r11d - 5fd: 49 39 c2 cmp %rax,%r10 - 600: 73 ae jae 5b0 - 602: 89 74 24 18 mov %esi,0x18(%rsp) - 606: 66 0f 6e 4c 24 18 movd 0x18(%rsp),%xmm1 - 60c: 4d 29 f2 sub %r14,%r10 - 60f: 44 89 5c 24 18 mov %r11d,0x18(%rsp) - 614: 66 0f 6e 64 24 18 movd 0x18(%rsp),%xmm4 - 61a: 49 83 e2 f0 and $0xfffffffffffffff0,%r10 - 61e: 89 54 24 18 mov %edx,0x18(%rsp) - 622: 66 0f 6e 44 24 18 movd 0x18(%rsp),%xmm0 - 628: 4f 8d 74 16 10 lea 0x10(%r14,%r10,1),%r14 - 62d: 89 7c 24 18 mov %edi,0x18(%rsp) - 631: 66 0f 6e 6c 24 18 movd 0x18(%rsp),%xmm5 - 637: 66 0f 62 cc punpckldq %xmm4,%xmm1 - 63b: 66 0f 62 c5 punpckldq %xmm5,%xmm0 - 63f: 66 0f 6c c1 punpcklqdq %xmm1,%xmm0 - 643: 0f 11 44 24 28 movups %xmm0,0x28(%rsp) - 648: 45 31 ed xor %r13d,%r13d - 64b: 4d 39 f7 cmp %r14,%r15 - 64e: 0f 87 4c 06 00 00 ja ca0 - 654: 0f 1f 40 00 nopl 0x0(%rax) - 658: 48 83 c3 18 add $0x18,%rbx - 65c: 48 3b 5c 24 10 cmp 0x10(%rsp),%rbx - 661: 0f 85 89 fd ff ff jne 3f0 - 667: 8b 74 24 30 mov 0x30(%rsp),%esi - 66b: 8d 86 b1 67 56 16 lea 0x165667b1(%rsi),%eax - 671: 85 ed test %ebp,%ebp - 673: 0f 85 8f 04 00 00 jne b08 - 679: 46 8d 0c 20 lea (%rax,%r12,1),%r9d - 67d: 48 8b 5c 24 08 mov 0x8(%rsp),%rbx - 682: 44 89 e8 mov %r13d,%eax - 685: 83 e0 0f and $0xf,%eax - 688: 41 83 e5 0c and $0xc,%r13d - 68c: 48 8d 73 18 lea 0x18(%rbx),%rsi - 690: 74 6e je 700 - 692: 69 54 24 38 3d ae b2 imul $0xc2b2ae3d,0x38(%rsp),%edx - 699: c2 - 69a: 48 8d 48 fc lea -0x4(%rax),%rcx - 69e: 41 01 d1 add %edx,%r9d - 6a1: 41 c1 c9 0f ror $0xf,%r9d - 6a5: 45 69 c9 2f eb d4 27 imul $0x27d4eb2f,%r9d,%r9d - 6ac: 48 83 f9 03 cmp $0x3,%rcx - 6b0: 76 36 jbe 6e8 - 6b2: 69 54 24 3c 3d ae b2 imul $0xc2b2ae3d,0x3c(%rsp),%edx - 6b9: c2 - 6ba: 48 83 e8 08 sub $0x8,%rax - 6be: 41 01 d1 add %edx,%r9d - 6c1: 41 c1 c9 0f ror $0xf,%r9d - 6c5: 45 69 c9 2f eb d4 27 imul $0x27d4eb2f,%r9d,%r9d - 6cc: 48 83 f8 03 cmp $0x3,%rax - 6d0: 76 16 jbe 6e8 - 6d2: 69 44 24 40 3d ae b2 imul $0xc2b2ae3d,0x40(%rsp),%eax - 6d9: c2 - 6da: 41 01 c1 add %eax,%r9d - 6dd: 41 c1 c9 0f ror $0xf,%r9d - 6e1: 45 69 c9 2f eb d4 27 imul $0x27d4eb2f,%r9d,%r9d - 6e8: 48 89 c8 mov %rcx,%rax - 6eb: 48 8b 5c 24 08 mov 0x8(%rsp),%rbx - 6f0: 48 c1 e8 02 shr $0x2,%rax - 6f4: 48 8d 74 83 1c lea 0x1c(%rbx,%rax,4),%rsi - 6f9: 48 f7 d8 neg %rax - 6fc: 48 8d 04 81 lea (%rcx,%rax,4),%rax - 700: 48 85 c0 test %rax,%rax - 703: 74 53 je 758 - 705: 0f b6 16 movzbl (%rsi),%edx - 708: 69 d2 b1 67 56 16 imul $0x165667b1,%edx,%edx - 70e: 41 01 d1 add %edx,%r9d - 711: 41 c1 c1 0b rol $0xb,%r9d - 715: 45 69 c9 b1 79 37 9e imul $0x9e3779b1,%r9d,%r9d - 71c: 48 83 e8 01 sub $0x1,%rax - 720: 74 36 je 758 - 722: 0f b6 56 01 movzbl 0x1(%rsi),%edx - 726: 69 d2 b1 67 56 16 imul $0x165667b1,%edx,%edx - 72c: 41 01 d1 add %edx,%r9d - 72f: 41 c1 c1 0b rol $0xb,%r9d - 733: 45 69 c9 b1 79 37 9e imul $0x9e3779b1,%r9d,%r9d - 73a: 48 83 f8 01 cmp $0x1,%rax - 73e: 74 18 je 758 - 740: 0f b6 46 02 movzbl 0x2(%rsi),%eax - 744: 69 c0 b1 67 56 16 imul $0x165667b1,%eax,%eax - 74a: 41 01 c1 add %eax,%r9d - 74d: 41 c1 c1 0b rol $0xb,%r9d - 751: 45 69 c9 b1 79 37 9e imul $0x9e3779b1,%r9d,%r9d - 758: 44 89 c8 mov %r9d,%eax - 75b: 48 81 c4 88 00 00 00 add $0x88,%rsp - 762: c1 e8 0f shr $0xf,%eax - 765: 5b pop %rbx - 766: 5d pop %rbp - 767: 41 31 c1 xor %eax,%r9d - 76a: 41 5c pop %r12 - 76c: 41 5d pop %r13 - 76e: 41 69 c1 77 ca eb 85 imul $0x85ebca77,%r9d,%eax - 775: 41 5e pop %r14 - 777: 41 5f pop %r15 - 779: 41 89 c1 mov %eax,%r9d - 77c: 41 c1 e9 0d shr $0xd,%r9d - 780: 44 31 c8 xor %r9d,%eax - 783: 69 c0 3d ae b2 c2 imul $0xc2b2ae3d,%eax,%eax - 789: 89 c2 mov %eax,%edx - 78b: c1 ea 10 shr $0x10,%edx - 78e: 31 d0 xor %edx,%eax - 790: c3 retq - 791: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) - 798: 48 8b 74 24 08 mov 0x8(%rsp),%rsi - 79d: 4c 89 f2 mov %r14,%rdx - 7a0: 48 8d 7c 06 18 lea 0x18(%rsi,%rax,1),%rdi - 7a5: 4c 89 fe mov %r15,%rsi - 7a8: e8 00 00 00 00 callq 7ad - 7ad: 44 8b 6c 24 48 mov 0x48(%rsp),%r13d - 7b2: 8b 03 mov (%rbx),%eax - 7b4: 45 01 f5 add %r14d,%r13d - 7b7: 44 89 6c 24 48 mov %r13d,0x48(%rsp) - 7bc: 83 f8 01 cmp $0x1,%eax - 7bf: 0f 85 5a fd ff ff jne 51f - 7c5: 8b 44 24 20 mov 0x20(%rsp),%eax - 7c9: 44 8d 60 08 lea 0x8(%rax),%r12d - 7cd: 31 c0 xor %eax,%eax - 7cf: 41 83 fc 0f cmp $0xf,%r12d - 7d3: 44 89 64 24 20 mov %r12d,0x20(%rsp) - 7d8: 0f 97 c0 seta %al - 7db: 0b 44 24 24 or 0x24(%rsp),%eax - 7df: 89 c5 mov %eax,%ebp - 7e1: 89 44 24 24 mov %eax,0x24(%rsp) - 7e5: 44 89 e8 mov %r13d,%eax - 7e8: 48 8d 50 08 lea 0x8(%rax),%rdx - 7ec: 48 83 fa 0f cmp $0xf,%rdx - 7f0: 0f 86 7a 05 00 00 jbe d70 - 7f6: 4c 8d 73 08 lea 0x8(%rbx),%r14 - 7fa: 45 85 ed test %r13d,%r13d - 7fd: 0f 85 f5 03 00 00 jne bf8 - 803: 49 39 de cmp %rbx,%r14 - 806: 0f 87 af 00 00 00 ja 8bb - 80c: 8b 74 24 28 mov 0x28(%rsp),%esi - 810: 8b 7c 24 2c mov 0x2c(%rsp),%edi - 814: 4c 89 f0 mov %r14,%rax - 817: 8b 4c 24 30 mov 0x30(%rsp),%ecx - 81b: 44 8b 54 24 34 mov 0x34(%rsp),%r10d - 820: 69 10 77 ca eb 85 imul $0x85ebca77,(%rax),%edx - 826: 48 83 c0 10 add $0x10,%rax - 82a: 01 d6 add %edx,%esi - 82c: 69 50 f4 77 ca eb 85 imul $0x85ebca77,-0xc(%rax),%edx - 833: c1 c6 0d rol $0xd,%esi - 836: 69 f6 b1 79 37 9e imul $0x9e3779b1,%esi,%esi - 83c: 01 d7 add %edx,%edi - 83e: 69 50 f8 77 ca eb 85 imul $0x85ebca77,-0x8(%rax),%edx - 845: c1 c7 0d rol $0xd,%edi - 848: 69 ff b1 79 37 9e imul $0x9e3779b1,%edi,%edi - 84e: 01 d1 add %edx,%ecx - 850: 69 50 fc 77 ca eb 85 imul $0x85ebca77,-0x4(%rax),%edx - 857: c1 c1 0d rol $0xd,%ecx - 85a: 69 c9 b1 79 37 9e imul $0x9e3779b1,%ecx,%ecx - 860: 44 01 d2 add %r10d,%edx - 863: c1 c2 0d rol $0xd,%edx - 866: 44 69 d2 b1 79 37 9e imul $0x9e3779b1,%edx,%r10d - 86d: 48 39 d8 cmp %rbx,%rax - 870: 76 ae jbe 820 - 872: 89 4c 24 18 mov %ecx,0x18(%rsp) - 876: 66 0f 6e 4c 24 18 movd 0x18(%rsp),%xmm1 - 87c: 48 89 d8 mov %rbx,%rax - 87f: 44 89 54 24 18 mov %r10d,0x18(%rsp) - 884: 66 0f 6e 74 24 18 movd 0x18(%rsp),%xmm6 - 88a: 4c 29 f0 sub %r14,%rax - 88d: 89 74 24 18 mov %esi,0x18(%rsp) - 891: 66 0f 6e 44 24 18 movd 0x18(%rsp),%xmm0 - 897: 48 83 e0 f0 and $0xfffffffffffffff0,%rax - 89b: 89 7c 24 18 mov %edi,0x18(%rsp) - 89f: 66 0f 6e 7c 24 18 movd 0x18(%rsp),%xmm7 - 8a5: 66 0f 62 ce punpckldq %xmm6,%xmm1 - 8a9: 4d 8d 74 06 10 lea 0x10(%r14,%rax,1),%r14 - 8ae: 66 0f 62 c7 punpckldq %xmm7,%xmm0 - 8b2: 66 0f 6c c1 punpcklqdq %xmm1,%xmm0 - 8b6: 0f 11 44 24 28 movups %xmm0,0x28(%rsp) - 8bb: 48 8d 53 10 lea 0x10(%rbx),%rdx - 8bf: 45 31 ed xor %r13d,%r13d - 8c2: 49 39 d6 cmp %rdx,%r14 - 8c5: 0f 83 8d fd ff ff jae 658 - 8cb: 48 8b 44 24 08 mov 0x8(%rsp),%rax - 8d0: 4c 29 f2 sub %r14,%rdx - 8d3: 4c 89 f6 mov %r14,%rsi - 8d6: 49 89 d7 mov %rdx,%r15 - 8d9: 48 8d 78 18 lea 0x18(%rax),%rdi - 8dd: 45 89 fd mov %r15d,%r13d - 8e0: e8 00 00 00 00 callq 8e5 - 8e5: 44 89 7c 24 48 mov %r15d,0x48(%rsp) - 8ea: e9 69 fd ff ff jmpq 658 - 8ef: 90 nop - 8f0: 48 8b 43 08 mov 0x8(%rbx),%rax - 8f4: 48 89 44 14 38 mov %rax,0x38(%rsp,%rdx,1) - 8f9: 8b 44 24 48 mov 0x48(%rsp),%eax - 8fd: 44 8d 68 08 lea 0x8(%rax),%r13d - 901: 44 89 6c 24 48 mov %r13d,0x48(%rsp) - 906: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1) - 90d: 00 00 00 - 910: 8b 6c 24 24 mov 0x24(%rsp),%ebp - 914: 44 8b 64 24 20 mov 0x20(%rsp),%r12d - 919: e9 3a fd ff ff jmpq 658 - 91e: 66 90 xchg %ax,%ax - 920: 8b 44 24 20 mov 0x20(%rsp),%eax - 924: 8b 54 24 48 mov 0x48(%rsp),%edx - 928: 4c 8d 73 08 lea 0x8(%rbx),%r14 - 92c: 4c 8d 7b 10 lea 0x10(%rbx),%r15 - 930: 83 c0 08 add $0x8,%eax - 933: 48 8d 4a 08 lea 0x8(%rdx),%rcx - 937: 83 f8 0f cmp $0xf,%eax - 93a: 89 44 24 20 mov %eax,0x20(%rsp) - 93e: 0f 97 c0 seta %al - 941: 0f b6 c0 movzbl %al,%eax - 944: 09 44 24 24 or %eax,0x24(%rsp) - 948: 48 89 d0 mov %rdx,%rax - 94b: 48 83 f9 0f cmp $0xf,%rcx - 94f: 76 9f jbe 8f0 - 951: 85 d2 test %edx,%edx - 953: 0f 85 07 02 00 00 jne b60 - 959: 49 39 de cmp %rbx,%r14 - 95c: 0f 87 bc 00 00 00 ja a1e - 962: 8b 54 24 28 mov 0x28(%rsp),%edx - 966: 8b 7c 24 2c mov 0x2c(%rsp),%edi - 96a: 4c 89 f0 mov %r14,%rax - 96d: 44 8b 44 24 30 mov 0x30(%rsp),%r8d - 972: 44 8b 4c 24 34 mov 0x34(%rsp),%r9d - 977: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1) - 97e: 00 00 - 980: 69 08 77 ca eb 85 imul $0x85ebca77,(%rax),%ecx - 986: 48 83 c0 10 add $0x10,%rax - 98a: 69 70 f8 77 ca eb 85 imul $0x85ebca77,-0x8(%rax),%esi - 991: 01 ca add %ecx,%edx - 993: 69 48 f4 77 ca eb 85 imul $0x85ebca77,-0xc(%rax),%ecx - 99a: 44 01 c6 add %r8d,%esi - 99d: c1 c2 0d rol $0xd,%edx - 9a0: c1 c6 0d rol $0xd,%esi - 9a3: 69 d2 b1 79 37 9e imul $0x9e3779b1,%edx,%edx - 9a9: 01 cf add %ecx,%edi - 9ab: 69 48 fc 77 ca eb 85 imul $0x85ebca77,-0x4(%rax),%ecx - 9b2: c1 c7 0d rol $0xd,%edi - 9b5: 44 69 c6 b1 79 37 9e imul $0x9e3779b1,%esi,%r8d - 9bc: 69 ff b1 79 37 9e imul $0x9e3779b1,%edi,%edi - 9c2: 44 01 c9 add %r9d,%ecx - 9c5: c1 c1 0d rol $0xd,%ecx - 9c8: 44 69 c9 b1 79 37 9e imul $0x9e3779b1,%ecx,%r9d - 9cf: 48 39 d8 cmp %rbx,%rax - 9d2: 76 ac jbe 980 - 9d4: 44 89 44 24 18 mov %r8d,0x18(%rsp) - 9d9: 66 0f 6e 4c 24 18 movd 0x18(%rsp),%xmm1 - 9df: 48 89 d8 mov %rbx,%rax - 9e2: 44 89 4c 24 18 mov %r9d,0x18(%rsp) - 9e7: 66 0f 6e 74 24 18 movd 0x18(%rsp),%xmm6 - 9ed: 4c 29 f0 sub %r14,%rax - 9f0: 89 54 24 18 mov %edx,0x18(%rsp) - 9f4: 66 0f 6e 44 24 18 movd 0x18(%rsp),%xmm0 - 9fa: 48 83 e0 f0 and $0xfffffffffffffff0,%rax - 9fe: 89 7c 24 18 mov %edi,0x18(%rsp) - a02: 66 0f 6e 7c 24 18 movd 0x18(%rsp),%xmm7 - a08: 66 0f 62 ce punpckldq %xmm6,%xmm1 - a0c: 4d 8d 74 06 10 lea 0x10(%r14,%rax,1),%r14 - a11: 66 0f 62 c7 punpckldq %xmm7,%xmm0 - a15: 66 0f 6c c1 punpcklqdq %xmm1,%xmm0 - a19: 0f 11 44 24 28 movups %xmm0,0x28(%rsp) - a1e: 4d 39 fe cmp %r15,%r14 - a21: 0f 82 09 01 00 00 jb b30 - a27: 44 8b 6c 24 48 mov 0x48(%rsp),%r13d - a2c: 8b 6c 24 24 mov 0x24(%rsp),%ebp - a30: 44 8b 64 24 20 mov 0x20(%rsp),%r12d - a35: e9 1e fc ff ff jmpq 658 - a3a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) - a40: 48 8b 74 24 08 mov 0x8(%rsp),%rsi - a45: bd 10 00 00 00 mov $0x10,%ebp - a4a: 89 ea mov %ebp,%edx - a4c: 48 8d 7c 06 18 lea 0x18(%rsi,%rax,1),%rdi - a51: 44 29 ea sub %r13d,%edx - a54: 4c 89 fe mov %r15,%rsi - a57: e8 00 00 00 00 callq a5c - a5c: 69 44 24 38 77 ca eb imul $0x85ebca77,0x38(%rsp),%eax - a63: 85 - a64: 41 89 e8 mov %ebp,%r8d - a67: 03 44 24 28 add 0x28(%rsp),%eax - a6b: c1 c0 0d rol $0xd,%eax - a6e: 44 2b 44 24 48 sub 0x48(%rsp),%r8d - a73: c7 44 24 48 00 00 00 movl $0x0,0x48(%rsp) - a7a: 00 - a7b: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - a81: 4b 8d 34 07 lea (%r15,%r8,1),%rsi - a85: 89 44 24 28 mov %eax,0x28(%rsp) - a89: 69 44 24 3c 77 ca eb imul $0x85ebca77,0x3c(%rsp),%eax - a90: 85 - a91: 03 44 24 2c add 0x2c(%rsp),%eax - a95: c1 c0 0d rol $0xd,%eax - a98: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - a9e: 89 44 24 2c mov %eax,0x2c(%rsp) - aa2: 69 44 24 40 77 ca eb imul $0x85ebca77,0x40(%rsp),%eax - aa9: 85 - aaa: 03 44 24 30 add 0x30(%rsp),%eax - aae: c1 c0 0d rol $0xd,%eax - ab1: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - ab7: 89 44 24 30 mov %eax,0x30(%rsp) - abb: 69 44 24 44 77 ca eb imul $0x85ebca77,0x44(%rsp),%eax - ac2: 85 - ac3: 03 44 24 34 add 0x34(%rsp),%eax - ac7: c1 c0 0d rol $0xd,%eax - aca: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - ad0: 89 44 24 34 mov %eax,0x34(%rsp) - ad4: e9 65 f9 ff ff jmpq 43e - ad9: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) - ae0: 48 29 f0 sub %rsi,%rax - ae3: 49 89 c6 mov %rax,%r14 - ae6: 48 8b 44 24 08 mov 0x8(%rsp),%rax - aeb: 4c 89 f2 mov %r14,%rdx - aee: 45 89 f5 mov %r14d,%r13d - af1: 48 8d 78 18 lea 0x18(%rax),%rdi - af5: e8 00 00 00 00 callq afa - afa: 44 89 74 24 48 mov %r14d,0x48(%rsp) - aff: e9 10 fa ff ff jmpq 514 - b04: 0f 1f 40 00 nopl 0x0(%rax) - b08: 8b 54 24 28 mov 0x28(%rsp),%edx - b0c: 8b 44 24 2c mov 0x2c(%rsp),%eax - b10: c1 c6 0c rol $0xc,%esi - b13: c1 c0 07 rol $0x7,%eax - b16: d1 c2 rol %edx - b18: 01 c2 add %eax,%edx - b1a: 8d 04 32 lea (%rdx,%rsi,1),%eax - b1d: 8b 54 24 34 mov 0x34(%rsp),%edx - b21: c1 ca 0e ror $0xe,%edx - b24: 01 d0 add %edx,%eax - b26: e9 4e fb ff ff jmpq 679 - b2b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) - b30: 48 8b 44 24 08 mov 0x8(%rsp),%rax - b35: 4d 29 f7 sub %r14,%r15 - b38: 4c 89 f6 mov %r14,%rsi - b3b: 4c 89 fa mov %r15,%rdx - b3e: 45 89 fd mov %r15d,%r13d - b41: 48 8d 78 18 lea 0x18(%rax),%rdi - b45: e8 00 00 00 00 callq b4a - b4a: 44 89 7c 24 48 mov %r15d,0x48(%rsp) - b4f: 8b 6c 24 24 mov 0x24(%rsp),%ebp - b53: 44 8b 64 24 20 mov 0x20(%rsp),%r12d - b58: e9 fb fa ff ff jmpq 658 - b5d: 0f 1f 00 nopl (%rax) - b60: 48 8b 74 24 08 mov 0x8(%rsp),%rsi - b65: bd 10 00 00 00 mov $0x10,%ebp - b6a: 48 8d 7c 16 18 lea 0x18(%rsi,%rdx,1),%rdi - b6f: 89 ea mov %ebp,%edx - b71: 4c 89 f6 mov %r14,%rsi - b74: 29 c2 sub %eax,%edx - b76: e8 00 00 00 00 callq b7b - b7b: 69 44 24 38 77 ca eb imul $0x85ebca77,0x38(%rsp),%eax - b82: 85 - b83: 89 e9 mov %ebp,%ecx - b85: 03 44 24 28 add 0x28(%rsp),%eax - b89: c1 c0 0d rol $0xd,%eax - b8c: 2b 4c 24 48 sub 0x48(%rsp),%ecx - b90: c7 44 24 48 00 00 00 movl $0x0,0x48(%rsp) - b97: 00 - b98: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - b9e: 49 01 ce add %rcx,%r14 - ba1: 89 44 24 28 mov %eax,0x28(%rsp) - ba5: 69 44 24 3c 77 ca eb imul $0x85ebca77,0x3c(%rsp),%eax - bac: 85 - bad: 03 44 24 2c add 0x2c(%rsp),%eax - bb1: c1 c0 0d rol $0xd,%eax - bb4: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - bba: 89 44 24 2c mov %eax,0x2c(%rsp) - bbe: 69 44 24 40 77 ca eb imul $0x85ebca77,0x40(%rsp),%eax - bc5: 85 - bc6: 03 44 24 30 add 0x30(%rsp),%eax - bca: c1 c0 0d rol $0xd,%eax - bcd: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - bd3: 89 44 24 30 mov %eax,0x30(%rsp) - bd7: 69 44 24 44 77 ca eb imul $0x85ebca77,0x44(%rsp),%eax - bde: 85 - bdf: 03 44 24 34 add 0x34(%rsp),%eax - be3: c1 c0 0d rol $0xd,%eax - be6: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - bec: 89 44 24 34 mov %eax,0x34(%rsp) - bf0: e9 64 fd ff ff jmpq 959 - bf5: 0f 1f 00 nopl (%rax) - bf8: 48 8b 74 24 08 mov 0x8(%rsp),%rsi - bfd: 41 bf 10 00 00 00 mov $0x10,%r15d - c03: 44 89 fa mov %r15d,%edx - c06: 48 8d 7c 06 18 lea 0x18(%rsi,%rax,1),%rdi - c0b: 44 29 ea sub %r13d,%edx - c0e: 4c 89 f6 mov %r14,%rsi - c11: e8 00 00 00 00 callq c16 - c16: 44 2b 7c 24 48 sub 0x48(%rsp),%r15d - c1b: 8b 6c 24 24 mov 0x24(%rsp),%ebp - c1f: c7 44 24 48 00 00 00 movl $0x0,0x48(%rsp) - c26: 00 - c27: 69 44 24 38 77 ca eb imul $0x85ebca77,0x38(%rsp),%eax - c2e: 85 - c2f: 03 44 24 28 add 0x28(%rsp),%eax - c33: 4d 01 fe add %r15,%r14 - c36: c1 c0 0d rol $0xd,%eax - c39: 44 8b 64 24 20 mov 0x20(%rsp),%r12d - c3e: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - c44: 89 44 24 28 mov %eax,0x28(%rsp) - c48: 69 44 24 3c 77 ca eb imul $0x85ebca77,0x3c(%rsp),%eax - c4f: 85 - c50: 03 44 24 2c add 0x2c(%rsp),%eax - c54: c1 c0 0d rol $0xd,%eax - c57: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - c5d: 89 44 24 2c mov %eax,0x2c(%rsp) - c61: 69 44 24 40 77 ca eb imul $0x85ebca77,0x40(%rsp),%eax - c68: 85 - c69: 03 44 24 30 add 0x30(%rsp),%eax - c6d: c1 c0 0d rol $0xd,%eax - c70: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - c76: 89 44 24 30 mov %eax,0x30(%rsp) - c7a: 69 44 24 44 77 ca eb imul $0x85ebca77,0x44(%rsp),%eax - c81: 85 - c82: 03 44 24 34 add 0x34(%rsp),%eax - c86: c1 c0 0d rol $0xd,%eax - c89: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - c8f: 89 44 24 34 mov %eax,0x34(%rsp) - c93: e9 6b fb ff ff jmpq 803 - c98: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) - c9f: 00 - ca0: 48 8b 44 24 08 mov 0x8(%rsp),%rax - ca5: 4d 29 f7 sub %r14,%r15 - ca8: 4c 89 f6 mov %r14,%rsi - cab: 4c 89 fa mov %r15,%rdx - cae: 45 89 fd mov %r15d,%r13d - cb1: 48 8d 78 18 lea 0x18(%rax),%rdi - cb5: e8 00 00 00 00 callq cba - cba: 44 89 7c 24 48 mov %r15d,0x48(%rsp) - cbf: e9 94 f9 ff ff jmpq 658 - cc4: 0f 1f 40 00 nopl 0x0(%rax) - cc8: 48 8b 74 24 08 mov 0x8(%rsp),%rsi - ccd: bd 10 00 00 00 mov $0x10,%ebp - cd2: 89 ea mov %ebp,%edx - cd4: 48 8d 7c 06 18 lea 0x18(%rsi,%rax,1),%rdi - cd9: 44 29 ea sub %r13d,%edx - cdc: 4c 89 f6 mov %r14,%rsi - cdf: e8 00 00 00 00 callq ce4 - ce4: 69 44 24 38 77 ca eb imul $0x85ebca77,0x38(%rsp),%eax - ceb: 85 - cec: 03 44 24 28 add 0x28(%rsp),%eax - cf0: 41 89 e8 mov %ebp,%r8d - cf3: c1 c0 0d rol $0xd,%eax - cf6: 44 2b 44 24 48 sub 0x48(%rsp),%r8d - cfb: 8b 6c 24 24 mov 0x24(%rsp),%ebp - cff: c7 44 24 48 00 00 00 movl $0x0,0x48(%rsp) - d06: 00 - d07: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - d0d: 4d 01 c6 add %r8,%r14 - d10: 44 8b 64 24 20 mov 0x20(%rsp),%r12d - d15: 89 44 24 28 mov %eax,0x28(%rsp) - d19: 69 44 24 3c 77 ca eb imul $0x85ebca77,0x3c(%rsp),%eax - d20: 85 - d21: 03 44 24 2c add 0x2c(%rsp),%eax - d25: c1 c0 0d rol $0xd,%eax - d28: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - d2e: 89 44 24 2c mov %eax,0x2c(%rsp) - d32: 69 44 24 40 77 ca eb imul $0x85ebca77,0x40(%rsp),%eax - d39: 85 - d3a: 03 44 24 30 add 0x30(%rsp),%eax - d3e: c1 c0 0d rol $0xd,%eax - d41: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - d47: 89 44 24 30 mov %eax,0x30(%rsp) - d4b: 69 44 24 44 77 ca eb imul $0x85ebca77,0x44(%rsp),%eax - d52: 85 - d53: 03 44 24 34 add 0x34(%rsp),%eax - d57: c1 c0 0d rol $0xd,%eax - d5a: 69 c0 b1 79 37 9e imul $0x9e3779b1,%eax,%eax - d60: 89 44 24 34 mov %eax,0x34(%rsp) - d64: e9 20 f8 ff ff jmpq 589 - d69: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) - d70: 48 8b 53 08 mov 0x8(%rbx),%rdx - d74: 48 89 54 04 38 mov %rdx,0x38(%rsp,%rax,1) - d79: e9 7b fb ff ff jmpq 8f9 - d7e: 66 90 xchg %ax,%ax - d80: 48 8b 74 24 08 mov 0x8(%rsp),%rsi - d85: 4c 89 d2 mov %r10,%rdx - d88: 4c 89 54 24 18 mov %r10,0x18(%rsp) - d8d: 48 8d 7c 06 18 lea 0x18(%rsi,%rax,1),%rdi - d92: 4c 89 f6 mov %r14,%rsi - d95: e8 00 00 00 00 callq d9a - d9a: 44 8b 6c 24 48 mov 0x48(%rsp),%r13d - d9f: 4c 8b 54 24 18 mov 0x18(%rsp),%r10 - da4: 8b 6c 24 24 mov 0x24(%rsp),%ebp - da8: 44 8b 64 24 20 mov 0x20(%rsp),%r12d - dad: 45 01 d5 add %r10d,%r13d - db0: 44 89 6c 24 48 mov %r13d,0x48(%rsp) - db5: e9 9e f8 ff ff jmpq 658 - dba: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) - dc0: 8b 74 24 30 mov 0x30(%rsp),%esi - dc4: 8b 6c 24 24 mov 0x24(%rsp),%ebp - dc8: 48 8d 44 24 20 lea 0x20(%rsp),%rax - dcd: 48 89 44 24 08 mov %rax,0x8(%rsp) - dd2: 44 8b 64 24 20 mov 0x20(%rsp),%r12d - dd7: 8d 86 b1 67 56 16 lea 0x165667b1(%rsi),%eax - ddd: 85 ed test %ebp,%ebp - ddf: 0f 84 94 f8 ff ff je 679 - de5: e9 1e fd ff ff jmpq b08 - dea: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) - -0000000000000df0 : - df0: 31 d2 xor %edx,%edx - df2: e9 00 00 00 00 jmpq df7 - df7: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1) - dfe: 00 00 - -0000000000000e00 : - e00: 41 54 push %r12 - e02: 49 89 f4 mov %rsi,%r12 - e05: 55 push %rbp - e06: 48 89 fd mov %rdi,%rbp - e09: bf 18 00 00 00 mov $0x18,%edi - e0e: 53 push %rbx - e0f: e8 00 00 00 00 callq e14 - e14: 4d 85 e4 test %r12,%r12 - e17: 4c 89 e6 mov %r12,%rsi - e1a: 48 89 c3 mov %rax,%rbx - e1d: b8 00 00 00 00 mov $0x0,%eax - e22: 48 0f 44 e8 cmove %rax,%rbp - e26: 4c 89 63 08 mov %r12,0x8(%rbx) - e2a: c6 43 14 00 movb $0x0,0x14(%rbx) - e2e: 48 89 ef mov %rbp,%rdi - e31: 48 89 2b mov %rbp,(%rbx) - e34: e8 00 00 00 00 callq e39 - e39: 89 43 10 mov %eax,0x10(%rbx) - e3c: 48 89 d8 mov %rbx,%rax - e3f: 5b pop %rbx - e40: 5d pop %rbp - e41: 41 5c pop %r12 - e43: c3 retq - e44: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) - e4b: 00 00 00 00 - e4f: 90 nop - -0000000000000e50 : - e50: 80 7f 14 00 cmpb $0x0,0x14(%rdi) - e54: 75 0d jne e63 - e56: 48 8b 47 08 mov 0x8(%rdi),%rax - e5a: c6 47 14 01 movb $0x1,0x14(%rdi) - e5e: 48 85 c0 test %rax,%rax - e61: 75 05 jne e68 - e63: c3 retq - e64: 0f 1f 40 00 nopl 0x0(%rax) - e68: 41 55 push %r13 - e6a: 41 54 push %r12 - e6c: 45 31 e4 xor %r12d,%r12d - e6f: 55 push %rbp - e70: 48 89 fd mov %rdi,%rbp - e73: 48 8d 3c 40 lea (%rax,%rax,2),%rdi - e77: 53 push %rbx - e78: 48 c1 e7 03 shl $0x3,%rdi - e7c: 31 db xor %ebx,%ebx - e7e: 48 83 ec 08 sub $0x8,%rsp - e82: e8 00 00 00 00 callq e87 - e87: 49 89 c5 mov %rax,%r13 - e8a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) - e90: 48 8b 75 00 mov 0x0(%rbp),%rsi - e94: 49 8d 7c 1d 00 lea 0x0(%r13,%rbx,1),%rdi - e99: 49 83 c4 01 add $0x1,%r12 - e9d: 48 01 de add %rbx,%rsi - ea0: 48 83 c3 18 add $0x18,%rbx - ea4: e8 00 00 00 00 callq ea9 - ea9: 4c 39 65 08 cmp %r12,0x8(%rbp) - ead: 77 e1 ja e90 - eaf: 4c 89 6d 00 mov %r13,0x0(%rbp) - eb3: 48 83 c4 08 add $0x8,%rsp - eb7: 5b pop %rbx - eb8: 5d pop %rbp - eb9: 41 5c pop %r12 - ebb: 41 5d pop %r13 - ebd: c3 retq - ebe: 66 90 xchg %ax,%ax - -0000000000000ec0 : - ec0: 48 8b 47 08 mov 0x8(%rdi),%rax - ec4: 48 89 02 mov %rax,(%rdx) - ec7: 48 85 c0 test %rax,%rax - eca: 75 0c jne ed8 - ecc: 48 c7 06 00 00 00 00 movq $0x0,(%rsi) - ed3: c3 retq - ed4: 0f 1f 40 00 nopl 0x0(%rax) - ed8: 41 55 push %r13 - eda: 41 54 push %r12 - edc: 4c 8d 24 40 lea (%rax,%rax,2),%r12 - ee0: 55 push %rbp - ee1: 49 c1 e4 03 shl $0x3,%r12 - ee5: 48 89 fd mov %rdi,%rbp - ee8: 53 push %rbx - ee9: 4c 89 e7 mov %r12,%rdi - eec: 48 89 f3 mov %rsi,%rbx - eef: 48 83 ec 08 sub $0x8,%rsp - ef3: e8 00 00 00 00 callq ef8 - ef8: 48 89 03 mov %rax,(%rbx) - efb: 49 89 c5 mov %rax,%r13 - efe: 31 db xor %ebx,%ebx - f00: 48 8b 75 00 mov 0x0(%rbp),%rsi - f04: 49 8d 7c 1d 00 lea 0x0(%r13,%rbx,1),%rdi - f09: 48 01 de add %rbx,%rsi - f0c: 48 83 c3 18 add $0x18,%rbx - f10: e8 00 00 00 00 callq f15 - f15: 49 39 dc cmp %rbx,%r12 - f18: 75 e6 jne f00 - f1a: 48 83 c4 08 add $0x8,%rsp - f1e: 5b pop %rbx - f1f: 5d pop %rbp - f20: 41 5c pop %r12 - f22: 41 5d pop %r13 - f24: c3 retq - f25: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) - f2c: 00 00 00 00 - -0000000000000f30 : - f30: 41 54 push %r12 - f32: 55 push %rbp - f33: 48 89 fd mov %rdi,%rbp - f36: bf 18 00 00 00 mov $0x18,%edi - f3b: 53 push %rbx - f3c: e8 00 00 00 00 callq f41 - f41: 8b 55 10 mov 0x10(%rbp),%edx - f44: 49 89 c4 mov %rax,%r12 - f47: 48 8b 45 08 mov 0x8(%rbp),%rax - f4b: 41 89 54 24 10 mov %edx,0x10(%r12) - f50: 49 89 44 24 08 mov %rax,0x8(%r12) - f55: 41 c6 44 24 14 01 movb $0x1,0x14(%r12) - f5b: 48 85 c0 test %rax,%rax - f5e: 75 10 jne f70 - f60: 4c 89 e0 mov %r12,%rax - f63: 5b pop %rbx - f64: 5d pop %rbp - f65: 49 c7 04 24 00 00 00 movq $0x0,(%r12) - f6c: 00 - f6d: 41 5c pop %r12 - f6f: c3 retq - f70: 48 8d 3c 40 lea (%rax,%rax,2),%rdi - f74: 31 db xor %ebx,%ebx - f76: 48 c1 e7 03 shl $0x3,%rdi - f7a: e8 00 00 00 00 callq f7f - f7f: 49 89 04 24 mov %rax,(%r12) - f83: eb 07 jmp f8c - f85: 0f 1f 00 nopl (%rax) - f88: 49 8b 04 24 mov (%r12),%rax - f8c: 48 8d 3c 5b lea (%rbx,%rbx,2),%rdi - f90: 48 8b 75 00 mov 0x0(%rbp),%rsi - f94: 48 83 c3 01 add $0x1,%rbx - f98: 48 c1 e7 03 shl $0x3,%rdi - f9c: 48 01 fe add %rdi,%rsi - f9f: 48 01 c7 add %rax,%rdi - fa2: e8 00 00 00 00 callq fa7 - fa7: 49 39 5c 24 08 cmp %rbx,0x8(%r12) - fac: 77 da ja f88 - fae: 4c 89 e0 mov %r12,%rax - fb1: 5b pop %rbx - fb2: 5d pop %rbp - fb3: 41 5c pop %r12 - fb5: c3 retq - fb6: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1) - fbd: 00 00 00 - -0000000000000fc0 : - fc0: 53 push %rbx - fc1: 80 7f 14 00 cmpb $0x0,0x14(%rdi) - fc5: 48 89 fb mov %rdi,%rbx - fc8: 75 0e jne fd8 - fca: 48 89 df mov %rbx,%rdi - fcd: 5b pop %rbx - fce: e9 00 00 00 00 jmpq fd3 - fd3: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) - fd8: 48 8b 77 08 mov 0x8(%rdi),%rsi - fdc: 48 8b 3f mov (%rdi),%rdi - fdf: e8 00 00 00 00 callq fe4 - fe4: 48 89 df mov %rbx,%rdi - fe7: 5b pop %rbx - fe8: e9 00 00 00 00 jmpq fed - fed: 0f 1f 00 nopl (%rax) - -0000000000000ff0 : - ff0: 89 f2 mov %esi,%edx - ff2: 48 8b 77 08 mov 0x8(%rdi),%rsi - ff6: 48 8b 3f mov (%rdi),%rdi - ff9: e9 00 00 00 00 jmpq ffe - ffe: 66 90 xchg %ax,%ax - -0000000000001000 : - 1000: 41 57 push %r15 - 1002: 41 56 push %r14 - 1004: 41 55 push %r13 - 1006: 41 54 push %r12 - 1008: 55 push %rbp - 1009: 53 push %rbx - 100a: 48 83 ec 58 sub $0x58,%rsp - 100e: 48 89 54 24 48 mov %rdx,0x48(%rsp) - 1013: 48 89 4c 24 40 mov %rcx,0x40(%rsp) - 1018: 48 85 f6 test %rsi,%rsi - 101b: 0f 84 a8 02 00 00 je 12c9 - 1021: 48 89 fd mov %rdi,%rbp - 1024: bf 00 04 00 00 mov $0x400,%edi - 1029: 48 89 f3 mov %rsi,%rbx - 102c: e8 00 00 00 00 callq 1031 - 1031: bf 00 04 00 00 mov $0x400,%edi - 1036: 49 89 c5 mov %rax,%r13 - 1039: e8 00 00 00 00 callq 103e - 103e: 49 89 c4 mov %rax,%r12 - 1041: 85 db test %ebx,%ebx - 1043: 0f 8e e8 02 00 00 jle 1331 - 1049: 8d 43 ff lea -0x1(%rbx),%eax - 104c: 48 89 6c 24 08 mov %rbp,0x8(%rsp) - 1051: 41 be 00 04 00 00 mov $0x400,%r14d - 1057: bb 00 04 00 00 mov $0x400,%ebx - 105c: 48 8d 04 40 lea (%rax,%rax,2),%rax - 1060: c7 44 24 24 00 00 00 movl $0x0,0x24(%rsp) - 1067: 00 - 1068: 48 c7 44 24 10 00 04 movq $0x400,0x10(%rsp) - 106f: 00 00 - 1071: 48 8d 44 c5 18 lea 0x18(%rbp,%rax,8),%rax - 1076: 48 89 44 24 18 mov %rax,0x18(%rsp) - 107b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) - 1080: 48 8b 44 24 08 mov 0x8(%rsp),%rax - 1085: 8b 40 08 mov 0x8(%rax),%eax - 1088: 83 f8 01 cmp $0x1,%eax - 108b: 0f 84 ef 01 00 00 je 1280 - 1091: 85 c0 test %eax,%eax - 1093: 0f 84 77 01 00 00 je 1210 - 1099: 83 f8 02 cmp $0x2,%eax - 109c: 0f 84 de 00 00 00 je 1180 - 10a2: 48 63 6c 24 24 movslq 0x24(%rsp),%rbp - 10a7: 4c 8b 7c 24 10 mov 0x10(%rsp),%r15 - 10ac: 49 8d 86 00 04 00 00 lea 0x400(%r14),%rax - 10b3: 4c 29 f8 sub %r15,%rax - 10b6: 48 89 c2 mov %rax,%rdx - 10b9: 4c 39 fd cmp %r15,%rbp - 10bc: 72 33 jb 10f1 - 10be: 4c 89 e0 mov %r12,%rax - 10c1: 49 89 dc mov %rbx,%r12 - 10c4: 48 89 d3 mov %rdx,%rbx - 10c7: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1) - 10ce: 00 00 - 10d0: 4e 8d 34 3b lea (%rbx,%r15,1),%r14 - 10d4: 48 89 c7 mov %rax,%rdi - 10d7: 49 81 c7 00 04 00 00 add $0x400,%r15 - 10de: 4c 89 f6 mov %r14,%rsi - 10e1: e8 00 00 00 00 callq 10e6 - 10e6: 49 39 ef cmp %rbp,%r15 - 10e9: 76 e5 jbe 10d0 - 10eb: 4c 89 e3 mov %r12,%rbx - 10ee: 49 89 c4 mov %rax,%r12 - 10f1: 4c 89 f7 mov %r14,%rdi - 10f4: 48 89 ea mov %rbp,%rdx - 10f7: 4c 89 ee mov %r13,%rsi - 10fa: 4c 29 ff sub %r15,%rdi - 10fd: 4c 01 e7 add %r12,%rdi - 1100: e8 00 00 00 00 callq 1105 - 1105: 4c 89 f8 mov %r15,%rax - 1108: 48 83 44 24 08 18 addq $0x18,0x8(%rsp) - 110e: 48 29 e8 sub %rbp,%rax - 1111: 48 89 44 24 10 mov %rax,0x10(%rsp) - 1116: 48 8b 44 24 08 mov 0x8(%rsp),%rax - 111b: 48 39 44 24 18 cmp %rax,0x18(%rsp) - 1120: 0f 85 5a ff ff ff jne 1080 - 1126: 4c 29 fd sub %r15,%rbp - 1129: 4c 01 f5 add %r14,%rbp - 112c: 48 8d 7d 01 lea 0x1(%rbp),%rdi - 1130: e8 00 00 00 00 callq 1135 - 1135: 48 89 ea mov %rbp,%rdx - 1138: 4c 89 e6 mov %r12,%rsi - 113b: 48 89 c1 mov %rax,%rcx - 113e: 48 8b 44 24 48 mov 0x48(%rsp),%rax - 1143: 48 89 cf mov %rcx,%rdi - 1146: 48 89 08 mov %rcx,(%rax) - 1149: e8 00 00 00 00 callq 114e - 114e: 4c 89 e7 mov %r12,%rdi - 1151: c6 04 28 00 movb $0x0,(%rax,%rbp,1) - 1155: 48 8b 44 24 40 mov 0x40(%rsp),%rax - 115a: 48 89 28 mov %rbp,(%rax) - 115d: e8 00 00 00 00 callq 1162 - 1162: 48 83 c4 58 add $0x58,%rsp - 1166: 4c 89 ef mov %r13,%rdi - 1169: 5b pop %rbx - 116a: 5d pop %rbp - 116b: 41 5c pop %r12 - 116d: 41 5d pop %r13 - 116f: 41 5e pop %r14 - 1171: 41 5f pop %r15 - 1173: e9 00 00 00 00 jmpq 1178 - 1178: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) - 117f: 00 - 1180: 48 8b 6c 24 08 mov 0x8(%rsp),%rbp - 1185: 48 8b 45 00 mov 0x0(%rbp),%rax - 1189: 48 89 c7 mov %rax,%rdi - 118c: 48 89 44 24 28 mov %rax,0x28(%rsp) - 1191: e8 00 00 00 00 callq 1196 - 1196: 49 89 c7 mov %rax,%r15 - 1199: 48 8b 45 10 mov 0x10(%rbp),%rax - 119d: 48 89 c7 mov %rax,%rdi - 11a0: 48 89 44 24 30 mov %rax,0x30(%rsp) - 11a5: e8 00 00 00 00 callq 11aa - 11aa: 48 89 44 24 38 mov %rax,0x38(%rsp) - 11af: 44 01 f8 add %r15d,%eax - 11b2: 48 63 e8 movslq %eax,%rbp - 11b5: 89 44 24 24 mov %eax,0x24(%rsp) - 11b9: 48 39 dd cmp %rbx,%rbp - 11bc: 72 24 jb 11e2 - 11be: 4c 89 e8 mov %r13,%rax - 11c1: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) - 11c8: 48 81 c3 00 04 00 00 add $0x400,%rbx - 11cf: 48 89 c7 mov %rax,%rdi - 11d2: 48 89 de mov %rbx,%rsi - 11d5: e8 00 00 00 00 callq 11da - 11da: 48 39 eb cmp %rbp,%rbx - 11dd: 76 e9 jbe 11c8 - 11df: 49 89 c5 mov %rax,%r13 - 11e2: 48 8b 74 24 28 mov 0x28(%rsp),%rsi - 11e7: 4c 89 fa mov %r15,%rdx - 11ea: 4c 89 ef mov %r13,%rdi - 11ed: e8 00 00 00 00 callq 11f2 - 11f2: 48 8b 54 24 38 mov 0x38(%rsp),%rdx - 11f7: 48 8b 74 24 30 mov 0x30(%rsp),%rsi - 11fc: 4b 8d 7c 3d 00 lea 0x0(%r13,%r15,1),%rdi - 1201: e8 00 00 00 00 callq 1206 - 1206: e9 9c fe ff ff jmpq 10a7 - 120b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) - 1210: 48 8b 44 24 08 mov 0x8(%rsp),%rax - 1215: 48 8b 00 mov (%rax),%rax - 1218: 48 89 c7 mov %rax,%rdi - 121b: 48 89 44 24 28 mov %rax,0x28(%rsp) - 1220: e8 00 00 00 00 callq 1225 - 1225: 49 89 c7 mov %rax,%r15 - 1228: 8d 40 08 lea 0x8(%rax),%eax - 122b: 48 63 e8 movslq %eax,%rbp - 122e: 89 44 24 24 mov %eax,0x24(%rsp) - 1232: 48 39 dd cmp %rbx,%rbp - 1235: 72 23 jb 125a - 1237: 4c 89 e8 mov %r13,%rax - 123a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) - 1240: 48 81 c3 00 04 00 00 add $0x400,%rbx - 1247: 48 89 c7 mov %rax,%rdi - 124a: 48 89 de mov %rbx,%rsi - 124d: e8 00 00 00 00 callq 1252 - 1252: 48 39 eb cmp %rbp,%rbx - 1255: 76 e9 jbe 1240 - 1257: 49 89 c5 mov %rax,%r13 - 125a: 48 8b 74 24 28 mov 0x28(%rsp),%rsi - 125f: 4c 89 fa mov %r15,%rdx - 1262: 4c 89 ef mov %r13,%rdi - 1265: e8 00 00 00 00 callq 126a - 126a: 48 8b 44 24 08 mov 0x8(%rsp),%rax - 126f: 48 8b 40 10 mov 0x10(%rax),%rax - 1273: 4b 89 44 3d 00 mov %rax,0x0(%r13,%r15,1) - 1278: e9 2a fe ff ff jmpq 10a7 - 127d: 0f 1f 00 nopl (%rax) - 1280: 48 8b 44 24 08 mov 0x8(%rsp),%rax - 1285: 48 8b 00 mov (%rax),%rax - 1288: 48 89 c7 mov %rax,%rdi - 128b: 48 89 44 24 28 mov %rax,0x28(%rsp) - 1290: e8 00 00 00 00 callq 1295 - 1295: 49 89 c7 mov %rax,%r15 - 1298: 8d 40 08 lea 0x8(%rax),%eax - 129b: 48 63 e8 movslq %eax,%rbp - 129e: 89 44 24 24 mov %eax,0x24(%rsp) - 12a2: 48 39 dd cmp %rbx,%rbp - 12a5: 72 b3 jb 125a - 12a7: 4c 89 e8 mov %r13,%rax - 12aa: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) - 12b0: 48 81 c3 00 04 00 00 add $0x400,%rbx - 12b7: 48 89 c7 mov %rax,%rdi - 12ba: 48 89 de mov %rbx,%rsi - 12bd: e8 00 00 00 00 callq 12c2 - 12c2: 48 39 eb cmp %rbp,%rbx - 12c5: 76 e9 jbe 12b0 - 12c7: eb 8e jmp 1257 - 12c9: 48 8d 3d 00 00 00 00 lea 0x0(%rip),%rdi # 12d0 - 12d0: e8 00 00 00 00 callq 12d5 - 12d5: 48 8b 54 24 48 mov 0x48(%rsp),%rdx - 12da: 48 89 c1 mov %rax,%rcx - 12dd: 48 89 02 mov %rax,(%rdx) - 12e0: 8b 31 mov (%rcx),%esi - 12e2: 48 83 c1 04 add $0x4,%rcx - 12e6: 8d 96 ff fe fe fe lea -0x1010101(%rsi),%edx - 12ec: f7 d6 not %esi - 12ee: 21 f2 and %esi,%edx - 12f0: 81 e2 80 80 80 80 and $0x80808080,%edx - 12f6: 74 e8 je 12e0 - 12f8: 89 d6 mov %edx,%esi - 12fa: c1 ee 10 shr $0x10,%esi - 12fd: f7 c2 80 80 00 00 test $0x8080,%edx - 1303: 0f 44 d6 cmove %esi,%edx - 1306: 48 8d 71 02 lea 0x2(%rcx),%rsi - 130a: 48 0f 44 ce cmove %rsi,%rcx - 130e: 89 d6 mov %edx,%esi - 1310: 40 00 d6 add %dl,%sil - 1313: 48 83 d9 03 sbb $0x3,%rcx - 1317: 48 29 c1 sub %rax,%rcx - 131a: 48 8b 44 24 40 mov 0x40(%rsp),%rax - 131f: 48 89 08 mov %rcx,(%rax) - 1322: 48 83 c4 58 add $0x58,%rsp - 1326: 5b pop %rbx - 1327: 5d pop %rbp - 1328: 41 5c pop %r12 - 132a: 41 5d pop %r13 - 132c: 41 5e pop %r14 - 132e: 41 5f pop %r15 - 1330: c3 retq - 1331: bf 01 00 00 00 mov $0x1,%edi - 1336: 31 ed xor %ebp,%ebp - 1338: e9 f3 fd ff ff jmpq 1130 - 133d: 0f 1f 00 nopl (%rax) - -0000000000001340 : - 1340: 48 83 ec 18 sub $0x18,%rsp - 1344: 48 8b 77 08 mov 0x8(%rdi),%rsi - 1348: 48 8b 3f mov (%rdi),%rdi - 134b: 48 8d 4c 24 08 lea 0x8(%rsp),%rcx - 1350: 48 89 e2 mov %rsp,%rdx - 1353: e8 00 00 00 00 callq 1358 - 1358: 48 8b 04 24 mov (%rsp),%rax - 135c: 48 83 c4 18 add $0x18,%rsp - 1360: c3 retq diff --git a/readme_fieldstat_easy.md b/readme_fieldstat_easy.md index 67e6901..14f0927 100644 --- a/readme_fieldstat_easy.md +++ b/readme_fieldstat_easy.md @@ -169,15 +169,15 @@ All the metrics in fieldstat easy are dynamic, which means that the metrics has #include "fieldstat_easy.h" const int N_THREADS = 3; -struct fieldstat_tag global_tags[1]; -struct fieldstat_tag tmptag; +struct field global_tags[1]; +struct field tmptag; tmptag.key = "app id"; tmptag.type = TAG_INTEGER; tmptag.value_longlong = 1; global_tags[0] = tmptag; -struct fieldstat_tag tag1 = {"direction", TAG_STRING, "incoming"}; -struct fieldstat_tag tag2 = {"direction", TAG_STRING, "outgoing"}; +struct field tag1 = {"direction", TAG_STRING, "incoming"}; +struct field tag2 = {"direction", TAG_STRING, "outgoing"}; struct fieldstat_easy *fse = fieldstat_easy_new(N_THREADS, NULL, global_tags, 1); int counter_id = fieldstat_easy_register_counter(fse, "incoming bytes"); diff --git a/src/cube.c b/src/cube.c index 92e999e..dfb0198 100644 --- a/src/cube.c +++ b/src/cube.c @@ -18,7 +18,7 @@ #define DEFAULT_N_CUBE 64 struct exdata_new_args { - const struct fieldstat_tag *tags; + const struct field *fields; size_t n_tags; }; @@ -34,7 +34,7 @@ struct cell { struct metric **metrics; size_t metrics_len; size_t max_n_metric; - struct fieldstat_tag_list tags; // cell identifier + struct field_list fields; // cell identifier }; struct cube { @@ -45,8 +45,8 @@ struct cube { }; size_t max_n_cell; - // the key of cube is the combination of shared tags - struct fieldstat_tag *cube_identifier; + // the key of cube is the combination of shared fields + struct field *cube_identifier; size_t n_shared_tags; int primary_metric_id; @@ -56,11 +56,11 @@ struct cube { UT_hash_handle hh; }; -static struct fieldstat_tag *tag_array_duplicate(const struct fieldstat_tag *tags_src, size_t n_tag) +static struct field *tag_array_duplicate(const struct field *tags_src, size_t n_field) { - struct fieldstat_tag *tags_dst = malloc(sizeof(struct fieldstat_tag) * n_tag); + struct field *tags_dst = malloc(sizeof(struct field) * n_field); - for (size_t i = 0; i < n_tag; i++) { + for (size_t i = 0; i < n_field; i++) { tags_dst[i].key = strdup(tags_src[i].key); tags_dst[i].type = tags_src[i].type; switch (tags_src[i].type) @@ -82,16 +82,16 @@ static struct fieldstat_tag *tag_array_duplicate(const struct fieldstat_tag *tag return tags_dst; } -static void fieldstat_free_tag_array(struct fieldstat_tag *tags, size_t n_tags) +static void fieldstat_free_tag_array(struct field *fields, size_t n_tags) { for (size_t i = 0; i < n_tags; i++) { - struct fieldstat_tag *tag = &tags[i]; - free((char *)tag->key); - if (tag->type == TAG_CSTRING) { - free((char *)tag->value_str); + struct field *field = &fields[i]; + free((char *)field->key); + if (field->type == TAG_CSTRING) { + free((char *)field->value_str); } } - free(tags); + free(fields); } void add_cube_to_position(struct cube_manager *instance, struct cube *cube, int id) @@ -134,22 +134,78 @@ struct cube_manager *cube_manager_new() { return pthis; } -static void tags2key(const struct fieldstat_tag tags[], size_t n_tags, char **out_key, size_t *out_key_size) +static int tags2key_safe(const struct field fields[], size_t n_tags, char *out_key, size_t out_key_size) +{ + if (n_tags == 0) { + const char dummy[] = "no fields"; + size_t len_dummy = sizeof(dummy) - 1; + if (out_key_size < len_dummy) { + return -1; + } + memcpy(out_key, dummy, len_dummy); + return len_dummy; + } + int i = 0; + size_t used_len = 0; + struct field *field = NULL; + + size_t remain_key_size = out_key_size; + void *val_position = NULL; + + size_t key_len = 0; + size_t val_len = 0; + + for(i = 0; i < (int)n_tags; i++) + { + field = (struct field *)&fields[i]; + key_len = strlen(field->key); + switch(field->type) + { + case TAG_INTEGER: + val_len = sizeof(long long); + val_position = (void *)&field->value_longlong; + break; + case TAG_DOUBLE: + val_len = sizeof(double); + val_position = (void *)&field->value_double; + + break; + case TAG_CSTRING: + val_len = strlen(field->value_str); + val_position = (void *)field->value_str; + break; + default: + assert(0); + break; + } + + used_len = key_len + val_len; + while (used_len >= remain_key_size) { + return -1; + } + memcpy(out_key + out_key_size - remain_key_size, field->key, key_len); + memcpy(out_key + out_key_size - remain_key_size + key_len, val_position, val_len); + remain_key_size -= used_len; + } + + return out_key_size - remain_key_size; +} + +static void tags2key_endeavor(const struct field fields[], size_t n_tags, char **out_key, size_t *out_key_size) { if (n_tags == 0) { // use a default dummy key - *out_key = strdup("no tags"); + *out_key = strdup("no fields"); *out_key_size = strlen(*out_key); return; } int i = 0; size_t used_len = 0; - struct fieldstat_tag *tag = NULL; + struct field *field = 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; + size_t remain_key_size = 4096 + 1024; + size_t total_key_size = 4096 + 1024; char *dynamic_mem = (char *)malloc(total_key_size); void *val_position = NULL; @@ -158,22 +214,22 @@ static void tags2key(const struct fieldstat_tag tags[], size_t n_tags, char **ou for(i = 0; i < (int)n_tags; i++) { - tag = (struct fieldstat_tag *)&tags[i]; - key_len = strlen(tag->key); - switch(tag->type) + field = (struct field *)&fields[i]; + key_len = strlen(field->key); + switch(field->type) { case TAG_INTEGER: val_len = sizeof(long long); - val_position = (void *)&tag->value_longlong; + val_position = (void *)&field->value_longlong; break; case TAG_DOUBLE: val_len = sizeof(double); - val_position = (void *)&tag->value_double; + val_position = (void *)&field->value_double; break; case TAG_CSTRING: - val_len = strlen(tag->value_str); - val_position = (void *)tag->value_str; + val_len = strlen(field->value_str); + val_position = (void *)field->value_str; break; default: assert(0); @@ -186,7 +242,7 @@ static void tags2key(const struct fieldstat_tag tags[], size_t n_tags, char **ou remain_key_size += alloced_every_time; dynamic_mem = (char *)realloc(dynamic_mem, total_key_size); } - memcpy(dynamic_mem + total_key_size - remain_key_size, tag->key, key_len); + memcpy(dynamic_mem + total_key_size - remain_key_size, field->key, key_len); memcpy(dynamic_mem + total_key_size - remain_key_size + key_len, val_position, val_len); remain_key_size -= used_len; } @@ -241,19 +297,26 @@ void cube_manager_delete(struct cube_manager *pthis, struct cube *cube) } } -int cube_manager_find(const struct cube_manager *pthis, const struct fieldstat_tag *identifier, size_t n_tag) +int cube_manager_find(const struct cube_manager *pthis, const struct field *identifier, size_t n_field) { - 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); + char key_stack[4096]; + char *key = key_stack; + int key_len = tags2key_safe(identifier, n_field, key, sizeof(key)); + bool free_key = false; + if (key_len < 0) { // very unlikely to happen + char *key_heap; + size_t key_len_tmp; + tags2key_endeavor(identifier, n_field, &key_heap, &key_len_tmp); + key = key_heap; + key_len = key_len_tmp; + free_key = true; + } struct cube *node = NULL; HASH_FIND(hh, pthis->hash_table, key, key_len, node); - free(key); + if (free_key) { + free(key); + } if (node == NULL) { return -1; } else { @@ -389,8 +452,8 @@ struct cell *cell_new(const struct exdata_new_args *args) { pthis->max_n_metric = DEFAULT_N_METRIC; pthis->metrics_len = 0; - pthis->tags.n_tag = args->n_tags; - pthis->tags.tag = tag_array_duplicate(args->tags, args->n_tags); + pthis->fields.n_field = args->n_tags; + pthis->fields.field = tag_array_duplicate(args->fields, args->n_tags); return pthis; } @@ -399,13 +462,13 @@ void cell_free(struct cell *pthis) { metric_free(pthis->metrics[i]); } free(pthis->metrics); - for (size_t i = 0; i < pthis->tags.n_tag; i++) { - free((char *)pthis->tags.tag[i].key); - if (pthis->tags.tag[i].type == TAG_CSTRING) { - free((char *)pthis->tags.tag[i].value_str); + for (size_t i = 0; i < pthis->fields.n_field; i++) { + free((char *)pthis->fields.field[i].key); + if (pthis->fields.field[i].type == TAG_CSTRING) { + free((char *)pthis->fields.field[i].value_str); } } - free(pthis->tags.tag); + free(pthis->fields.field); free(pthis); } @@ -422,8 +485,8 @@ struct cell *cell_copy(const struct cell *src) { pthis->metrics[i] = metric_copy(src->metrics[i]); } - pthis->tags.n_tag = src->tags.n_tag; - pthis->tags.tag = tag_array_duplicate(src->tags.tag, src->tags.n_tag); + pthis->fields.n_field = src->fields.n_field; + pthis->fields.field = tag_array_duplicate(src->fields.field, src->fields.n_field); return pthis; } @@ -474,29 +537,29 @@ void *exdata_copy_i(void *exdata) { return cell_copy((struct cell *)exdata); } -struct cube *cube_info_new(const struct fieldstat_tag *shared_tags, size_t n_tag, enum sampling_mode mode, size_t max_n_cell) +struct cube *cube_info_new(const struct field *shared_tags, size_t n_field, enum sampling_mode mode, size_t max_n_cell) { struct cube *cube = calloc(1, sizeof(struct cube)); cube->sampling_mode = mode; - if (n_tag == 0) { + if (n_field == 0) { cube->cube_identifier = NULL; } else { - cube->cube_identifier = tag_array_duplicate(shared_tags, n_tag); + cube->cube_identifier = tag_array_duplicate(shared_tags, n_field); } - cube->n_shared_tags = n_tag; + cube->n_shared_tags = n_field; cube->max_n_cell = max_n_cell; - tags2key(shared_tags, n_tag, &cube->key, &cube->key_len); + tags2key_endeavor(shared_tags, n_field, &cube->key, &cube->key_len); cube->id = -1; return cube; } -struct cube *cube_new(const struct fieldstat_tag *shared_tags, size_t n_tag, enum sampling_mode mode, size_t max_n_cell) +struct cube *cube_new(const struct field *shared_tags, size_t n_field, enum sampling_mode mode, size_t max_n_cell) { - struct cube *cube = cube_info_new(shared_tags, n_tag, mode, max_n_cell); + struct cube *cube = cube_info_new(shared_tags, n_field, mode, max_n_cell); switch (mode) { @@ -548,54 +611,65 @@ void cube_set_primary_metric(struct cube *cube, int metric_id) { cube->primary_metric_id = metric_id; } -struct cell *get_cell(struct cube *cube, const struct fieldstat_tag *tags, size_t n_tag,long long increment, int metric_id) { - char *tag_in_string; - size_t tag_len; - tags2key(tags, n_tag, &tag_in_string, &tag_len); +struct cell *get_cell(struct cube *cube, const struct field *fields, size_t n_field,long long increment, int metric_id) { + char key_stack[4096]; + char *key = key_stack; + int key_len = tags2key_safe(fields, n_field, key, sizeof(key)); + bool free_key = false; + if (key_len < 0) { // very unlikely to happen + char *key_heap; + size_t key_len_tmp; + tags2key_endeavor(fields, n_field, &key_heap, &key_len_tmp); + key = key_heap; + key_len = key_len_tmp; + free_key = true; + } + struct exdata_new_args args; - args.tags = tags; - args.n_tags = n_tag; + args.fields = fields; + args.n_tags = n_field; struct cell *cell_data = NULL; - switch (cube->sampling_mode) { case SAMPLING_MODE_TOPK: { if (cube->primary_metric_id != metric_id) { - cell_data = heavy_keeper_get0_exdata(cube->topk, tag_in_string, tag_len); + cell_data = heavy_keeper_get0_exdata(cube->topk, key, key_len); if (cell_data == NULL) { - int tmp_ret = heavy_keeper_add(cube->topk, tag_in_string, tag_len, 0, (void *)&args); + int tmp_ret = heavy_keeper_add(cube->topk, key, key_len, 0, (void *)&args); if (tmp_ret == 1) { - cell_data = heavy_keeper_get0_exdata(cube->topk, tag_in_string, tag_len); + cell_data = heavy_keeper_get0_exdata(cube->topk, key, key_len); } } } else { // heavy_keeper_add should be called anyway, to let the topk record update. - int tmp_ret = heavy_keeper_add(cube->topk, tag_in_string, tag_len, increment, (void *)&args); + int tmp_ret = heavy_keeper_add(cube->topk, key, key_len, increment, (void *)&args); if (tmp_ret == 1) { - cell_data = heavy_keeper_get0_exdata(cube->topk, tag_in_string, tag_len); + cell_data = heavy_keeper_get0_exdata(cube->topk, key, key_len); } } break;} case SAMPLING_MODE_COMPREHENSIVE: { - cell_data = hash_table_get0_exdata(cube->comprehensive, tag_in_string, tag_len); + cell_data = hash_table_get0_exdata(cube->comprehensive, key, key_len); if (cell_data == NULL) { - int tmp_ret = hash_table_add(cube->comprehensive, tag_in_string, tag_len, (void *)&args); + int tmp_ret = hash_table_add(cube->comprehensive, key, key_len, (void *)&args); if (tmp_ret == 1) { - cell_data = hash_table_get0_exdata(cube->comprehensive, tag_in_string, tag_len); + cell_data = hash_table_get0_exdata(cube->comprehensive, key, key_len); } } break;} } - free(tag_in_string); + if (free_key) { + free(key); + } return cell_data; } -int cube_histogram_record(struct cube *cube, const struct metric_manifest *manifest, const struct fieldstat_tag *tags, size_t n_tag, long long value) { +int cube_histogram_record(struct cube *cube, const struct metric_manifest *manifest, const struct field *fields, size_t n_field, long long value) { assert(manifest->type == METRIC_TYPE_HISTOGRAM); assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->primary_metric_id != manifest->id)); - struct cell *cell_data = get_cell(cube, tags, n_tag, 0, manifest->id); + struct cell *cell_data = get_cell(cube, fields, n_field, 0, manifest->id); if (cell_data == NULL) { return FS_ERR_TOO_MANY_CELLS; } @@ -608,11 +682,11 @@ int cube_histogram_record(struct cube *cube, const struct metric_manifest *manif return FS_OK; } -int cube_hll_add(struct cube *cube, const struct metric_manifest *manifest, const struct fieldstat_tag *tags, size_t n_tag, const char *key, size_t key_len) { +int cube_hll_add(struct cube *cube, const struct metric_manifest *manifest, const struct field *fields, size_t n_field, const char *key, size_t key_len) { assert(manifest->type == METRIC_TYPE_HLL); assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->primary_metric_id != manifest->id)); - struct cell *cell_data = get_cell(cube, tags, n_tag, 0, manifest->id); + struct cell *cell_data = get_cell(cube, fields, n_field, 0, manifest->id); if (cell_data == NULL) { return FS_ERR_TOO_MANY_CELLS; } @@ -622,28 +696,28 @@ int cube_hll_add(struct cube *cube, const struct metric_manifest *manifest, cons return FS_OK; } -uint64_t tags2hash(const struct fieldstat_tag *tag, size_t n_tag) { +uint64_t tags2hash(const struct field *field, size_t n_field) { XXH3_state_t state = {0}; XXH3_64bits_reset(&state); - for (int i = 0; i < n_tag; i++) { - XXH3_64bits_update(&state, tag[i].key, strlen(tag[i].key)); - if (tag[i].type != TAG_CSTRING) { - XXH3_64bits_update(&state, &tag[i].value_longlong, sizeof(long long)); + for (int i = 0; i < n_field; i++) { + XXH3_64bits_update(&state, field[i].key, strlen(field[i].key)); + if (field[i].type != TAG_CSTRING) { + XXH3_64bits_update(&state, &field[i].value_longlong, sizeof(long long)); } else { - XXH3_64bits_update(&state, tag[i].value_str, strlen(tag[i].value_str)); + XXH3_64bits_update(&state, field[i].value_str, strlen(field[i].value_str)); } } return XXH3_64bits_digest(&state); } -int cube_hll_add_tag(struct cube *cube, const struct metric_manifest *manifest, const struct fieldstat_tag *tags, size_t n_tag, const struct fieldstat_tag *tags_key, size_t n_tag_key) +int cube_hll_add_tag(struct cube *cube, const struct metric_manifest *manifest, const struct field *fields, size_t n_field, const struct field *tags_key, size_t n_tag_key) { assert(manifest->type == METRIC_TYPE_HLL); assert(cube->sampling_mode != SAMPLING_MODE_TOPK || (cube->primary_metric_id != manifest->id)); - struct cell *cell_data = get_cell(cube, tags, n_tag, 0, manifest->id); + struct cell *cell_data = get_cell(cube, fields, n_field, 0, manifest->id); if (cell_data == NULL) { return FS_ERR_TOO_MANY_CELLS; } @@ -654,11 +728,11 @@ int cube_hll_add_tag(struct cube *cube, const struct metric_manifest *manifest, return FS_OK; } -int cube_counter_incrby(struct cube *cube, const struct metric_manifest *manifest, const struct fieldstat_tag *tags, size_t n_tag, long long increment) { +int cube_counter_incrby(struct cube *cube, const struct metric_manifest *manifest, const struct field *fields, size_t n_field, long long increment) { assert(manifest->type == METRIC_TYPE_COUNTER); assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->primary_metric_id != manifest->id || increment >= 0)); - struct cell *cell_data = get_cell(cube, tags, n_tag, increment, manifest->id); + struct cell *cell_data = get_cell(cube, fields, n_field, increment, manifest->id); if (cell_data == NULL) { return FS_ERR_TOO_MANY_CELLS; } @@ -669,11 +743,11 @@ int cube_counter_incrby(struct cube *cube, const struct metric_manifest *manifes return FS_OK; } -int cube_counter_set(struct cube *cube, const struct metric_manifest *manifest, const struct fieldstat_tag *tags, size_t n_tag, long long value) { +int cube_counter_set(struct cube *cube, const struct metric_manifest *manifest, const struct field *fields, size_t n_field, long long value) { assert(manifest->type == METRIC_TYPE_COUNTER); assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->primary_metric_id != manifest->id)); - struct cell *cell_data = get_cell(cube, tags, n_tag, 0, manifest->id); + struct cell *cell_data = get_cell(cube, fields, n_field, 0, manifest->id); if (cell_data == NULL) { return FS_ERR_TOO_MANY_CELLS; } @@ -729,7 +803,7 @@ struct cube *cube_fork(const struct cube *cube) { return ret; } -void cube_get_cells(const struct cube *cube, struct fieldstat_tag_list **tag_list, size_t *n_cell) +void cube_get_cells(const struct cube *cube, struct field_list **tag_list, size_t *n_cell) { size_t n_cell_tmp = 0; switch (cube->sampling_mode) { @@ -761,30 +835,30 @@ void cube_get_cells(const struct cube *cube, struct fieldstat_tag_list **tag_lis assert(0); } - struct fieldstat_tag_list *tag_list_ret = (struct fieldstat_tag_list *)malloc(sizeof(struct fieldstat_tag_list) * n_cell_tmp); + struct field_list *tag_list_ret = (struct field_list *)malloc(sizeof(struct field_list) * n_cell_tmp); *tag_list = tag_list_ret; *n_cell = n_cell_tmp; for (int i = 0; i < n_cell_tmp; i++) { struct cell *cell_data = cell_datas[i]; - struct fieldstat_tag_list *tag_list_tmp = &tag_list_ret[i]; - tag_list_tmp->n_tag = cell_data->tags.n_tag; - if (tag_list_tmp->n_tag == 0) { - tag_list_tmp->tag = NULL; + struct field_list *tag_list_tmp = &tag_list_ret[i]; + tag_list_tmp->n_field = cell_data->fields.n_field; + if (tag_list_tmp->n_field == 0) { + tag_list_tmp->field = NULL; continue; } - tag_list_tmp->tag = tag_array_duplicate(cell_data->tags.tag, tag_list_tmp->n_tag); + tag_list_tmp->field = tag_array_duplicate(cell_data->fields.field, tag_list_tmp->n_field); } free(cell_datas); } -const struct cell *get_cell_by_tag_list(const struct cube *cube, const struct fieldstat_tag_list *tags) +const struct cell *get_cell_by_tag_list(const struct cube *cube, const struct field_list *fields) { const struct cell *ret = NULL; char *tag_in_string; size_t tag_len; - tags2key(tags->tag, tags->n_tag, &tag_in_string, &tag_len); + tags2key_endeavor(fields->field, fields->n_field, &tag_in_string, &tag_len); switch (cube->sampling_mode) { @@ -803,9 +877,9 @@ const struct cell *get_cell_by_tag_list(const struct cube *cube, const struct fi return ret; } -const struct metric *get_metric_by_tag_list(const struct cube *cube, const struct fieldstat_tag_list *tags, int metric_id,int *ret) +const struct metric *get_metric_by_tag_list(const struct cube *cube, const struct field_list *fields, int metric_id,int *ret) { - const struct cell *data = get_cell_by_tag_list(cube, tags); + const struct cell *data = get_cell_by_tag_list(cube, fields); if (data == NULL) { *ret = FS_ERR_INVALID_TAG; @@ -821,10 +895,10 @@ const struct metric *get_metric_by_tag_list(const struct cube *cube, const struc return data->metrics[metric_id]; } -int cube_counter_get(const struct cube *cube, int metric_id, const struct fieldstat_tag_list *tags, long long *value) +int cube_counter_get(const struct cube *cube, int metric_id, const struct field_list *fields, long long *value) { int ret; - const struct metric *metric = get_metric_by_tag_list(cube, tags, metric_id, &ret); + const struct metric *metric = get_metric_by_tag_list(cube, fields, metric_id, &ret); if (ret != FS_OK) { return ret; } @@ -836,10 +910,10 @@ int cube_counter_get(const struct cube *cube, int metric_id, const struct fields return FS_OK; } -int cube_hll_get(const struct cube *cube, int metric_id, const struct fieldstat_tag_list *tags, double *value) +int cube_hll_get(const struct cube *cube, int metric_id, const struct field_list *fields, double *value) { int ret; - const struct metric *metric = get_metric_by_tag_list(cube, tags, metric_id, &ret); + const struct metric *metric = get_metric_by_tag_list(cube, fields, metric_id, &ret); if (ret != FS_OK) { return ret; } @@ -851,10 +925,10 @@ int cube_hll_get(const struct cube *cube, int metric_id, const struct fieldstat_ return FS_OK; } -int cube_histogram_value_at_percentile(const struct cube *cube, int metric_id, const struct fieldstat_tag_list *tags, double percentile, long long *value) +int cube_histogram_value_at_percentile(const struct cube *cube, int metric_id, const struct field_list *fields, double percentile, long long *value) { int ret; - const struct metric *metric = get_metric_by_tag_list(cube, tags, metric_id, &ret); + const struct metric *metric = get_metric_by_tag_list(cube, fields, metric_id, &ret); if (ret != FS_OK) { return ret; } @@ -866,9 +940,9 @@ int cube_histogram_value_at_percentile(const struct cube *cube, int metric_id, c return FS_OK; } -int cube_histogram_count_le_value(const struct cube *cube, int metric_id, const struct fieldstat_tag_list *tags, long long value, long long *count) { +int cube_histogram_count_le_value(const struct cube *cube, int metric_id, const struct field_list *fields, long long value, long long *count) { int ret; - const struct metric *metric = get_metric_by_tag_list(cube, tags, metric_id, &ret); + const struct metric *metric = get_metric_by_tag_list(cube, fields, metric_id, &ret); if (ret != FS_OK) { return ret; } @@ -880,9 +954,9 @@ int cube_histogram_count_le_value(const struct cube *cube, int metric_id, const return FS_OK; } -int cube_get_serialization(const struct cube *cube, int metric_id, const struct fieldstat_tag_list *tags, char **blob, size_t *blob_size) { +int cube_get_serialization(const struct cube *cube, int metric_id, const struct field_list *fields, char **blob, size_t *blob_size) { int ret; - const struct metric *metric = get_metric_by_tag_list(cube, tags, metric_id, &ret); + const struct metric *metric = get_metric_by_tag_list(cube, fields, metric_id, &ret); if (ret != FS_OK) { return ret; } @@ -905,8 +979,8 @@ int cube_get_cell_count(const struct cube *cube) { } } -void cube_get_cells_used_by_metric(const struct cube *cube, const struct fieldstat_tag_list *tags, int **metric_id_out, size_t *n_metric_out) { - const struct cell *cell_data = get_cell_by_tag_list(cube, tags); +void cube_get_cells_used_by_metric(const struct cube *cube, const struct field_list *fields, int **metric_id_out, size_t *n_metric_out) { + const struct cell *cell_data = get_cell_by_tag_list(cube, fields); if (cell_data == NULL) { *metric_id_out = NULL; *n_metric_out = 0; @@ -924,17 +998,17 @@ void cube_get_cells_used_by_metric(const struct cube *cube, const struct fieldst *n_metric_out = n_metric; } -struct fieldstat_tag_list *cube_get_identifier(const struct cube *cube) { - struct fieldstat_tag_list *tag_list = (struct fieldstat_tag_list *)malloc(sizeof(struct fieldstat_tag_list)); +struct field_list *cube_get_identifier(const struct cube *cube) { + struct field_list *tag_list = (struct field_list *)malloc(sizeof(struct field_list)); if (cube->n_shared_tags == 0) { - tag_list->tag = NULL; - tag_list->n_tag = 0; + tag_list->field = NULL; + tag_list->n_field = 0; return tag_list; } - tag_list->tag = tag_array_duplicate(cube->cube_identifier, cube->n_shared_tags); - tag_list->n_tag = cube->n_shared_tags; + tag_list->field = tag_array_duplicate(cube->cube_identifier, cube->n_shared_tags); + tag_list->n_field = cube->n_shared_tags; return tag_list; diff --git a/src/cube.h b/src/cube.h index 3a2d20b..1ac4b4d 100644 --- a/src/cube.h +++ b/src/cube.h @@ -7,43 +7,43 @@ extern "C" #include #include -#include "fieldstat.h" // for tags +#include "fieldstat.h" // for fields #include "metric_manifest.h" struct cube; struct cube_manager; -struct cube *cube_new(const struct fieldstat_tag *shared_tags, size_t n_tag, enum sampling_mode mode, size_t max_n_cell); +struct cube *cube_new(const struct field *shared_tags, size_t n_field, enum sampling_mode mode, size_t max_n_cell); void cube_free(struct cube *cube); void cube_reset(struct cube *cube); struct cube *cube_copy(const struct cube *cube); void cube_merge(struct cube *dest, const struct cube *src); struct cube *cube_fork(const struct cube *cube); // only copy the cube configurations, leave the cells empty -int cube_histogram_record(struct cube *cube, const struct metric_manifest *manifest, const struct fieldstat_tag *tags, size_t n_tag, long long value); -int cube_hll_add(struct cube *cube, const struct metric_manifest *manifest, const struct fieldstat_tag *tags, size_t n_tag, const char *key, size_t key_len); -int cube_hll_add_tag(struct cube *cube, const struct metric_manifest *manifest, const struct fieldstat_tag *tags, size_t n_tag, const struct fieldstat_tag *tags_key, size_t n_tag_key); -int cube_counter_incrby(struct cube *cube, const struct metric_manifest *manifest, const struct fieldstat_tag *tags, size_t n_tag, long long increment); -int cube_counter_set(struct cube *cube, const struct metric_manifest *manifest, const struct fieldstat_tag *tags, size_t n_tag, long long value); +int cube_histogram_record(struct cube *cube, const struct metric_manifest *manifest, const struct field *fields, size_t n_field, long long value); +int cube_hll_add(struct cube *cube, const struct metric_manifest *manifest, const struct field *fields, size_t n_field, const char *key, size_t key_len); +int cube_hll_add_tag(struct cube *cube, const struct metric_manifest *manifest, const struct field *fields, size_t n_field, const struct field *tags_key, size_t n_tag_key); +int cube_counter_incrby(struct cube *cube, const struct metric_manifest *manifest, const struct field *fields, size_t n_field, long long increment); +int cube_counter_set(struct cube *cube, const struct metric_manifest *manifest, const struct field *fields, size_t n_field, long long value); -int cube_counter_get(const struct cube *cube, int metric_id, const struct fieldstat_tag_list *tags, long long *value); -int cube_hll_get(const struct cube *cube, int metric_id, const struct fieldstat_tag_list *tags, double *value); -int cube_histogram_value_at_percentile(const struct cube *cube, int metric_id, const struct fieldstat_tag_list *tags, double percentile, long long *value); -int cube_histogram_count_le_value(const struct cube *cube, int metric_id, const struct fieldstat_tag_list *tags, long long value, long long *count); -int cube_get_serialization(const struct cube *cube, int metric_id, const struct fieldstat_tag_list *tags, char **blob, size_t *blob_size); +int cube_counter_get(const struct cube *cube, int metric_id, const struct field_list *fields, long long *value); +int cube_hll_get(const struct cube *cube, int metric_id, const struct field_list *fields, double *value); +int cube_histogram_value_at_percentile(const struct cube *cube, int metric_id, const struct field_list *fields, double percentile, long long *value); +int cube_histogram_count_le_value(const struct cube *cube, int metric_id, const struct field_list *fields, long long value, long long *count); +int cube_get_serialization(const struct cube *cube, int metric_id, const struct field_list *fields, char **blob, size_t *blob_size); int cube_get_cell_count(const struct cube *cube); -void cube_get_cells(const struct cube *cube, struct fieldstat_tag_list **tag_list, size_t *n_cell); -void cube_get_cells_used_by_metric(const struct cube *cube, const struct fieldstat_tag_list *tags, int **metric_id_out, size_t *n_metric_out); +void cube_get_cells(const struct cube *cube, struct field_list **tag_list, size_t *n_cell); +void cube_get_cells_used_by_metric(const struct cube *cube, const struct field_list *fields, int **metric_id_out, size_t *n_metric_out); void cube_set_primary_metric(struct cube *cube, int metric_id); -struct fieldstat_tag_list *cube_get_identifier(const struct cube *cube); +struct field_list *cube_get_identifier(const struct cube *cube); struct cube *cube_manager_get_cube_by_id(const struct cube_manager *manager, int cube_id); // the cube will be taken over by the manager, user do not free it. int cube_manager_add(struct cube_manager *pthis, struct cube *cube); void cube_manager_delete(struct cube_manager *pthis, struct cube *cube); // the cube will be freed by the manager -int cube_manager_find(const struct cube_manager *pthis, const struct fieldstat_tag *identifier, size_t n_tag); +int cube_manager_find(const struct cube_manager *pthis, const struct field *identifier, size_t n_field); struct cube_manager *cube_manager_new(); void cube_manager_free(struct cube_manager *pthis); void cube_manager_merge(struct cube_manager *dest, const struct cube_manager *src); diff --git a/src/exporter/cjson_exporter.c b/src/exporter/cjson_exporter.c index 643fb0f..9466f01 100644 --- a/src/exporter/cjson_exporter.c +++ b/src/exporter/cjson_exporter.c @@ -50,7 +50,7 @@ struct counter_history; struct export_kv_pair { char *key; - enum fs_tag_type type; + enum field_type type; union{ long long value_longlong; double value_double; @@ -60,7 +60,7 @@ struct export_kv_pair { struct fieldstat_json_exporter { char *name; - struct fieldstat_tag_list *global_tag_list; + struct field_list *global_tag_list; struct counter_history *history; long long last_ts; }; @@ -69,9 +69,9 @@ struct cell_iter { int *cube_ids; int n_cube; int curr_cube_idx; - struct fieldstat_tag_list *shared_tag; + struct field_list *shared_tag; - struct fieldstat_tag_list *tag_list; + struct field_list *tag_list; size_t n_cell; size_t curr_cell_idx; @@ -101,7 +101,7 @@ struct counter_history { long long ts; char *exporter_name; - struct fieldstat_tag_list *global_tag_list; + struct field_list *global_tag_list; }; struct couple_export_table_item { @@ -123,7 +123,7 @@ void kv_pair_free(struct export_kv_pair *pair) { free(pair); } -void kv_pair_fill_with_tags(struct export_kv_pair *dest, const struct fieldstat_tag *src) +void kv_pair_fill_with_tags(struct export_kv_pair *dest, const struct field *src) { dest->key = strdup(src->key); dest->type = src->type; @@ -214,33 +214,33 @@ void counter_history_free(struct counter_history *history) free(history); } -bool fieldstat_tag_list_cmp(const struct fieldstat_tag_list *a, const struct fieldstat_tag_list *b) +bool fieldstat_tag_list_cmp(const struct field_list *a, const struct field_list *b) { - if (a->n_tag != b->n_tag) { + if (a->n_field != b->n_field) { return false; } - for (int i = 0; i < a->n_tag; i++) { - if (strcmp(a->tag[i].key, b->tag[i].key) != 0) { + for (int i = 0; i < a->n_field; i++) { + if (strcmp(a->field[i].key, b->field[i].key) != 0) { return false; } - if (a->tag[i].type != b->tag[i].type) { + if (a->field[i].type != b->field[i].type) { return false; } - switch (a->tag[i].type) + switch (a->field[i].type) { case TAG_INTEGER: - if (a->tag[i].value_longlong != b->tag[i].value_longlong) { + if (a->field[i].value_longlong != b->field[i].value_longlong) { return false; } break; case TAG_DOUBLE: - if (a->tag[i].value_double != b->tag[i].value_double) { + if (a->field[i].value_double != b->field[i].value_double) { return false; } break; case TAG_CSTRING: - if (strcmp(a->tag[i].value_str, b->tag[i].value_str) != 0) { + if (strcmp(a->field[i].value_str, b->field[i].value_str) != 0) { return false; } break; @@ -252,24 +252,24 @@ bool fieldstat_tag_list_cmp(const struct fieldstat_tag_list *a, const struct fie return true; } -struct fieldstat_tag_list *my_copy_fs_tag_list(const struct fieldstat_tag_list *src) +struct field_list *my_copy_fs_tag_list(const struct field_list *src) { - struct fieldstat_tag_list *dest = malloc(sizeof(struct fieldstat_tag_list)); - dest->n_tag = src->n_tag; - dest->tag = malloc(sizeof(struct fieldstat_tag) * dest->n_tag); - for (int i = 0; i < dest->n_tag; i++) { - dest->tag[i].key = strdup(src->tag[i].key); - dest->tag[i].type = src->tag[i].type; - switch (src->tag[i].type) + struct field_list *dest = malloc(sizeof(struct field_list)); + dest->n_field = src->n_field; + dest->field = malloc(sizeof(struct field) * dest->n_field); + for (int i = 0; i < dest->n_field; i++) { + dest->field[i].key = strdup(src->field[i].key); + dest->field[i].type = src->field[i].type; + switch (src->field[i].type) { case TAG_INTEGER: - dest->tag[i].value_longlong = src->tag[i].value_longlong; + dest->field[i].value_longlong = src->field[i].value_longlong; break; case TAG_DOUBLE: - dest->tag[i].value_double = src->tag[i].value_double; + dest->field[i].value_double = src->field[i].value_double; break; case TAG_CSTRING: - dest->tag[i].value_str = strdup(src->tag[i].value_str); + dest->field[i].value_str = strdup(src->field[i].value_str); break; default: assert(0); @@ -290,7 +290,7 @@ bool counter_history_check_if_need_to_update(const struct fieldstat_json_exporte } const char *cur_exporter_name = exporter->name ? exporter->name : DEFAULT_EXPORTER_NAME; - const struct fieldstat_tag_list *cur_global_tag_list = exporter->global_tag_list; + const struct field_list *cur_global_tag_list = exporter->global_tag_list; if (strcmp(history->exporter_name, cur_exporter_name) != 0) { return true; @@ -302,7 +302,7 @@ bool counter_history_check_if_need_to_update(const struct fieldstat_json_exporte if (history->global_tag_list == NULL && cur_global_tag_list == NULL) { return false; } - // global tag cant be deleted, so no need to check if cur_global_tag_list == NULL && history->global_tag_list != NULL + // global field cant be deleted, so no need to check if cur_global_tag_list == NULL && history->global_tag_list != NULL if (fieldstat_tag_list_cmp(cur_global_tag_list, history->global_tag_list) == false) { return true; } @@ -313,7 +313,7 @@ bool counter_history_check_if_need_to_update(const struct fieldstat_json_exporte void counter_history_fill_version_info(struct counter_history *history, struct fieldstat_json_exporter *exporter, const struct fieldstat *instance) { const char *cur_exporter_name = exporter->name ? exporter->name : DEFAULT_EXPORTER_NAME; - const struct fieldstat_tag_list *cur_global_tag_list = exporter->global_tag_list; + const struct field_list *cur_global_tag_list = exporter->global_tag_list; free(history->exporter_name); history->exporter_name = strdup(cur_exporter_name); @@ -336,7 +336,7 @@ void fieldstat_json_exporter_update_history(struct fieldstat_json_exporter *expo void write_delta_to_json(struct fieldstat_json_exporter *exporter, struct cellwise_rec_for_export *tag_field_pair, struct json_writer *field_json) { - // for every tag_field_pair, get the tag json string + // for every tag_field_pair, get the field json string const char *tag_json = json_writer_unwrap(tag_field_pair->cjson_tags); if (tag_json == NULL) { tag_json = "\a\t\a"; // just a dummy string @@ -409,13 +409,13 @@ void couple_export_table_free(struct couple_export_table *tbl) #define NIL_TAG_JSON "\anil" -// align delta fields to acc fields by matching tag json string, return an array with length n_acc, each of whose element match the corresponding acc element by both tag and index +// align delta fields to acc fields by matching field json string, return an array with length n_acc, each of whose element match the corresponding acc element by both field and index const struct cellwise_rec_for_export **rearrange_metric_delta(const struct cellwise_rec_for_export *acc, size_t n_acc, const struct cellwise_rec_for_export *delta, size_t n_delta) { struct couple_export_table *map = couple_export_table_new(); for (int i = 0; i < n_delta; i++) { const char *tag_json = json_writer_unwrap(delta[i].cjson_tags); - if (tag_json == NULL) { // tag might be empty, give it a dummy name + if (tag_json == NULL) { // field might be empty, give it a dummy name tag_json = NIL_TAG_JSON; } couple_export_table_add(map, tag_json, i); @@ -425,7 +425,7 @@ const struct cellwise_rec_for_export **rearrange_metric_delta(const struct cellw for (int id_acc = 0; id_acc < n_acc; id_acc++) { const char *tag_str_acc = json_writer_unwrap(acc[id_acc].cjson_tags); - if (tag_str_acc == NULL) { // tag might be empty, give it a dummy name + if (tag_str_acc == NULL) { // field might be empty, give it a dummy name tag_str_acc = NIL_TAG_JSON; } @@ -573,28 +573,28 @@ void kv_pair_write_to_json(const struct export_kv_pair *pairs, struct json_write } } -void tag_list_append_to_tag_object(const struct fieldstat_tag_list *tag_list, struct json_writer *cjson_tags) +void tag_list_append_to_tag_object(const struct field_list *tag_list, struct json_writer *cjson_tags) { - size_t tag_list_len = tag_list->n_tag; + size_t tag_list_len = tag_list->n_field; struct export_kv_pair pairs = {0}; for (int i = 0; i < tag_list_len; i++) { - if (tag_list->n_tag == 0) { + if (tag_list->n_field == 0) { continue; } memset(&pairs, 0, sizeof(struct export_kv_pair)); - pairs.key = (char *)tag_list->tag[i].key; - pairs.type = tag_list->tag[i].type; + pairs.key = (char *)tag_list->field[i].key; + pairs.type = tag_list->field[i].type; switch (pairs.type) { case TAG_INTEGER: - pairs.value_longlong = tag_list->tag[i].value_longlong; + pairs.value_longlong = tag_list->field[i].value_longlong; break; case TAG_DOUBLE: - pairs.value_double = tag_list->tag[i].value_double; + pairs.value_double = tag_list->field[i].value_double; break; case TAG_CSTRING: - pairs.value_str = (char *)tag_list->tag[i].value_str; + pairs.value_str = (char *)tag_list->field[i].value_str; break; default: break; @@ -605,20 +605,20 @@ void tag_list_append_to_tag_object(const struct fieldstat_tag_list *tag_list, st void cell_iter_read_tag_list(const struct cell_iter *iter, struct export_kv_pair **exported_tags, size_t *len_out) { - struct fieldstat_tag_list *tag_list_cell = &iter->tag_list[iter->curr_cell_idx]; - struct fieldstat_tag_list *tag_arr_shared = iter->shared_tag; + struct field_list *tag_list_cell = &iter->tag_list[iter->curr_cell_idx]; + struct field_list *tag_arr_shared = iter->shared_tag; - size_t ret_tag_list_len = tag_list_cell->n_tag + tag_arr_shared->n_tag; + size_t ret_tag_list_len = tag_list_cell->n_field + tag_arr_shared->n_field; struct export_kv_pair *tag_list = malloc(sizeof(struct export_kv_pair) * ret_tag_list_len); *exported_tags = tag_list; *len_out = ret_tag_list_len; - for (int i = 0; i < tag_list_cell->n_tag; i++) { - kv_pair_fill_with_tags(tag_list++, &tag_list_cell->tag[i]); + for (int i = 0; i < tag_list_cell->n_field; i++) { + kv_pair_fill_with_tags(tag_list++, &tag_list_cell->field[i]); } - for (int i = 0; i < tag_arr_shared->n_tag; i++) { - kv_pair_fill_with_tags(tag_list++, &tag_arr_shared->tag[i]); + for (int i = 0; i < tag_arr_shared->n_field; i++) { + kv_pair_fill_with_tags(tag_list++, &tag_arr_shared->field[i]); } } @@ -955,7 +955,7 @@ char *fieldstat_json_exporter_export_with_delta(const struct fieldstat_json_expo free(expair_delta[i].metric_pairs); char *dummy_s; size_t dummy_len; - json_writer_finish(expair_delta[i].cjson_tags, &dummy_s, &dummy_len); // the tag json is not added to the root json, so we need to free it manually + json_writer_finish(expair_delta[i].cjson_tags, &dummy_s, &dummy_len); // the field json is not added to the root json, so we need to free it manually free(dummy_s); } free(expair_delta); @@ -975,30 +975,30 @@ struct fieldstat_json_exporter *fieldstat_json_exporter_new() return exporter; } -void fieldstat_json_exporter_set_global_tag(struct fieldstat_json_exporter *exporter, const struct fieldstat_tag tag_list[], size_t n_tag) +void fieldstat_json_exporter_set_global_tag(struct fieldstat_json_exporter *exporter, const struct field tag_list[], size_t n_field) { if (exporter->global_tag_list != NULL) { - free(exporter->global_tag_list->tag); + free(exporter->global_tag_list->field); free(exporter->global_tag_list); } - exporter->global_tag_list = malloc(sizeof(struct fieldstat_tag_list)); - exporter->global_tag_list->n_tag = n_tag; - exporter->global_tag_list->tag = malloc(sizeof(struct fieldstat_tag) * n_tag); - for (size_t i = 0; i < n_tag; i++) { - struct fieldstat_tag *tag = &exporter->global_tag_list->tag[i]; - tag->key = strdup(tag_list[i].key); - tag->type = tag_list[i].type; - switch (tag->type) + exporter->global_tag_list = malloc(sizeof(struct field_list)); + exporter->global_tag_list->n_field = n_field; + exporter->global_tag_list->field = malloc(sizeof(struct field) * n_field); + for (size_t i = 0; i < n_field; i++) { + struct field *field = &exporter->global_tag_list->field[i]; + field->key = strdup(tag_list[i].key); + field->type = tag_list[i].type; + switch (field->type) { case TAG_INTEGER: - tag->value_longlong = tag_list[i].value_longlong; + field->value_longlong = tag_list[i].value_longlong; break; case TAG_CSTRING: - tag->value_str = strdup(tag_list[i].value_str); + field->value_str = strdup(tag_list[i].value_str); break; case TAG_DOUBLE: - tag->value_double = tag_list[i].value_double; + field->value_double = tag_list[i].value_double; break; default: diff --git a/src/fieldstat.c b/src/fieldstat.c index cd43128..4e3a103 100644 --- a/src/fieldstat.c +++ b/src/fieldstat.c @@ -43,9 +43,9 @@ union metric_parameter *construct_parameters(enum metric_type type, ...) return paras; } -void tag_array_copy(struct fieldstat_tag *tags_dst, const struct fieldstat_tag *tags_src, size_t n_tag) +void tag_array_copy(struct field *tags_dst, const struct field *tags_src, size_t n_field) { - for (size_t i = 0; i < n_tag; i++) { + for (size_t i = 0; i < n_field; i++) { tags_dst[i].key = strdup(tags_src[i].key); tags_dst[i].type = tags_src[i].type; switch (tags_src[i].type) @@ -65,9 +65,9 @@ void tag_array_copy(struct fieldstat_tag *tags_dst, const struct fieldstat_tag * } } -bool is_tag_array_same(const struct fieldstat_tag *tags1, const struct fieldstat_tag *tags2, size_t n_tag) +bool is_tag_array_same(const struct field *tags1, const struct field *tags2, size_t n_field) { - for (size_t i = 0; i < n_tag; i++) { + for (size_t i = 0; i < n_field; i++) { if (tags1[i].type != tags2[i].type) { return false; } @@ -150,27 +150,27 @@ int fieldstat_destroy_cube(struct fieldstat *instance, int cube_id) /* cube */ /* -------------------------------------------------------------------------- */ -void fieldstat_free_tag_array(struct fieldstat_tag *tags, size_t n_tags) +void fieldstat_free_tag_array(struct field *fields, size_t n_tags) { for (size_t i = 0; i < n_tags; i++) { - struct fieldstat_tag *tag = &tags[i]; - free((char *)tag->key); - if (tag->type == TAG_CSTRING) { - free((char *)tag->value_str); + struct field *field = &fields[i]; + free((char *)field->key); + if (field->type == TAG_CSTRING) { + free((char *)field->value_str); } } - free(tags); + free(fields); } -int fieldstat_create_cube(struct fieldstat *instance, const struct fieldstat_tag *cube_identifier, size_t n_tag, enum sampling_mode mode, size_t max_n_cell) +int fieldstat_create_cube(struct fieldstat *instance, const struct field *cube_identifier, size_t cube_identifier_len, enum sampling_mode mode, size_t max_n_cell) { if (instance == NULL) { return FS_ERR_NULL_HANDLER; } - if (n_tag == 0 || cube_identifier == NULL) { + if (cube_identifier_len == 0 || cube_identifier == NULL) { cube_identifier = NULL; - n_tag = 0; + cube_identifier_len = 0; } if (mode == SAMPLING_MODE_TOPK && max_n_cell == 0) { return FS_ERR_INVALID_PARAM; @@ -179,7 +179,7 @@ int fieldstat_create_cube(struct fieldstat *instance, const struct fieldstat_tag max_n_cell = INT32_MAX; } - struct cube *cube = cube_new(cube_identifier, n_tag, mode, max_n_cell); + struct cube *cube = cube_new(cube_identifier, cube_identifier_len, mode, max_n_cell); int ret = cube_manager_add(instance->cube_manager, cube); if (ret < 0) { cube_free(cube); @@ -295,7 +295,7 @@ int fieldstat_register_hist(struct fieldstat *instance, const char *metric_name, /* -------------------------------------------------------------------------- */ // cppcheck-suppress [constParameterPointer, unmatchedSuppression] -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) +int fieldstat_counter_incrby(struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, size_t n_fields, long long increment) { struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -306,11 +306,11 @@ int fieldstat_counter_incrby(struct fieldstat *instance, int cube_id, int metric return FS_ERR_INVALID_METRIC_ID; } - return cube_counter_incrby(cube, manifest, tags, n_tag, increment); + return cube_counter_incrby(cube, manifest, fields, n_fields, increment); } // cppcheck-suppress [constParameterPointer, unmatchedSuppression] -int fieldstat_counter_set(struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long value) +int fieldstat_counter_set(struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, size_t n_fields, long long value) { struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -321,11 +321,11 @@ int fieldstat_counter_set(struct fieldstat *instance, int cube_id, int metric_id return FS_ERR_INVALID_METRIC_ID; } - return cube_counter_set(cube, manifest, tags, n_tag, value); + return cube_counter_set(cube, manifest, fields, n_fields, value); } // cppcheck-suppress [constParameterPointer, unmatchedSuppression] -int fieldstat_hll_add(struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, const char *key, size_t key_len) +int fieldstat_hll_add(struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, size_t n_fields, const char *key, size_t key_len) { struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -336,11 +336,11 @@ int fieldstat_hll_add(struct fieldstat *instance, int cube_id, int metric_id, co return FS_ERR_INVALID_METRIC_ID; } - return cube_hll_add(cube, manifest, tags, n_tag, key, key_len); + return cube_hll_add(cube, manifest, fields, n_fields, key, key_len); } // cppcheck-suppress [constParameterPointer, unmatchedSuppression] -int fieldstat_hll_add_tag(struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, const struct fieldstat_tag *tags_key, size_t n_tag_key) +int fieldstat_hll_add_field(struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, size_t n_fields, const struct field *item, size_t item_len) { struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -351,11 +351,11 @@ int fieldstat_hll_add_tag(struct fieldstat *instance, int cube_id, int metric_id return FS_ERR_INVALID_METRIC_ID; } - return cube_hll_add_tag(cube, manifest, tags, n_tag, tags_key, n_tag_key); + return cube_hll_add_tag(cube, manifest, fields, n_fields, item, item_len); } // cppcheck-suppress [constParameterPointer, unmatchedSuppression] -int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long value) +int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, size_t n_fields, long long value) { struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -366,7 +366,7 @@ int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id return FS_ERR_INVALID_METRIC_ID; } - return cube_histogram_record(cube, manifest, tags, n_tag, value); + return cube_histogram_record(cube, manifest, fields, n_fields, value); } int fieldstat_merge(struct fieldstat *instance, const struct fieldstat *src) @@ -444,7 +444,7 @@ void fieldstat_get_metrics(const struct fieldstat *instance, int **metric_id_out } } -struct fieldstat_tag_list *fieldstat_cube_get_tags(const struct fieldstat *instance, int cube_id) +struct field_list *fieldstat_cube_get_tags(const struct fieldstat *instance, int cube_id) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -454,36 +454,36 @@ struct fieldstat_tag_list *fieldstat_cube_get_tags(const struct fieldstat *insta return cube_get_identifier(cube); } -int fieldstat_counter_get(const struct fieldstat *instance, int cube_id, const struct fieldstat_tag_list *tags, int metric_id, long long *value) +int fieldstat_counter_get(const struct fieldstat *instance, int cube_id, const struct field_list *fields, int metric_id, long long *value) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { return FS_ERR_INVALID_CUBE_ID; } - return cube_counter_get(cube, metric_id, tags, value); + return cube_counter_get(cube, metric_id, fields, value); } -int fieldstat_hll_get(const struct fieldstat *instance, int cube_id, const struct fieldstat_tag_list *tags, int metric_id, double *value) +int fieldstat_hll_get(const struct fieldstat *instance, int cube_id, const struct field_list *fields, int metric_id, double *value) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { return FS_ERR_INVALID_CUBE_ID; } - int ret = cube_hll_get(cube, metric_id, tags, value); + int ret = cube_hll_get(cube, metric_id, fields, value); return ret; } -long long fieldstat_hist_value_at_percentile(const struct fieldstat *instance, int cube_id, const struct fieldstat_tag_list *tags, int metric_id, double percentile) +long long fieldstat_hist_value_at_percentile(const struct fieldstat *instance, int cube_id, const struct field_list *fields, int metric_id, double percentile) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { return FS_ERR_INVALID_CUBE_ID; } long long value; - int ret = cube_histogram_value_at_percentile(cube, metric_id, tags, percentile, &value); + int ret = cube_histogram_value_at_percentile(cube, metric_id, fields, percentile, &value); if (ret < 0) { return ret; } @@ -491,21 +491,21 @@ long long fieldstat_hist_value_at_percentile(const struct fieldstat *instance, i return value; } -long long fieldstat_hist_count_le_value(const struct fieldstat *instance, int cube_id, const struct fieldstat_tag_list *tags, int metric_id, long long value) +long long fieldstat_hist_count_le_value(const struct fieldstat *instance, int cube_id, const struct field_list *fields, int metric_id, long long value) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { return FS_ERR_INVALID_CUBE_ID; } long long count; - int ret = cube_histogram_count_le_value(cube, metric_id, tags, value, &count); + int ret = cube_histogram_count_le_value(cube, metric_id, fields, value, &count); if (ret < 0) { return ret; } return count; } -void fieldstat_get_serialized_blob(const struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag_list *tags, char **blob, size_t *blob_size) +void fieldstat_get_serialized_blob(const struct fieldstat *instance, int cube_id, int metric_id, const struct field_list *fields, char **blob, size_t *blob_size) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -514,16 +514,16 @@ void fieldstat_get_serialized_blob(const struct fieldstat *instance, int cube_id return; } - cube_get_serialization(cube, metric_id, tags, blob, blob_size); + cube_get_serialization(cube, metric_id, fields, blob, blob_size); } -void fieldstat_tag_list_arr_free(struct fieldstat_tag_list *tag_list, size_t n_cell) +void fieldstat_tag_list_arr_free(struct field_list *tag_list, size_t n_cell) { if (tag_list == NULL) { return; } for (int i = 0; i < n_cell; i++) { - fieldstat_free_tag_array(tag_list[i].tag, tag_list[i].n_tag); + fieldstat_free_tag_array(tag_list[i].field, tag_list[i].n_field); } free(tag_list); } @@ -548,7 +548,7 @@ enum metric_type fieldstat_get_metric_type(const struct fieldstat *instance, int return metric->type; } -void fieldstat_cube_get_cells(const struct fieldstat *instance, int cube_id, struct fieldstat_tag_list **tag_list, size_t *n_cell) +void fieldstat_cube_get_cells(const struct fieldstat *instance, int cube_id, struct field_list **tag_list, size_t *n_cell) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -572,7 +572,7 @@ int fieldstat_get_used_sampling(const struct fieldstat *instance, int cube_id) return cube_get_cell_count(cube); } -int fieldstat_find_cube(const struct fieldstat *instance, const struct fieldstat_tag *shared_tags, size_t n_shared_tags) +int fieldstat_find_cube(const struct fieldstat *instance, const struct field *shared_tags, size_t n_shared_tags) { if (instance == NULL) { return FS_ERR_NULL_HANDLER; @@ -586,8 +586,8 @@ int fieldstat_find_cube(const struct fieldstat *instance, const struct fieldstat return cube_id; } -void fieldstat_get_metric_in_cell(const struct fieldstat *instance, int cube_id, const struct fieldstat_tag_list *tags, int **metric_id_out, size_t *n_metric_out) +void fieldstat_get_metric_in_cell(const struct fieldstat *instance, int cube_id, const struct field_list *fields, int **metric_id_out, size_t *n_metric_out) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); - return cube_get_cells_used_by_metric(cube, tags, metric_id_out, n_metric_out); + return cube_get_cells_used_by_metric(cube, fields, metric_id_out, n_metric_out); } \ No newline at end of file diff --git a/src/fieldstat_easy.c b/src/fieldstat_easy.c index 8b73b40..0e70a1c 100644 --- a/src/fieldstat_easy.c +++ b/src/fieldstat_easy.c @@ -114,7 +114,7 @@ void *fs_easy_output_thread(void *arg) // return void * for pthread_create check return NULL; // return void * for pthread_create check only } -struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const char *name, const struct fieldstat_tag *tags, size_t n_tag) { +struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const char *name, const struct field *fields, size_t n_field) { if (max_thread_num <= 0) { return NULL; } @@ -126,8 +126,8 @@ struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const char *name, fse->accumulate = fieldstat_fork(fse->delta); fse->exporter = fieldstat_json_exporter_new(); - if (tags != NULL && n_tag > 0) { - fieldstat_json_exporter_set_global_tag(fse->exporter, tags, n_tag); + if (fields != NULL && n_field > 0) { + fieldstat_json_exporter_set_global_tag(fse->exporter, fields, n_field); } if (name != NULL) { fieldstat_json_exporter_set_name(fse->exporter, name); @@ -312,7 +312,7 @@ int fieldstat_easy_output_array_and_reset(struct fieldstat_easy *fse, char ***js return 0; } -int fieldstat_easy_counter_incrby(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long increment) +int fieldstat_easy_counter_incrby(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct field *fields, size_t n_field, long long increment) { if (thread_id < 0) { return -1; @@ -322,13 +322,13 @@ int fieldstat_easy_counter_incrby(struct fieldstat_easy *fse, int thread_id, int } pthread_spin_lock(&fse->fsu[thread_id].lock); - int ret = fieldstat_counter_incrby(fse->fsu[thread_id].active, 0, metric_id, tags, n_tag, increment); + int ret = fieldstat_counter_incrby(fse->fsu[thread_id].active, 0, metric_id, fields, n_field, increment); pthread_spin_unlock(&fse->fsu[thread_id].lock); return ret; } -int fieldstat_easy_counter_set(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long value) +int fieldstat_easy_counter_set(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct field *fields, size_t n_field, long long value) { if (thread_id < 0) { return -1; @@ -338,13 +338,13 @@ int fieldstat_easy_counter_set(struct fieldstat_easy *fse, int thread_id, int me } pthread_spin_lock(&fse->fsu[thread_id].lock); - int ret = fieldstat_counter_set(fse->fsu[thread_id].active, 0, metric_id, tags, n_tag, value); + int ret = fieldstat_counter_set(fse->fsu[thread_id].active, 0, metric_id, fields, n_field, value); pthread_spin_unlock(&fse->fsu[thread_id].lock); return ret; } -int fieldstat_easy_histogram_record(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct fieldstat_tag *tags, size_t n_tag, long long value) +int fieldstat_easy_histogram_record(struct fieldstat_easy *fse, int thread_id, int metric_id, const struct field *fields, size_t n_field, long long value) { if (thread_id < 0) { return -1; @@ -354,7 +354,7 @@ int fieldstat_easy_histogram_record(struct fieldstat_easy *fse, int thread_id, i } pthread_spin_lock(&fse->fsu[thread_id].lock); - int ret = fieldstat_hist_record(fse->fsu[thread_id].active, 0, metric_id, tags, n_tag, value); + int ret = fieldstat_hist_record(fse->fsu[thread_id].active, 0, metric_id, fields, n_field, value); pthread_spin_unlock(&fse->fsu[thread_id].lock); return ret; diff --git a/src/tags/heavy_keeper.c b/src/tags/heavy_keeper.c index a7c77c7..5f2b197 100644 --- a/src/tags/heavy_keeper.c +++ b/src/tags/heavy_keeper.c @@ -597,7 +597,7 @@ int heavy_keeper_add(struct heavy_keeper *heavy_keeper, const char *key, size_t // If a key is not in the min-heap, then the estimated key size should be no larger than nmin. // or if the min-heap is not full(nmin == 0), every key should be taken into account, so of course it should be added. // in neither case, bucket->count > nMin && not_in_sorted_set happen. - // The keys whose counts are both larger than nmin and not in min-heap must have the same xxhash value, and its FP stored in bucket represents another tag, + // The keys whose counts are both larger than nmin and not in min-heap must have the same xxhash value, and its FP stored in bucket represents another field, // In this case, the sketch won't be updated. This key is expected to be taken into account in another array, // where its FP is different from the one it should collided with, so that element keys won't be missed. if (not_in_sorted_set) { @@ -638,7 +638,7 @@ int heavy_keeper_add(struct heavy_keeper *heavy_keeper, const char *key, size_t if (maxv > old_cnt) { sorted_set_incrby_count(summary, key, key_len, maxv - old_cnt); } - return 1; // no popped, but the tag definitely exists in the sorted set + return 1; // no popped, but the exdata definitely exists in the sorted set } } @@ -759,7 +759,7 @@ void heavy_keeper_merge(struct heavy_keeper *dest, const struct heavy_keeper *sr for (int i = 0; i < size_src; i++) { const heap_entry *entry = sorted_set_find_entry(new_rec, key_arr[i], key_lens[i]); - if (entry != NULL) { // the tag is in both dest and src, so has been processed in the previous loop. The reason why no need to sum up result is that merged sketch already keeps its summed up count + if (entry != NULL) { // the key is in both dest and src, so has been processed in the previous loop. The reason why no need to sum up result is that merged sketch already keeps its summed up count void *exdata_new = sorted_set_entry_get_data(entry)->exdata; void *exdata_src = exdatas_src[i]; dest->merge_fn(exdata_new, exdata_src); diff --git a/test/profiling/main.c b/test/profiling/main.c index 3e498af..5838f20 100644 --- a/test/profiling/main.c +++ b/test/profiling/main.c @@ -4,26 +4,26 @@ #include #include "fieldstat.h" -#include "tags/my_ut_hash.h" -#include "tags/my_ut_hash_inner.h" +#include "fields/my_ut_hash.h" +#include "fields/my_ut_hash_inner.h" #define ADD_OPER_NUM 5000000ULL // #define ADD_OPER_NUM 1 #define MAX_STRING_KEY_LEN 10 -const struct fieldstat_tag TEST_TAG_INT = {"INT key_", TAG_INTEGER, {.value_longlong = 100}}; +const struct field TEST_TAG_INT = {"INT key_", TAG_INTEGER, {.value_longlong = 100}}; int main () { printf("Start profiling...\n"); clock_t start, end; - // struct fieldstat_tag TAG[4] = { + // struct field TAG[4] = { // {"INT key_", TAG_INTEGER, {.value_longlong = 100}}, // {"STRING key_", TAG_CSTRING, {.value_str = "10012312312312"}}, // {"STRING key_", TAG_CSTRING, {.value_str = "100adsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"}}, // {"FLOAT key_", TAG_INTEGER, {.value_double = 100.0}}, // }; - struct fieldstat_tag TAG[4] = { + struct field TAG[4] = { {"object_id", TAG_INTEGER, {.value_longlong = 20}}, {"item_id", TAG_INTEGER, {.value_longlong = 16916397}}, {"chart_id", TAG_INTEGER, {.value_longlong = 1}}, diff --git a/test/test_easy_fs.cpp b/test/test_easy_fs.cpp index d3f45b7..9512aa0 100644 --- a/test/test_easy_fs.cpp +++ b/test/test_easy_fs.cpp @@ -28,12 +28,12 @@ TEST(test_easy_fieldstat, output_to_buff) fieldstat_easy_output(fse, &buff, &buff_len); cJSON *root = cJSON_Parse(buff); cJSON *cell = cJSON_GetArrayItem(root, 0); - cJSON *metric = cJSON_GetObjectItem(cell, "fields"); + cJSON *metric = cJSON_GetObjectItem(cell, "tags"); long long value = cJSON_GetObjectItem(metric, "metric counter")->valueint; EXPECT_EQ(value, 1); - cJSON *tags = cJSON_GetObjectItem(cell, "tags"); - EXPECT_EQ(cJSON_GetObjectItem(tags, TEST_TAG_INT.key)->valueint, TEST_TAG_INT.value_longlong); - EXPECT_STREQ(cJSON_GetObjectItem(tags, TEST_TAG_STRING.key)->valuestring, TEST_TAG_STRING.value_str); + cJSON *fields = cJSON_GetObjectItem(cell, "tags"); + EXPECT_EQ(cJSON_GetObjectItem(fields, TEST_TAG_INT.key)->valueint, TEST_TAG_INT.value_longlong); + EXPECT_STREQ(cJSON_GetObjectItem(fields, TEST_TAG_STRING.key)->valuestring, TEST_TAG_STRING.value_str); cJSON_Delete(root); free(buff); @@ -55,7 +55,7 @@ TEST(test_easy_fieldstat, output_to_buff_with_delta) cJSON *root = cJSON_Parse(buff); cJSON *cell = cJSON_GetArrayItem(root, 0); - cJSON *metric = cJSON_GetObjectItem(cell, "fields"); + cJSON *metric = cJSON_GetObjectItem(cell, "tags"); long long value = cJSON_GetObjectItem(metric, "metric counter")->valueint; EXPECT_EQ(value, 2); cJSON *metric_delta = cJSON_GetObjectItem(cell, "fields_delta"); @@ -104,7 +104,7 @@ TEST(test_easy_fieldstat, output_to_file) EXPECT_EQ(cJSON_GetArraySize(root), 1); cJSON *tagged_by_int = cJSON_GetArrayItem(root, 0); - cJSON *metric = cJSON_GetObjectItem(tagged_by_int, "fields"); + cJSON *metric = cJSON_GetObjectItem(tagged_by_int, "tags"); EXPECT_TRUE(metric != NULL); long long value = cJSON_GetObjectItem(metric, "metric counter")->valueint; @@ -117,7 +117,7 @@ TEST(test_easy_fieldstat, output_to_file) root = read_file(); EXPECT_EQ(cJSON_GetArraySize(root), 1); tagged_by_int = cJSON_GetArrayItem(root, 0); - metric = cJSON_GetObjectItem(tagged_by_int, "fields"); + metric = cJSON_GetObjectItem(tagged_by_int, "tags"); value = cJSON_GetObjectItem(metric, "metric counter")->valueint; EXPECT_EQ(value, 111); // should not change cJSON_Delete(root); @@ -128,7 +128,7 @@ TEST(test_easy_fieldstat, output_to_file) printf("4th interval\n"); root = read_file(); cJSON *tagged_by_double = cJSON_GetArrayItem(root, 1); - metric = cJSON_GetObjectItem(tagged_by_double, "fields"); + metric = cJSON_GetObjectItem(tagged_by_double, "tags"); value = cJSON_GetObjectItem(metric, "metric counter")->valueint; EXPECT_EQ(value, 10086); cJSON_Delete(root); @@ -150,7 +150,7 @@ TEST(test_easy_fieldstat, empty_tag) EXPECT_EQ(cJSON_GetArraySize(root), 1); cJSON *tagged_by_int = cJSON_GetArrayItem(root, 0); - cJSON *metric = cJSON_GetObjectItem(tagged_by_int, "fields"); + cJSON *metric = cJSON_GetObjectItem(tagged_by_int, "tags"); EXPECT_TRUE(metric != NULL); cJSON *metric_delta = cJSON_GetObjectItem(tagged_by_int, "fields_delta"); EXPECT_TRUE(metric_delta != NULL); @@ -197,8 +197,8 @@ TEST(test_easy_fieldstat, output_interval_ok) TEST(test_easy_fieldstat, ensure_data_racing_of_two_output_and_of_incyby) { const int N_THREADS = 3; - struct fieldstat_tag global_tags[1]; - struct fieldstat_tag tmptag; + struct field global_tags[1]; + struct field tmptag; tmptag.key = "app id"; tmptag.type = TAG_INTEGER; tmptag.value_longlong = 1; @@ -250,7 +250,7 @@ TEST(test_easy_fieldstat, reset) long long get_value(const char *input, const char *key) { cJSON *root = cJSON_Parse(input); - cJSON *metric = cJSON_GetObjectItem(root, "fields"); + cJSON *metric = cJSON_GetObjectItem(root, "tags"); long long value = cJSON_GetObjectItem(metric, key)->valueint; cJSON_Delete(root); return value; diff --git a/test/test_empty_tags.cpp b/test/test_empty_tags.cpp index 7e17489..5c39f26 100644 --- a/test/test_empty_tags.cpp +++ b/test/test_empty_tags.cpp @@ -8,12 +8,12 @@ void assert_cell_null(const struct fieldstat *instance, int cube_id, long long expected_count) { - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance, cube_id, &tag_list, &n_cell); EXPECT_EQ(n_cell, 1); - EXPECT_EQ(tag_list[0].n_tag, 0); - EXPECT_TRUE(tag_list[0].tag == NULL); + EXPECT_EQ(tag_list[0].n_field, 0); + EXPECT_TRUE(tag_list[0].field == NULL); long long value; fieldstat_counter_get(instance, cube_id, &tag_list[0], 0, &value); EXPECT_EQ(value, expected_count); @@ -57,9 +57,9 @@ TEST(test_empty_tag, merge) int n_cube = 0; fieldstat_get_cubes(instance_dst, &ret_cube_id_arr, &n_cube); int ret_cell_id = ret_cube_id_arr[0]; - struct fieldstat_tag_list *shared_tag = fieldstat_cube_get_tags(instance_dst, ret_cell_id); - EXPECT_EQ(shared_tag->n_tag, 0); - EXPECT_TRUE(shared_tag->tag == NULL); + struct field_list *shared_tag = fieldstat_cube_get_tags(instance_dst, ret_cell_id); + EXPECT_EQ(shared_tag->n_field, 0); + EXPECT_TRUE(shared_tag->field == NULL); fieldstat_tag_list_arr_free(shared_tag, 1); free(ret_cube_id_arr); @@ -81,9 +81,9 @@ TEST(test_empty_tag, merge_topk) int n_cube = 0; fieldstat_get_cubes(instance_dst, &ret_cube_id_arr, &n_cube); int ret_cell_id = ret_cube_id_arr[0]; - struct fieldstat_tag_list *shared_tag = fieldstat_cube_get_tags(instance_dst, ret_cell_id); - EXPECT_EQ(shared_tag->n_tag, 0); - EXPECT_TRUE(shared_tag->tag == NULL); + struct field_list *shared_tag = fieldstat_cube_get_tags(instance_dst, ret_cell_id); + EXPECT_EQ(shared_tag->n_field, 0); + EXPECT_TRUE(shared_tag->field == NULL); fieldstat_tag_list_arr_free(shared_tag, 1); free(ret_cube_id_arr); @@ -107,11 +107,11 @@ TEST(test_empty_tag, export) fieldstat_free(instance); cJSON *root = cJSON_GetArrayItem(root_arr, 0); - // check tag - cJSON *tag = cJSON_GetObjectItem(root, "tags"); - EXPECT_EQ(cJSON_GetArraySize(tag), 0); + // check field + cJSON *field = cJSON_GetObjectItem(root, "tags"); + EXPECT_EQ(cJSON_GetArraySize(field), 0); - cJSON *metrics = cJSON_GetObjectItem(root, "fields"); + cJSON *metrics = cJSON_GetObjectItem(root, "tags"); EXPECT_NE(metrics, nullptr); cJSON *counter = cJSON_GetObjectItem(metrics, "metric"); EXPECT_EQ(counter->valueint, 1); diff --git a/test/test_exporter_json.cpp b/test/test_exporter_json.cpp index aac8ac7..259091b 100644 --- a/test/test_exporter_json.cpp +++ b/test/test_exporter_json.cpp @@ -23,23 +23,23 @@ struct hdr_histogram *g_histogram_standard; #define TEST_TOPK_STANDARD_K 5 #define TEST_METRIC_NUM 2 -const struct fieldstat_tag TEST_TAG_GLOBAL1 = {"test_tag_global 1", .type = TAG_INTEGER, {.value_longlong = 1}}; -const struct fieldstat_tag TEST_TAG_GLOBAL2 = {"test_tag_global 2", .type = TAG_DOUBLE, {.value_double = 2.2}}; -const struct fieldstat_tag TEST_TAG_GLOBAL3 = {"test_tag_global 3", .type = TAG_CSTRING, {.value_str = "string3"}}; -const struct fieldstat_tag TEST_TAG_GLOBAL[3] = {TEST_TAG_GLOBAL1, TEST_TAG_GLOBAL2, TEST_TAG_GLOBAL3}; +const struct field TEST_TAG_GLOBAL1 = {"test_tag_global 1", .type = TAG_INTEGER, {.value_longlong = 1}}; +const struct field TEST_TAG_GLOBAL2 = {"test_tag_global 2", .type = TAG_DOUBLE, {.value_double = 2.2}}; +const struct field TEST_TAG_GLOBAL3 = {"test_tag_global 3", .type = TAG_CSTRING, {.value_str = "string3"}}; +const struct field TEST_TAG_GLOBAL[3] = {TEST_TAG_GLOBAL1, TEST_TAG_GLOBAL2, TEST_TAG_GLOBAL3}; -const struct fieldstat_tag TEST_TAG_SHARED1_1 = {"test_tag_shared 1", .type = TAG_INTEGER, {.value_longlong = 3}}; -const struct fieldstat_tag TEST_TAG_SHARED1_2 = {"test_tag_shared 2", .type = TAG_DOUBLE, {.value_double = 0.2}}; -const struct fieldstat_tag TEST_TAG_SHARED1_3 = {"test_tag_shared 3", .type = TAG_CSTRING, {.value_str = "1string"}}; -const struct fieldstat_tag TEST_TAG_SHARED1[3] = {TEST_TAG_SHARED1_1, TEST_TAG_SHARED1_2, TEST_TAG_SHARED1_3}; +const struct field TEST_TAG_SHARED1_1 = {"test_tag_shared 1", .type = TAG_INTEGER, {.value_longlong = 3}}; +const struct field TEST_TAG_SHARED1_2 = {"test_tag_shared 2", .type = TAG_DOUBLE, {.value_double = 0.2}}; +const struct field TEST_TAG_SHARED1_3 = {"test_tag_shared 3", .type = TAG_CSTRING, {.value_str = "1string"}}; +const struct field TEST_TAG_SHARED1[3] = {TEST_TAG_SHARED1_1, TEST_TAG_SHARED1_2, TEST_TAG_SHARED1_3}; -const struct fieldstat_tag TEST_TAG_SHARED2_1 = {"test_tag_shared 11", .type = TAG_INTEGER, {.value_longlong = 4}}; -const struct fieldstat_tag TEST_TAG_SHARED2_2 = {"test_tag_shared 22", .type = TAG_DOUBLE, {.value_double = 0.3}}; -const struct fieldstat_tag TEST_TAG_SHARED2_3 = {"test_tag_shared 33", .type = TAG_CSTRING, {.value_str = "2string"}}; -const struct fieldstat_tag TEST_TAG_SHARED2[3] = {TEST_TAG_SHARED2_1, TEST_TAG_SHARED2_2, TEST_TAG_SHARED2_3}; +const struct field TEST_TAG_SHARED2_1 = {"test_tag_shared 11", .type = TAG_INTEGER, {.value_longlong = 4}}; +const struct field TEST_TAG_SHARED2_2 = {"test_tag_shared 22", .type = TAG_DOUBLE, {.value_double = 0.3}}; +const struct field TEST_TAG_SHARED2_3 = {"test_tag_shared 33", .type = TAG_CSTRING, {.value_str = "2string"}}; +const struct field TEST_TAG_SHARED2[3] = {TEST_TAG_SHARED2_1, TEST_TAG_SHARED2_2, TEST_TAG_SHARED2_3}; -const struct fieldstat_tag TEST_TAG_SHARED3_1 = {"test_tag_shared 3", .type = TAG_INTEGER, {.value_longlong = 5}}; -const struct fieldstat_tag TEST_TAG_SHARED3[1] = {TEST_TAG_SHARED3_1}; +const struct field TEST_TAG_SHARED3_1 = {"test_tag_shared 3", .type = TAG_INTEGER, {.value_longlong = 5}}; +const struct field TEST_TAG_SHARED3[1] = {TEST_TAG_SHARED3_1}; void test_check_if_tag_list_is_in_json(cJSON *tag_obj, const Fieldstat_tag_list_wrapper *benchmark) { @@ -60,7 +60,7 @@ void test_check_if_tag_list_is_in_json(cJSON *tag_obj, const Fieldstat_tag_list_ void test_check_if_global_tag_is_in_json(cJSON *tag_obj) { - struct fieldstat_tag_list tag_list = {.tag = (struct fieldstat_tag *)TEST_TAG_GLOBAL, .n_tag = 3}; + struct field_list tag_list = {.field = (struct field *)TEST_TAG_GLOBAL, .n_field = 3}; const Fieldstat_tag_list_wrapper benchmark(&tag_list); test_check_if_tag_list_is_in_json(tag_obj, &benchmark); } @@ -105,7 +105,7 @@ void test_check_if_metric_topk_correct(cJSON *metric_obj, const char **name, uns } } -void fill_random_tag(Fieldstat_tag_list_wrapper *tags[], int tag_list_num) +void fill_random_tag(Fieldstat_tag_list_wrapper *fields[], int tag_list_num) { std::uniform_int_distribution dist(1,100); std::mt19937 rng(); @@ -113,7 +113,7 @@ void fill_random_tag(Fieldstat_tag_list_wrapper *tags[], int tag_list_num) for (int i = 0; i < tag_list_num; i++) { Fieldstat_tag_list_wrapper *tmp = new Fieldstat_tag_list_wrapper(dist, i + 1); - tags[i] = tmp; + fields[i] = tmp; } } @@ -192,12 +192,12 @@ TEST(export_test, cjson_export_with_fixed_tag_and_many_metrics_on_one_cube_of_co int id_histogram = fieldstat_register_hist(instance, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); - Fieldstat_tag_list_wrapper *tags[tag_list_num]; - fill_random_tag(tags, tag_list_num); + Fieldstat_tag_list_wrapper *fields[tag_list_num]; + fill_random_tag(fields, tag_list_num); for (int j = 0; j < tag_list_num; j++) { - const struct fieldstat_tag *tag_tmp = tags[j]->get_tag(); - size_t tag_count = tags[j]->get_tag_count(); + const struct field *tag_tmp = fields[j]->get_tag(); + size_t tag_count = fields[j]->get_tag_count(); fieldstat_counter_incrby(instance, cube_id, id_counter, tag_tmp, tag_count, 1); for (size_t i = 0; i < OPER_NUM; i++){ @@ -215,10 +215,10 @@ TEST(export_test, cjson_export_with_fixed_tag_and_many_metrics_on_one_cube_of_co { cJSON *root = cJSON_GetArrayItem(root_arr, i); - // check tag - cJSON *tag = cJSON_GetObjectItem(root, "tags"); - EXPECT_NE(tag, nullptr); - test_check_if_tag_list_is_in_json(tag, tags[i]); + // check field + cJSON *field = cJSON_GetObjectItem(root, "tags"); + EXPECT_NE(field, nullptr); + test_check_if_tag_list_is_in_json(field, fields[i]); // check metrics cJSON *metrics = cJSON_GetObjectItem(root, "fields"); @@ -230,7 +230,7 @@ TEST(export_test, cjson_export_with_fixed_tag_and_many_metrics_on_one_cube_of_co } for (int i = 0; i < 3; i++) { - delete tags[i]; + delete fields[i]; } fieldstat_free(instance); @@ -262,7 +262,7 @@ TEST(export_test, cjson_export_on_one_cube_of_topk_sampling) EXPECT_EQ(tag_val->type, cJSON_Number); topk_tag_value_set.insert(tag_val->valueint); - struct fieldstat_tag_list tmp_tag = {(struct fieldstat_tag *)&TEST_TAG_SHARED1, 3}; + struct field_list tmp_tag = {(struct field *)&TEST_TAG_SHARED1, 3}; Fieldstat_tag_list_wrapper shared_wrapper = Fieldstat_tag_list_wrapper(&tmp_tag); test_check_if_tag_list_is_in_json(tag, &shared_wrapper); @@ -300,7 +300,7 @@ TEST(export_test, only_registered_but_not_added_export_null_with_global_tag) fieldstat_register_hist(instance, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); - // add global tag + // add global field cJSON *root_arr = test_exporter_extract_results_with_standard_global(instance); EXPECT_EQ(root_arr, nullptr); @@ -319,9 +319,9 @@ TEST(export_test, skip_two_empty_cube_and_export_last_one_with_global_tag) g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); const int tag_num = 1; - Fieldstat_tag_list_wrapper *tags[tag_num]; - fill_random_tag(tags, tag_num); - const Fieldstat_tag_list_wrapper *the_tag = tags[0]; + Fieldstat_tag_list_wrapper *fields[tag_num]; + fill_random_tag(fields, tag_num); + const Fieldstat_tag_list_wrapper *the_tag = fields[0]; for (size_t i = 0; i < OPER_NUM; i++){ fieldstat_hist_record(instance, cube_id_3, id_histogram, the_tag->get_tag(), the_tag->get_tag_count(), g_histogram_standard_oper[i]); } @@ -337,7 +337,7 @@ TEST(export_test, skip_two_empty_cube_and_export_last_one_with_global_tag) // check tag cJSON *tag = cJSON_GetObjectItem(root, "tags"); - test_check_if_tag_list_is_in_json(tag, tags[0]); + test_check_if_tag_list_is_in_json(tag, fields[0]); test_check_if_global_tag_is_in_json(tag); cJSON *metrics = cJSON_GetObjectItem(root, "fields"); @@ -350,7 +350,7 @@ TEST(export_test, skip_two_empty_cube_and_export_last_one_with_global_tag) FAIL(); } - delete tags[0]; + delete fields[0]; fieldstat_free(instance); cJSON_Delete(root_arr); @@ -367,9 +367,9 @@ TEST(export_test, skip_empty_metrics_given_cube_deleted) { (void)fieldstat_register_counter(instance, "counter4"); const int tag_num = 1; - Fieldstat_tag_list_wrapper *tags[tag_num]; - fill_random_tag(tags, tag_num); - const Fieldstat_tag_list_wrapper *the_tag = tags[0]; + Fieldstat_tag_list_wrapper *fields[tag_num]; + fill_random_tag(fields, tag_num); + const Fieldstat_tag_list_wrapper *the_tag = fields[0]; fieldstat_counter_incrby(instance, cube_id, metric_id, the_tag->get_tag(), the_tag->get_tag_count(), 1234); @@ -380,13 +380,13 @@ TEST(export_test, skip_empty_metrics_given_cube_deleted) { for (int i = 0; i < arr_num; i++) { cJSON *root = cJSON_GetArrayItem(root_arr, i); - // check tag - cJSON *tag = cJSON_GetObjectItem(root, "tags"); - test_check_if_tag_list_is_in_json(tag, tags[0]); - test_check_if_global_tag_is_in_json(tag); - struct fieldstat_tag_list tmp_tag = {(struct fieldstat_tag *)&TEST_TAG_SHARED2, 3}; + // check field + cJSON *field = cJSON_GetObjectItem(root, "tags"); + test_check_if_tag_list_is_in_json(field, fields[0]); + test_check_if_global_tag_is_in_json(field); + struct field_list tmp_tag = {(struct field *)&TEST_TAG_SHARED2, 3}; Fieldstat_tag_list_wrapper shared_wrapper = Fieldstat_tag_list_wrapper(&tmp_tag); - test_check_if_tag_list_is_in_json(tag, &shared_wrapper); + test_check_if_tag_list_is_in_json(field, &shared_wrapper); cJSON *metrics = cJSON_GetObjectItem(root, "fields"); EXPECT_NE(metrics, nullptr); @@ -399,7 +399,7 @@ TEST(export_test, skip_empty_metrics_given_cube_deleted) { FAIL(); } - delete tags[0]; + delete fields[0]; fieldstat_free(instance); cJSON_Delete(root_arr); } @@ -645,15 +645,15 @@ TEST(export_test, enable_delta_and_export_three_times_skipping_cube_with_no_coun fieldstat_free(instance); } -void test_check_delta_for_one_json(const struct fieldstat_tag_list *expect_cell_tag, const struct fieldstat_tag_list *expect_shared_tag, long long expect_value, long long expect_delta, cJSON *root) +void test_check_delta_for_one_json(const struct field_list *expect_cell_tag, const struct field_list *expect_shared_tag, long long expect_value, long long expect_delta, cJSON *root) { - // check tag - cJSON *tag = cJSON_GetObjectItem(root, "tags"); + // check field + cJSON *field = cJSON_GetObjectItem(root, "tags"); Fieldstat_tag_list_wrapper cell_wrapper = Fieldstat_tag_list_wrapper(expect_cell_tag); - test_check_if_tag_list_is_in_json(tag, &cell_wrapper); + test_check_if_tag_list_is_in_json(field, &cell_wrapper); Fieldstat_tag_list_wrapper shared_wrapper = Fieldstat_tag_list_wrapper(expect_shared_tag); - test_check_if_tag_list_is_in_json(tag, &shared_wrapper); - test_check_if_global_tag_is_in_json(tag); + test_check_if_tag_list_is_in_json(field, &shared_wrapper); + test_check_if_global_tag_is_in_json(field); // check metrics cJSON *metrics = cJSON_GetObjectItem(root, "fields"); @@ -690,21 +690,21 @@ TEST(export_test, enable_delta_and_export_instance_with_many_cells_with_global_t /* ------------------------------ cube 0 cell 0 ----------------------------- */ cJSON *root = cJSON_GetArrayItem(root_arr, 0); - struct fieldstat_tag_list tmp_tag_cell = {(struct fieldstat_tag *)&TEST_TAG_INT, 1}; - struct fieldstat_tag_list tmp_tag_shared = {(struct fieldstat_tag *)&TEST_TAG_SHARED1, 3}; + struct field_list tmp_tag_cell = {(struct field *)&TEST_TAG_INT, 1}; + struct field_list tmp_tag_shared = {(struct field *)&TEST_TAG_SHARED1, 3}; test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 11, 11, root); /* ------------------------------ cube 0 cell 1 ----------------------------- */ root = cJSON_GetArrayItem(root_arr, 1); - tmp_tag_cell = (struct fieldstat_tag_list){(struct fieldstat_tag *)&TEST_TAG_STRING, 1}; + tmp_tag_cell = (struct field_list){(struct field *)&TEST_TAG_STRING, 1}; test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 12, 12, root); /* ------------------------------ cube 1 cell 0 ----------------------------- */ root = cJSON_GetArrayItem(root_arr, 2); - tmp_tag_cell = (struct fieldstat_tag_list){(struct fieldstat_tag *)&TEST_TAG_INT, 1}; - tmp_tag_shared = (struct fieldstat_tag_list){(struct fieldstat_tag *)&TEST_TAG_SHARED3, 1}; + tmp_tag_cell = (struct field_list){(struct field *)&TEST_TAG_INT, 1}; + tmp_tag_shared = (struct field_list){(struct field *)&TEST_TAG_SHARED3, 1}; test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 21, 21, root); /* ------------------------------ cube 1 cell 1 ----------------------------- */ root = cJSON_GetArrayItem(root_arr, 3); - tmp_tag_cell = (struct fieldstat_tag_list){(struct fieldstat_tag *)&TEST_TAG_DOUBLE, 1}; + tmp_tag_cell = (struct field_list){(struct field *)&TEST_TAG_DOUBLE, 1}; test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 22, 22, root); // new turn @@ -726,21 +726,21 @@ TEST(export_test, enable_delta_and_export_instance_with_many_cells_with_global_t /* ------------------------------ cube 0 cell 0 ----------------------------- */ root = cJSON_GetArrayItem(root_arr, 0); - tmp_tag_cell = (struct fieldstat_tag_list){(struct fieldstat_tag *)&TEST_TAG_INT, 1}; - tmp_tag_shared = (struct fieldstat_tag_list){(struct fieldstat_tag *)&TEST_TAG_SHARED1, 3}; + tmp_tag_cell = (struct field_list){(struct field *)&TEST_TAG_INT, 1}; + tmp_tag_shared = (struct field_list){(struct field *)&TEST_TAG_SHARED1, 3}; test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 111, 100, root); /* ------------------------------ cube 0 cell 1 ----------------------------- */ root = cJSON_GetArrayItem(root_arr, 1); - tmp_tag_cell = (struct fieldstat_tag_list){(struct fieldstat_tag *)&TEST_TAG_STRING, 1}; + tmp_tag_cell = (struct field_list){(struct field *)&TEST_TAG_STRING, 1}; test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 212, 200, root); /* ------------------------------ cube 1 cell 0 ----------------------------- */ root = cJSON_GetArrayItem(root_arr, 2); - tmp_tag_cell = (struct fieldstat_tag_list){(struct fieldstat_tag *)&TEST_TAG_INT, 1}; - tmp_tag_shared = (struct fieldstat_tag_list){(struct fieldstat_tag *)&TEST_TAG_SHARED3, 1}; + tmp_tag_cell = (struct field_list){(struct field *)&TEST_TAG_INT, 1}; + tmp_tag_shared = (struct field_list){(struct field *)&TEST_TAG_SHARED3, 1}; test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 321, 300, root); /* ------------------------------ cube 1 cell 1 ----------------------------- */ root = cJSON_GetArrayItem(root_arr, 3); - tmp_tag_cell = (struct fieldstat_tag_list){(struct fieldstat_tag *)&TEST_TAG_DOUBLE, 1}; + tmp_tag_cell = (struct field_list){(struct field *)&TEST_TAG_DOUBLE, 1}; test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 422, 400, root); cJSON_Delete(root_arr); @@ -950,28 +950,6 @@ TEST(export_test, delta_with_two_instance_different_cell) fieldstat_free(delta); } -// TEST(export_test, sort_tag) { -// const struct fieldstat_tag tag1[3] = {TEST_TAG_INT, TEST_TAG_STRING, TEST_TAG_DOUBLE}; -// const struct fieldstat_tag tag2[3] = {TEST_TAG_STRING, TEST_TAG_DOUBLE, TEST_TAG_INT}; - -// struct fieldstat *instance = fieldstat_new(); -// fieldstat_create_cube(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); -// int id_counter = fieldstat_register_counter(instance, "counter"); -// fieldstat_counter_incrby(instance, 0, id_counter, tag1, 3, 1); -// fieldstat_counter_incrby(instance, 0, id_counter, tag2, 3, 10); - -// // export test -// cJSON *root_arr = test_exporter_extract_results(instance); -// EXPECT_EQ(cJSON_GetArraySize(root_arr), 1); -// cJSON *root = cJSON_GetArrayItem(root_arr, 0); -// cJSON *metrics = cJSON_GetObjectItem(root, "fields"); -// cJSON *counter = cJSON_GetObjectItem(metrics, "counter"); -// EXPECT_EQ(counter->valueint, 11); - -// cJSON_Delete(root_arr); -// fieldstat_free(instance); -// } - extern "C" { extern int add_object_to_json_array_start(char *buf, int buf_len); extern int add_object_to_json_array_end(char **buf, int buf_len, int start); diff --git a/test/test_fieldstat_exporter.py b/test/test_fieldstat_exporter.py index 232f4b5..6f65cb2 100644 --- a/test/test_fieldstat_exporter.py +++ b/test/test_fieldstat_exporter.py @@ -52,33 +52,33 @@ class TestPrometheusExporter(unittest.TestCase): def test__escape_metric_tags(self): json_obj = {'name': '-', - 'tags': { + 'fields': { 'send(){}/\\%*$-,;': 'sum', 'policy_id': 1, 'quanlity': 0.5 }, 'fields': {'T_success_log': 1}, 'timestamp': 1694657637836} - tags = self.prom._PrometheusExporter__escape_metric_tags(json_obj) + fields = self.prom._PrometheusExporter__escape_metric_tags(json_obj) - self.assertEqual(tags, "send____________=\"sum\",policy_id=\"1\",quanlity=\"0.5\",app_name=\"-\"") + self.assertEqual(fields, "send____________=\"sum\",policy_id=\"1\",quanlity=\"0.5\",app_name=\"-\"") def test__build_type_counter(self): name = "tsg_master_log" - tags = "send_log=\"sum\",policy_id=\"1\",app_name=\"-\"" + fields = "send_log=\"sum\",policy_id=\"1\",app_name=\"-\"" value = 100 - metric = self.prom._PrometheusExporter__build_type_counter(name, tags, value) + metric = self.prom._PrometheusExporter__build_type_counter(name, fields, value) self.assertEqual(metric, "tsg_master_log{send_log=\"sum\",policy_id=\"1\",app_name=\"-\"} 100\n") def test__build_histogram_format(self): c_hist = FieldstatAPI.libfieldstat.fieldstat_histogram_base64_decode(self.hist_val.encode('utf-8')) name = "tsg_master_log" - tags = "policy_id=\"1\",app_name=\"-\"" + fields = "policy_id=\"1\",app_name=\"-\"" self.prom.hist_bins = [10,20,50,80,90,95,99] - metrics = self.prom._PrometheusExporter__build_histogram_format(name, tags, c_hist) + metrics = self.prom._PrometheusExporter__build_histogram_format(name, fields, c_hist) desired = "tsg_master_log_bucket{policy_id=\"1\",app_name=\"-\",le=\"10.00\"} 10\n"\ "tsg_master_log_bucket{policy_id=\"1\",app_name=\"-\",le=\"20.00\"} 20\n"\ @@ -94,10 +94,10 @@ class TestPrometheusExporter(unittest.TestCase): def test__build_summary_format(self): c_hist = FieldstatAPI.libfieldstat.fieldstat_histogram_base64_decode(self.hist_val.encode('utf-8')) name = "tsg_master_log" - tags = "policy_id=\"1\",app_name=\"-\"" + fields = "policy_id=\"1\",app_name=\"-\"" self.prom.hist_bins = [0.1,0.2,0.5,0.8,0.9,0.95,0.99] - metrics = self.prom._PrometheusExporter__build_summary_format(name, tags, c_hist) + metrics = self.prom._PrometheusExporter__build_summary_format(name, fields, c_hist) desired = "tsg_master_log{policy_id=\"1\",app_name=\"-\",quantile=\"10.00%\"} 9\n" \ "tsg_master_log{policy_id=\"1\",app_name=\"-\",quantile=\"20.00%\"} 19\n"\ @@ -111,13 +111,13 @@ class TestPrometheusExporter(unittest.TestCase): def test__build_type_histogram(self): name = "tsg_master_log" - tags = "policy_id=\"1\",app_name=\"-\"" + fields = "policy_id=\"1\",app_name=\"-\"" value = self.hist_val self.prom.hist_bins = [0.1,0.2,0.5,0.8,0.9,0.95,0.99] self.prom.hist_format = "summary" - metrics = self.prom._PrometheusExporter__build_type_histogram(name, tags, value) + metrics = self.prom._PrometheusExporter__build_type_histogram(name, fields, value) desired = "tsg_master_log{policy_id=\"1\",app_name=\"-\",quantile=\"10.00%\"} 9\n" \ "tsg_master_log{policy_id=\"1\",app_name=\"-\",quantile=\"20.00%\"} 19\n"\ @@ -133,7 +133,7 @@ class TestPrometheusExporter(unittest.TestCase): self.prom.hist_bins = [10,20,50,80,90,95,99] self.prom.hist_format = "histogram" - metrics = self.prom._PrometheusExporter__build_type_histogram(name, tags, value) + metrics = self.prom._PrometheusExporter__build_type_histogram(name, fields, value) desired = "tsg_master_log_bucket{policy_id=\"1\",app_name=\"-\",le=\"10.00\"} 10\n"\ "tsg_master_log_bucket{policy_id=\"1\",app_name=\"-\",le=\"20.00\"} 20\n"\ @@ -149,10 +149,10 @@ class TestPrometheusExporter(unittest.TestCase): def test__build_type_hll(self): name = "tsg_master_log" - tags = "policy_id=\"1\",app_name=\"-\"" + fields = "policy_id=\"1\",app_name=\"-\"" value = "AQUBDECDAQxAQQUIIEEJCDCFARgQRAUIMIMAAAECAAAAAAAAAA==" - metric = self.prom._PrometheusExporter__build_type_hll(name, tags, value) + metric = self.prom._PrometheusExporter__build_type_hll(name, fields, value) self.assertEqual(metric, "tsg_master_log{policy_id=\"1\",app_name=\"-\"} 93.61\n") @@ -164,7 +164,7 @@ class TestPrometheusExporter(unittest.TestCase): "policy_id": 1, "quanlity": 0.50 }, - "fields": { + "tags": { "T_success_log": 1 }, "fields_delta": { @@ -180,7 +180,7 @@ class TestPrometheusExporter(unittest.TestCase): "tags": { "rule_id": 1 }, - "fields": { + "tags": { "external_ip": "AQUBDECDAQxAQQUIIEEJCDCFARgQRAUIMIMAAAECAAAAAAAAAA==", }, "timestamp_ms": 100010, @@ -196,7 +196,7 @@ class TestPrometheusExporter(unittest.TestCase): "rule_id": 1, "action": "deny" }, - "fields": { + "tags": { "list_num": "HISTEwAAAGQAAAAAAAAAAwAAAAAAAAABAAAAAAAJJ8A/8AAAAAAAAAEEAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAAAAAAAAA" }, "timestamp_ms": 100010, @@ -273,26 +273,26 @@ class TestCounterTable(unittest.TestCase): # self.c_table.field_names = [] # table = self.c_table.create_row_table({"column0": 0, "column1": 1}) - # tags = {"row": "0"} + # fields = {"row": "0"} # field = {"column0": 0, "column1":1} - # self.c_table.add_row_table_row(None, tags, field) + # self.c_table.add_row_table_row(None, fields, field) # table_str = table.get_string() # row_count = len(table_str.split("\n")) - 1 # self.assertEqual(row_count, 0) - # self.c_table.add_row_table_row(table, tags, field) + # self.c_table.add_row_table_row(table, fields, field) # row_count = len(table_str.split("\n")) - 1 # self.assertEqual(row_count, 0) def test_add_table_column(self): head = "policy_hit" - tags = "{\"thread_id\": 1,\"action\": \"deny\"}" + fields = "{\"thread_id\": 1,\"action\": \"deny\"}" value = 100 speed_s = 1.1 self.c_table.columns = [] - self.c_table.add_table_column(tags, head, value, speed_s) + self.c_table.add_table_column(fields, head, value, speed_s) self.assertEqual(len(self.c_table.columns), 1) self.assertEqual(self.c_table.read_columns_num(), 1) @@ -408,16 +408,16 @@ class TestHistogramTable(unittest.TestCase): def test_build_table(self): - tags = "{\"thread_id\": 1}" + fields = "{\"thread_id\": 1}" key = "hit_policy" - self.h_table.build_table(tags, key, self.hist_val, self.hist_val, 1000) + self.h_table.build_table(fields, key, self.hist_val, self.hist_val, 1000) table_str = self.h_table.tables[-1].get_string() row_count = len(table_str.split("\n")) self.assertEqual(row_count, 7) def test_build_table(self): - tags = "{\"thread_id\": 1,\"action\": \"deny\"}" + fields = "{\"thread_id\": 1,\"action\": \"deny\"}" key = "policy_hit" self.h_table.format = "summary" @@ -426,7 +426,7 @@ class TestHistogramTable(unittest.TestCase): self.h_table.bins = [] for i in range(1, n_bins + 1): self.h_table.bins.append(i * 0.01) - self.h_table.build_table(tags, key, self.hist_val, self.hist_val, 1000) + self.h_table.build_table(fields, key, self.hist_val, self.hist_val, 1000) table = self.h_table.tables[-1] self.assertEqual(len(table.field_names), n_bins + 6) table_str = self.h_table.tables[-1].get_string() @@ -435,7 +435,7 @@ class TestHistogramTable(unittest.TestCase): def test_print_tables(self): - tags = "{\"thread_id\": 1,\"action\": \"deny\"}" + fields = "{\"thread_id\": 1,\"action\": \"deny\"}" key = "policy_hit" value = self.hist_val @@ -443,7 +443,7 @@ class TestHistogramTable(unittest.TestCase): n_operate = random.randint(1, 100) self.h_table.tables = [] for _ in range (n_operate): - self.h_table.build_table(tags, key, self.hist_val, None, 1000) + self.h_table.build_table(fields, key, self.hist_val, None, 1000) output = StringIO() sys.stdout = output @@ -463,7 +463,7 @@ class TestHistogramTable(unittest.TestCase): class TestLocalExporter(unittest.TestCase): def setUp(self): self.local = LocalExporter() - self.tags = "{\"thread_id\": 1,\"action\": \"deny\"}" + self.fields = "{\"thread_id\": 1,\"action\": \"deny\"}" self.key = "policy_hit" @@ -471,7 +471,7 @@ class TestLocalExporter(unittest.TestCase): "tags": { "send_log": "sum" }, - "fields": { + "tags": { "T_fail_log": 2 }, "fields_delta": { @@ -485,7 +485,7 @@ class TestLocalExporter(unittest.TestCase): "tags": { "rule_id": 1 }, - "fields": { + "tags": { "acc_ip": "AQUFEGDCAhAwhAMMIQQBBBCDBRBggQMEMIcAAADCAAAAAAAAAA==" }, "timestamp_ms": 100010, @@ -497,7 +497,7 @@ class TestLocalExporter(unittest.TestCase): "tags": { "action": "deny" }, - "fields": { + "tags": { "list_num": "HISTEwAAAGQAAAAAAAAAAwAAAAAAAAABAAAAAAAJJ8A/8AAAAAAA"\ "AAEEAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC"\ "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC"\ @@ -532,7 +532,7 @@ class TestLocalExporter(unittest.TestCase): val_delta = random.randint(10, 20) tsms_delta = random.randint(1, 10) * 1000 self.local.ctable = CounterTable() - self.local._LocalExporter__build_counter_type_exporter(self.tags, self.key, val, val_delta, tsms_delta) + self.local._LocalExporter__build_counter_type_exporter(self.fields, self.key, val, val_delta, tsms_delta) self.assertEqual(self.local.ctable.columns[-1][1][1], str(val)) self.assertEqual(self.local.ctable.columns[-1][1][2], "{:.2f}".format(val_delta*1000/tsms_delta)) @@ -544,7 +544,7 @@ class TestLocalExporter(unittest.TestCase): "CAgICAgICAgICAgICAgICAgICAgIAAAAAAAAA" self.local.htable = HistogramTable() peradd = len(self.local.htable.tables) - self.local._LocalExporter__build_histogram_type_exporter(self.tags, self.key, hist_val, None, 0) + self.local._LocalExporter__build_histogram_type_exporter(self.fields, self.key, hist_val, None, 0) postadd = len(self.local.htable.tables) self.assertEqual(postadd - peradd, 1) @@ -553,36 +553,36 @@ class TestLocalExporter(unittest.TestCase): value = "AQUBDECDAQxAQQUIIEEJCDCFARgQRAUIMIMAAAECAAAAAAAAAA==" self.local.hlltable = CounterTable() peradd = len(self.local.hlltable.columns) - self.local._LocalExporter__build_hll_type_exporter(self.tags, self.key, value) + self.local._LocalExporter__build_hll_type_exporter(self.fields, self.key, value) postadd = len(self.local.hlltable.columns) self.assertEqual(postadd - peradd, 1) def test__append_app_name_to_tags(self): - tags = self.local._LocalExporter__append_app_name_to_tags(self.counter_json_object) - self.assertEqual(tags, "{\"send_log\": \"sum\", \"app_name\": \"-\"}") + fields = self.local._LocalExporter__append_app_name_to_tags(self.counter_json_object) + self.assertEqual(fields, "{\"send_log\": \"sum\", \"app_name\": \"-\"}") def test__is_tags_matched(self): self.local.match_tags = {} - tags = {"action": "deny", "policy_id": 0, "hit_rate": 1.1} - ret = self.local._LocalExporter__is_tags_matched(tags) + fields = {"action": "deny", "policy_id": 0, "hit_rate": 1.1} + ret = self.local._LocalExporter__is_tags_matched(fields) self.assertEqual(ret, True) self.local.match_tags = {"action": "deny"} - tags = {} - ret = self.local._LocalExporter__is_tags_matched(tags) + fields = {} + ret = self.local._LocalExporter__is_tags_matched(fields) self.assertEqual(ret, False) self.local.match_tags = {"action": "deny", "policy_id": 0, "hit_rate": 1.1} - tags = {"action": "deny"} - ret = self.local._LocalExporter__is_tags_matched(tags) + fields = {"action": "deny"} + ret = self.local._LocalExporter__is_tags_matched(fields) self.assertEqual(ret, False) self.local.match_tags = {"action": "deny", "policy_id": 0, "hit_rate": 1.10} - tags = {"action": "deny", "policy_id": 0, "hit_rate": 1.1} - ret = self.local._LocalExporter__is_tags_matched(tags) + fields = {"action": "deny", "policy_id": 0, "hit_rate": 1.1} + ret = self.local._LocalExporter__is_tags_matched(fields) self.assertEqual(ret, True) @@ -591,7 +591,7 @@ class TestLocalExporter(unittest.TestCase): "tags": { "send_log": "sum" }, - "fields": { + "tags": { "T_fail_log": 2 }, "fields_delta": { @@ -604,7 +604,7 @@ class TestLocalExporter(unittest.TestCase): "tags": { "send_log": "firewall" }, - "fields": { + "tags": { "T_fail_log": 2 }, "fields_delta": { @@ -684,7 +684,7 @@ class TestFieldstatExporter(unittest.TestCase): self.assertEqual(args.loop, False) self.assertEqual(args.clear_screen, False) - args = parser.parse_args(["local", "--loop", "--clear-screen", "-i", "1000", "--display-hist", "--display-hll", "--display-counter", "--match-tags", "policy:1,rule:1"]) + args = parser.parse_args(["local", "--loop", "--clear-screen", "-i", "1000", "--display-hist", "--display-hll", "--display-counter", "--match-fields", "policy:1,rule:1"]) self.assertEqual(args.interval, 1000) self.assertEqual(args.loop, True) self.assertEqual(args.clear_screen, True) @@ -701,8 +701,8 @@ class TestFieldstatExporter(unittest.TestCase): def test_parse_tags_str(self): tags_str = "policy:1,rule:intercept" - tags = self.exporter._FieldstatExporter__parse_tags_str(tags_str) - self.assertEqual(tags, {'policy': 1, 'rule': 'intercept'}) + fields = self.exporter._FieldstatExporter__parse_tags_str(tags_str) + self.assertEqual(fields, {'policy': 1, 'rule': 'intercept'}) def test_read_shared_args_value(self): parser = self.exporter._FieldstatExporter__build_shared_args_parser() diff --git a/test/test_fuzz_test.cpp b/test/test_fuzz_test.cpp index bcf0d20..38f68bc 100644 --- a/test/test_fuzz_test.cpp +++ b/test/test_fuzz_test.cpp @@ -10,7 +10,7 @@ using namespace std; -void fill_random_tag_of_length_1_to_3(Fieldstat_tag_list_wrapper *tags[], int tag_list_num) +void fill_random_tag_of_length_1_to_3(Fieldstat_tag_list_wrapper *fields[], int tag_list_num) { std::uniform_int_distribution dist(1,100); std::mt19937 rng(); @@ -19,11 +19,11 @@ void fill_random_tag_of_length_1_to_3(Fieldstat_tag_list_wrapper *tags[], int ta { Fieldstat_tag_list_wrapper *tmp = new Fieldstat_tag_list_wrapper(dist, rand() % 3 + 1); tmp->sort_tag_list(); - tags[i] = tmp; + fields[i] = tmp; } } -void fill_with_elephant_flows(Fieldstat_tag_list_wrapper *tags[], int tag_list_num) +void fill_with_elephant_flows(Fieldstat_tag_list_wrapper *fields[], int tag_list_num) { for (int i = 0; i < tag_list_num; i++) { @@ -36,11 +36,11 @@ void fill_with_elephant_flows(Fieldstat_tag_list_wrapper *tags[], int tag_list_n } else { tmp = new Fieldstat_tag_list_wrapper("mouse", rand() % 10000); } - tags[i] = tmp; + fields[i] = tmp; } } -long long fuzz_fieldstat_counter_get(const struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag_list *tag_list) +long long fuzz_fieldstat_counter_get(const struct fieldstat *instance, int cube_id, int metric_id, const struct field_list *tag_list) { long long value = 0; int ret = fieldstat_counter_get(instance, cube_id, tag_list, metric_id, &value); @@ -48,7 +48,7 @@ long long fuzz_fieldstat_counter_get(const struct fieldstat *instance, int cube_ return value; } -double fuzz_fieldstat_hll_get(const struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag_list *tag_list) +double fuzz_fieldstat_hll_get(const struct fieldstat *instance, int cube_id, int metric_id, const struct field_list *tag_list) { double value = 0; int ret = fieldstat_hll_get(instance, cube_id, tag_list, metric_id, &value); @@ -83,7 +83,7 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ // init metric fieldstat_register_counter(master, metric_name[METRIC_ID_COUNTER]); fieldstat_register_hll(master, metric_name[METRIC_ID_HLL], 6); - // all the possible tags + // all the possible fields Fieldstat_tag_list_wrapper *tag_list_wrapper[FLOW_NUM]; fill_random_tag_of_length_1_to_3(tag_list_wrapper, FLOW_NUM); //all the possible operations @@ -133,19 +133,19 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ } } struct fieldstat *instance = replica[rand() % INSTANCE_NUM]; // the flow randomly goes to one of the instance - const Fieldstat_tag_list_wrapper * tag = tag_list_wrapper[rand() % FLOW_NUM]; + const Fieldstat_tag_list_wrapper * field = tag_list_wrapper[rand() % FLOW_NUM]; int cube_id = rand() % CUBE_NUM; const Fieldstat_tag_list_wrapper *shared_tag = shared_tags[cube_id]; - int ret_add = fieldstat_counter_incrby(instance, cube_id, METRIC_ID_COUNTER, tag->get_tag(), tag->get_tag_count(), rand_nums[i]); + int ret_add = fieldstat_counter_incrby(instance, cube_id, METRIC_ID_COUNTER, field->get_tag(), field->get_tag_count(), rand_nums[i]); if (ret_add == FS_ERR_TOO_MANY_CELLS) { continue; } EXPECT_EQ(ret_add, FS_OK); string *val = rand_strs[i]; - ret_add = fieldstat_hll_add(instance, cube_id, METRIC_ID_HLL, tag->get_tag(), tag->get_tag_count(), val->c_str(), val->size()); + ret_add = fieldstat_hll_add(instance, cube_id, METRIC_ID_HLL, field->get_tag(), field->get_tag_count(), val->c_str(), val->size()); EXPECT_EQ(ret_add, FS_OK); - string cell_key = shared_tag->to_string() + tag->to_string(); + string cell_key = shared_tag->to_string() + field->to_string(); comp_count[cell_key] += rand_nums[i]; comp_hll[cell_key].insert(*val); } @@ -170,10 +170,10 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ struct fieldstat *instance_in_focus = dest; fieldstat_get_cubes(instance_in_focus, &cube_ids, &cube_num); for (int i = 0; i < cube_num; i++) { - struct fieldstat_tag_list *shared_tag_out = fieldstat_cube_get_tags(instance_in_focus, cube_ids[i]); + struct field_list *shared_tag_out = fieldstat_cube_get_tags(instance_in_focus, cube_ids[i]); size_t cell_num0; - struct fieldstat_tag_list *tags0; + struct field_list *tags0; fieldstat_cube_get_cells(instance_in_focus, cube_ids[i], &tags0, &cell_num0); for (size_t j = 0; j < cell_num0; j++) { @@ -222,7 +222,7 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ } // init metric fieldstat_register_counter(master, "topk"); - // all the possible tags + // all the possible fields Fieldstat_tag_list_wrapper *tag_list_wrapper[FLOW_NUM]; fill_with_elephant_flows(tag_list_wrapper, FLOW_NUM); //all the possible operations @@ -235,7 +235,7 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ replica[i] = fieldstat_fork(master); } // for benchmark - unordered_map> count_map; // hte first key is shared tag, second key is tag + unordered_map> count_map; // hte first key is shared field, second key is field clock_t start = clock(); int next_shared_tag_value = CUBE_NUM; @@ -269,16 +269,16 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ } } struct fieldstat *instance = replica[rand() % INSTANCE_NUM]; // the flow randomly goes to one of the instance - const Fieldstat_tag_list_wrapper * tag = tag_list_wrapper[rand() % FLOW_NUM]; + const Fieldstat_tag_list_wrapper * field = tag_list_wrapper[rand() % FLOW_NUM]; int cube_id = rand() % CUBE_NUM; const Fieldstat_tag_list_wrapper *shared_tag = shared_tags[cube_id]; - int ret_add = fieldstat_counter_incrby(instance, cube_id, 0, tag->get_tag(), tag->get_tag_count(), rand_nums[i]); + int ret_add = fieldstat_counter_incrby(instance, cube_id, 0, field->get_tag(), field->get_tag_count(), rand_nums[i]); if (ret_add == FS_ERR_TOO_MANY_CELLS) { continue; } EXPECT_EQ(ret_add, FS_OK); - count_map[shared_tag->to_string()][tag->to_string()] += rand_nums[i]; + count_map[shared_tag->to_string()][field->to_string()] += rand_nums[i]; } clock_t end = clock(); @@ -296,15 +296,15 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ struct fieldstat *instance_in_focus = dest; fieldstat_get_cubes(instance_in_focus, &cube_ids, &cube_num); for (int i = 0; i < cube_num; i++) { - struct fieldstat_tag_list *shared_tag_out = fieldstat_cube_get_tags(instance_in_focus, cube_ids[i]); + struct field_list *shared_tag_out = fieldstat_cube_get_tags(instance_in_focus, cube_ids[i]); size_t cell_num; - struct fieldstat_tag_list *tags; - fieldstat_cube_get_cells(instance_in_focus, cube_ids[i], &tags, &cell_num); + struct field_list *fields; + fieldstat_cube_get_cells(instance_in_focus, cube_ids[i], &fields, &cell_num); std::vector test_result; for (size_t j = 0; j < cell_num; j++) { - test_result.push_back(new Fieldstat_tag_list_wrapper(&tags[j])); + test_result.push_back(new Fieldstat_tag_list_wrapper(&fields[j])); } double accuracy = test_cal_topk_accuracy(test_result, count_map[Fieldstat_tag_list_wrapper(shared_tag_out).to_string()]); @@ -315,7 +315,7 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ delete test_result[j]; } - fieldstat_tag_list_arr_free(tags, cell_num); + fieldstat_tag_list_arr_free(fields, cell_num); fieldstat_tag_list_arr_free(shared_tag_out, 1); } free(cube_ids); @@ -341,23 +341,23 @@ TEST(Fuzz_test, add_and_reset_with_randomly_generated_flows_and_randomly_chosen_ fieldstat_counter_incrby(instance, cube_id, primary_metric_id, tag_list_wrapper[0]->get_tag(), tag_list_wrapper[0]->get_tag_count(), 1); fieldstat_counter_incrby(instance, cube_id, counter2_id, tag_list_wrapper[0]->get_tag(), tag_list_wrapper[0]->get_tag_count(), 1); - struct fieldstat_tag_list tag_list_tmp = {NULL, 0}; + struct field_list tag_list_tmp = {NULL, 0}; for(int i = 0; i < FLOW_NUM; i++) { int using_id = rand() % 2 == 0 ? primary_metric_id : counter2_id; int ret = fieldstat_counter_incrby(instance, cube_id, using_id, tag_list_wrapper[i]->get_tag(), tag_list_wrapper[i]->get_tag_count(), 1); if (ret == FS_ERR_TOO_MANY_CELLS) { - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance, cube_id, &tag_list, &n_cell); ASSERT_EQ(n_cell, 1); long long value; - tag_list_tmp.tag = (struct fieldstat_tag *)tag_list_wrapper[i]->get_tag(); - tag_list_tmp.n_tag = tag_list_wrapper[i]->get_tag_count(); + tag_list_tmp.field = (struct field *)tag_list_wrapper[i]->get_tag(); + tag_list_tmp.n_field = tag_list_wrapper[i]->get_tag_count(); int counter_exist = fieldstat_counter_get(instance, cube_id, &tag_list_tmp, using_id, &value); - ASSERT_EQ(counter_exist, FS_ERR_INVALID_TAG); // the tag is not added to the cube + ASSERT_EQ(counter_exist, FS_ERR_INVALID_TAG); // the field is not added to the cube fieldstat_tag_list_arr_free(tag_list, n_cell); } @@ -391,7 +391,7 @@ TEST(Fuzz_test, simple_one_for_perf) } // init metric fieldstat_register_counter(master, "topk"); - // all the possible tags + // all the possible fields Fieldstat_tag_list_wrapper *tag_list_wrapper[FLOW_NUM]; fill_with_elephant_flows(tag_list_wrapper, FLOW_NUM); //all the possible operations @@ -408,10 +408,10 @@ TEST(Fuzz_test, simple_one_for_perf) for (int i = 0; i < TEST_ROUND; i++) { - const Fieldstat_tag_list_wrapper * tag = tag_list_wrapper[rand() % FLOW_NUM]; + const Fieldstat_tag_list_wrapper * field = tag_list_wrapper[rand() % FLOW_NUM]; int cube_id = rand() % CUBE_NUM; - (void)fieldstat_counter_incrby(instance, cube_id, 0, tag->get_tag(), tag->get_tag_count(), rand_nums[i]); + (void)fieldstat_counter_incrby(instance, cube_id, 0, field->get_tag(), field->get_tag_count(), rand_nums[i]); } clock_t end = clock(); diff --git a/test/test_merge.cpp b/test/test_merge.cpp index cf37bc7..e51b90d 100644 --- a/test/test_merge.cpp +++ b/test/test_merge.cpp @@ -31,7 +31,7 @@ double test_cal_accuracy_given_expected_key(vectorn_tag, 1); - EXPECT_STREQ(tag_list->tag[0].key, TEST_TAG_STRING.key); + EXPECT_EQ(tag_list->n_field, 1); + EXPECT_STREQ(tag_list->field[0].key, TEST_TAG_STRING.key); fieldstat_free(instance); fieldstat_free(instance_dest); @@ -203,7 +203,7 @@ TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_a fieldstat_merge(instance_dest, instance); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance_dest, 0, &tag_list, &n_cell); EXPECT_EQ(n_cell, 2); @@ -291,12 +291,12 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_topk) long long measure = merge_test_fieldstat_counter_get(instance, cube_id, metric_id); EXPECT_EQ(measure, 10086); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance, cube_id, &tag_list, &n_cell); EXPECT_EQ(n_cell, 1); - EXPECT_EQ(tag_list->n_tag, 1); - EXPECT_STREQ(tag_list->tag[0].key, TEST_TAG_STRING.key); + EXPECT_EQ(tag_list->n_field, 1); + EXPECT_STREQ(tag_list->field[0].key, TEST_TAG_STRING.key); fieldstat_free(instance); fieldstat_free(instance_dest); @@ -322,7 +322,7 @@ TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_topk) free(cube_id_dest); EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0), "metric_name"); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance_dest, ret_cube_id, &tag_list, &n_cell); EXPECT_EQ(n_cell, 1); @@ -350,7 +350,7 @@ TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_a fieldstat_merge(instance_dest, instance); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance_dest, 0, &tag_list, &n_cell); EXPECT_EQ(n_cell, 2); @@ -382,7 +382,7 @@ TEST(unit_test_merge, merge_accuracy_test_with_K_large_enough_topk) struct fieldstat *instance_dest = test_push_flows(flows_in_dest, K); fieldstat_merge(instance_dest, instance_src); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance_dest, 0, &tag_list, &n_cell); @@ -420,7 +420,7 @@ TEST(unit_test_merge, merge_accuracy_test_gen_dest_full_all_inserted_given_src_f fieldstat_merge(instance_dest, instance_src); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance_dest, 0, &tag_list, &n_cell); vector flows_in_merged; @@ -453,7 +453,7 @@ TEST(unit_test_merge, merge_accuracy_test_gen_dest_full_some_inserted_and_some_m struct fieldstat *instance_dest = test_push_flows(flows_in_dest, K); fieldstat_merge(instance_dest, instance_src); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance_dest, 0, &tag_list, &n_cell); vector flows_in_merged; @@ -488,11 +488,11 @@ TEST(unit_test_merge, primary_metric_has_no_value) fieldstat_merge(instance_dest, instance); fieldstat_merge(instance_dest, instance); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance_dest, 0, &tag_list, &n_cell); EXPECT_EQ(n_cell, 1); - EXPECT_STREQ(tag_list[0].tag[0].key, TEST_TAG_STRING.key); + EXPECT_STREQ(tag_list[0].field[0].key, TEST_TAG_STRING.key); EXPECT_EQ(merge_test_fieldstat_counter_get(instance_dest, 0, metric_operated, &tag_list[0]), 2); EXPECT_EQ(merge_test_fieldstat_counter_get(instance_dest, 0, metric_primary, &tag_list[0]), 0); diff --git a/test/test_metric_counter.cpp b/test/test_metric_counter.cpp index d5d2d5c..675c42f 100644 --- a/test/test_metric_counter.cpp +++ b/test/test_metric_counter.cpp @@ -19,7 +19,7 @@ struct fieldstat *test_init_standard_instance() return instance; } -long long my_fieldstat_counter_get(const struct fieldstat *instance, int cube_id, int metric_id, const struct fieldstat_tag_list *tag_list = &TEST_TAG_LIST_INT) +long long my_fieldstat_counter_get(const struct fieldstat *instance, int cube_id, int metric_id, const struct field_list *tag_list = &TEST_TAG_LIST_INT) { long long ret = 0; fieldstat_counter_get(instance, cube_id, tag_list, metric_id, &ret); @@ -38,12 +38,12 @@ void test_assert_standard_instance(const struct fieldstat *instance) const char *name = fieldstat_get_metric_name(instance, 0); EXPECT_STREQ(name, "czz_test counter metric"); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance, 0, &tag_list, &n_cell); EXPECT_EQ(n_cell, 1); - EXPECT_EQ(tag_list->n_tag, 1); - EXPECT_STREQ(tag_list->tag[0].key, TEST_TAG_INT.key); + EXPECT_EQ(tag_list->n_field, 1); + EXPECT_STREQ(tag_list->field[0].key, TEST_TAG_INT.key); int *metric_id = NULL; size_t n_metric = 0; @@ -114,7 +114,7 @@ TEST(metric_test_counter, topk_add_and_test_accuracy) fieldstat_register_counter(instance, "test"); int tag_list_num = 10000; - Fieldstat_tag_list_wrapper *tags[tag_list_num]; + Fieldstat_tag_list_wrapper *fields[tag_list_num]; map flow_cnt; for (int i = 0; i < tag_list_num; i++) { @@ -127,16 +127,16 @@ TEST(metric_test_counter, topk_add_and_test_accuracy) flow_k = "mouse"; flow_v = std::to_string(rand() % 1000); } - tags[i] = new Fieldstat_tag_list_wrapper(flow_k, flow_v.c_str()); + fields[i] = new Fieldstat_tag_list_wrapper(flow_k, flow_v.c_str()); flow_cnt[flow_k + flow_v]++; } for (int i = 0; i < tag_list_num; i++) { - fieldstat_counter_incrby(instance, 0, 0, tags[i]->get_tag(), tags[i]->get_tag_count(), 1); + fieldstat_counter_incrby(instance, 0, 0, fields[i]->get_tag(), fields[i]->get_tag_count(), 1); } - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance, 0, &tag_list, &n_cell); EXPECT_EQ(n_cell, 10); @@ -159,7 +159,7 @@ TEST(metric_test_counter, topk_add_and_test_accuracy) fieldstat_free(instance); for (int i = 0; i < tag_list_num; i++) - delete tags[i]; + delete fields[i]; } TEST(metric_test_counter, add_with_wrong_cube_id_expecting_fail) @@ -230,15 +230,15 @@ TEST(metric_test_counter, primary_counter_add_after_first) EXPECT_EQ(my_fieldstat_counter_get(instance, cube_id, metric_id2), 10); // TOPK functions well - struct fieldstat_tag tag = TEST_TAG_INT; + struct field field = TEST_TAG_INT; for (int i = 0; i < 9; i++) { - tag.value_longlong = i + 123; - ret = fieldstat_counter_incrby(instance, cube_id, metric_id_primary, &tag, 1, 1 + i); + field.value_longlong = i + 123; + ret = fieldstat_counter_incrby(instance, cube_id, metric_id_primary, &field, 1, 1 + i); EXPECT_EQ(ret, FS_OK); } // now the TOPK is full, add a new one - tag.value_longlong = 321; - ret = fieldstat_counter_incrby(instance, cube_id, metric_id_primary, &tag, 1, 1); + field.value_longlong = 321; + ret = fieldstat_counter_incrby(instance, cube_id, metric_id_primary, &field, 1, 1); EXPECT_EQ(ret, FS_ERR_TOO_MANY_CELLS); fieldstat_free(instance); diff --git a/test/test_metric_histogram.cpp b/test/test_metric_histogram.cpp index 4faf9fc..06fdd17 100644 --- a/test/test_metric_histogram.cpp +++ b/test/test_metric_histogram.cpp @@ -31,12 +31,12 @@ void test_assert_standard_instance(const struct fieldstat *instance) EXPECT_STREQ(name, "czz_test hdr metric"); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance, 0, &tag_list, &n_cell); EXPECT_EQ(n_cell, 1); - EXPECT_EQ(tag_list->n_tag, 1); - EXPECT_STREQ(tag_list->tag[0].key, TEST_TAG_STRING.key); + EXPECT_EQ(tag_list->n_field, 1); + EXPECT_STREQ(tag_list->field[0].key, TEST_TAG_STRING.key); int *metric_id = NULL; size_t n_metric = 0; diff --git a/test/test_metric_hll.cpp b/test/test_metric_hll.cpp index 3a4cbe1..8e96266 100644 --- a/test/test_metric_hll.cpp +++ b/test/test_metric_hll.cpp @@ -26,12 +26,12 @@ void test_assert_standard_instance(const struct fieldstat *instance) const char *name = fieldstat_get_metric_name(instance, 0); EXPECT_STREQ(name, "czz_test hll metric"); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; size_t n_cell = 0; fieldstat_cube_get_cells(instance, 0, &tag_list, &n_cell); EXPECT_EQ(n_cell, 1); - EXPECT_EQ(tag_list->n_tag, 1); - EXPECT_STREQ(tag_list->tag[0].key, TEST_TAG_INT.key); + EXPECT_EQ(tag_list->n_field, 1); + EXPECT_STREQ(tag_list->field[0].key, TEST_TAG_INT.key); int *metric_id = NULL; size_t n_metric = 0; @@ -67,9 +67,9 @@ TEST(metric_test_hll, simple_register_and_query) TEST(metric_test_hll, add_with_tags) { struct fieldstat *instance = test_init_standard_instance_one_cube_one_metric_one_cell_hll(); - fieldstat_hll_add_tag(instance, 0, 0, &TEST_TAG_INT, 1, &TEST_TAG_INT, 1); - fieldstat_hll_add_tag(instance, 0, 0, &TEST_TAG_INT, 1, &TEST_TAG_DOUBLE, 1); - fieldstat_hll_add_tag(instance, 0, 0, &TEST_TAG_INT, 1, &TEST_TAG_STRING, 1); + fieldstat_hll_add_field(instance, 0, 0, &TEST_TAG_INT, 1, &TEST_TAG_INT, 1); + fieldstat_hll_add_field(instance, 0, 0, &TEST_TAG_INT, 1, &TEST_TAG_DOUBLE, 1); + fieldstat_hll_add_field(instance, 0, 0, &TEST_TAG_INT, 1, &TEST_TAG_STRING, 1); test_assert_standard_instance(instance); EXPECT_NEAR(my_fieldstat_hll_get(instance, 0, 0), 3, 0.5); diff --git a/test/test_performance.cpp b/test/test_performance.cpp index 11c05ce..5931a81 100644 --- a/test/test_performance.cpp +++ b/test/test_performance.cpp @@ -9,19 +9,19 @@ // /* -------------------------------------------------------------------------- */ // /* merge */ // /* -------------------------------------------------------------------------- */ -double perform_merge_test(std::function metric_add_func, +double perform_merge_test(std::function metric_add_func, std::function metric_register_func, enum sampling_mode mode, bool merge_empty_dest) { const int MAX_CELL_NUM = 1000; - Fieldstat_tag_list_wrapper *tags[MAX_CELL_NUM]; + Fieldstat_tag_list_wrapper *fields[MAX_CELL_NUM]; for (int i = 0; i < MAX_CELL_NUM; i++) { - tags[i] = new Fieldstat_tag_list_wrapper("my key", i); + fields[i] = new Fieldstat_tag_list_wrapper("my key", i); } struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, mode, MAX_CELL_NUM); int metric_id = metric_register_func(instance); for (int j = 0; j < MAX_CELL_NUM; j++) { - metric_add_func(instance, cube_id, metric_id, tags[j]->get_tag(), 1); + metric_add_func(instance, cube_id, metric_id, fields[j]->get_tag(), 1); } struct fieldstat *instance_dest = fieldstat_new(); @@ -36,7 +36,7 @@ double perform_merge_test(std::functionget_tag(), 1, 1); + fieldstat_counter_incrby(instance, cube_id, metric_id, fields[rand() % TAG_NUM]->get_tag(), 1, 1); } } } @@ -447,7 +447,7 @@ TEST(test_performance, export_many_cells) fieldstat_free(instance); for (int i = 0; i < TAG_NUM; i++) { - delete tags[i]; + delete fields[i]; } } @@ -501,7 +501,7 @@ struct fieldstat *construct_fs_with_many_cells(int cell_num, enum sampling_mode struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT, 1, mode, cell_num); fieldstat_register_counter(instance, "test"); - struct fieldstat_tag tmp_tag = TEST_TAG_INT; + struct field tmp_tag = TEST_TAG_INT; for (int i = 0; i < cell_num; i++) { tmp_tag.value_longlong = i; fieldstat_counter_incrby(instance, 0, 0, &tmp_tag, 1, 1); diff --git a/test/test_register_and_reset.cpp b/test/test_register_and_reset.cpp index 25bdfb0..2e295e8 100644 --- a/test/test_register_and_reset.cpp +++ b/test/test_register_and_reset.cpp @@ -82,7 +82,7 @@ TEST(test_register, register_many_cubes) { struct fieldstat *instance = fieldstat_new(); int registered_cube = 10000; // will trigger realloc many times - struct fieldstat_tag shared_tag = TEST_SHARED_TAG; + struct field shared_tag = TEST_SHARED_TAG; for (int i = 0; i < registered_cube; i++) { shared_tag.value_longlong = i; int cube_id = fieldstat_create_cube(instance, &shared_tag, 1, SAMPLING_MODE_COMPREHENSIVE, 10); @@ -107,16 +107,17 @@ TEST(test_register, add_many_tagged_cells) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - struct fieldstat_tag test_tag_long[100]; - for (int i = 0; i < 100; i++) { + size_t n_field = 1000; + struct field test_tag_long[n_field]; + for (int i = 0; i < n_field; i++) { test_tag_long[i] = TEST_TAG_INT; // will trigger realloc } int metric_id = fieldstat_register_counter(instance, "counter"); - fieldstat_counter_incrby(instance, cube_id, metric_id, test_tag_long, 100, 10086); + fieldstat_counter_incrby(instance, cube_id, metric_id, test_tag_long, n_field, 10086); long long result; - struct fieldstat_tag_list tag_list = {test_tag_long, 100}; + struct field_list tag_list = {test_tag_long, n_field}; fieldstat_counter_get(instance, cube_id, &tag_list, metric_id, &result); EXPECT_EQ(result, 10086); @@ -127,7 +128,7 @@ TEST(test_register, add_long_tagged_cells) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - struct fieldstat_tag test_tag_long = TEST_TAG_STRING; + struct field test_tag_long = TEST_TAG_STRING; char *long_string = (char *)malloc(5001); memset(long_string, 'a', 5001); long_string[5000] = '\0'; @@ -137,7 +138,7 @@ TEST(test_register, add_long_tagged_cells) fieldstat_counter_incrby(instance, cube_id, metric_id, &test_tag_long, 1, 10086); long long result; - struct fieldstat_tag_list tag_list = {&test_tag_long, 1}; + struct field_list tag_list = {&test_tag_long, 1}; fieldstat_counter_get(instance, cube_id, &tag_list, metric_id, &result); EXPECT_EQ(result, 10086); @@ -194,17 +195,17 @@ TEST(test_register, fork_registered_info_with_cube_and_metric) int cube_num; fieldstat_get_cubes(dup, &cube_ids, &cube_num); EXPECT_EQ(cube_num, 2); - struct fieldstat_tag_list *tag_list = NULL; + struct field_list *tag_list = NULL; tag_list = fieldstat_cube_get_tags(dup, cube_ids[0]); - EXPECT_STREQ(tag_list->tag[0].key, TEST_SHARED_TAG.key); + EXPECT_STREQ(tag_list->field[0].key, TEST_SHARED_TAG.key); fieldstat_tag_list_arr_free(tag_list, 1); size_t n_cell = 0; fieldstat_cube_get_cells(dup, cube_ids[0], &tag_list, &n_cell); EXPECT_EQ(n_cell, 0); tag_list = fieldstat_cube_get_tags(dup, cube_ids[1]); - EXPECT_STREQ(tag_list->tag[0].key, TEST_TAG_DOUBLE.key); + EXPECT_STREQ(tag_list->field[0].key, TEST_TAG_DOUBLE.key); free(cube_ids); fieldstat_tag_list_arr_free(tag_list, 1); @@ -256,7 +257,7 @@ TEST(test_register, register_many_cells_on_unlimited_sized_cube) struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 0); int metric_id = fieldstat_register_counter(instance, "counter"); - struct fieldstat_tag test_tag = {"abc", TAG_INTEGER, {.value_longlong = 0}}; + struct field test_tag = {"abc", TAG_INTEGER, {.value_longlong = 0}}; for (int i = 0; i < 10000; i++) { test_tag.value_longlong = i; fieldstat_counter_incrby(instance, cube_id, metric_id, &test_tag, 1, 1); @@ -264,7 +265,7 @@ TEST(test_register, register_many_cells_on_unlimited_sized_cube) for (int i = 0; i < 10000; i++) { test_tag.value_longlong = i; - struct fieldstat_tag_list tag_list = {&test_tag, 1}; + struct field_list tag_list = {&test_tag, 1}; long long value; fieldstat_counter_get(instance, cube_id, &tag_list, metric_id, &value); EXPECT_EQ(value, 1); @@ -313,8 +314,8 @@ TEST(calibrate, target_one_more_metric) EXPECT_EQ(test_get_max_metric_id(target), 0); EXPECT_STREQ(fieldstat_get_metric_name(target, 0), "counter"); - struct fieldstat_tag_list *tag_list = fieldstat_cube_get_tags(target, cube_id); - EXPECT_STREQ(tag_list->tag[0].key, TEST_SHARED_TAG.key); + struct field_list *tag_list = fieldstat_cube_get_tags(target, cube_id); + EXPECT_STREQ(tag_list->field[0].key, TEST_SHARED_TAG.key); fieldstat_free(master); fieldstat_free(target); @@ -334,8 +335,8 @@ TEST(calibrate, master_one_more_metric) EXPECT_EQ(test_get_max_metric_id(target), 1); EXPECT_STREQ(fieldstat_get_metric_name(target, 0), "counter"); EXPECT_STREQ(fieldstat_get_metric_name(target, 1), "counter2"); - struct fieldstat_tag_list *tag_list = fieldstat_cube_get_tags(target, cube_id); - EXPECT_STREQ(tag_list->tag[0].key, TEST_SHARED_TAG.key); + struct field_list *tag_list = fieldstat_cube_get_tags(target, cube_id); + EXPECT_STREQ(tag_list->field[0].key, TEST_SHARED_TAG.key); fieldstat_free(master); fieldstat_free(target); @@ -357,8 +358,8 @@ TEST(calibrate, different_metric) EXPECT_EQ(test_get_max_metric_id(target), 1); EXPECT_STREQ(fieldstat_get_metric_name(target, 0), "counter"); EXPECT_STREQ(fieldstat_get_metric_name(target, 1), "hi i am master new"); - struct fieldstat_tag_list *tag_list = fieldstat_cube_get_tags(target, cube_id); - EXPECT_STREQ(tag_list->tag[0].key, TEST_SHARED_TAG.key); + struct field_list *tag_list = fieldstat_cube_get_tags(target, cube_id); + EXPECT_STREQ(tag_list->field[0].key, TEST_SHARED_TAG.key); fieldstat_free(master); fieldstat_free(target); @@ -386,8 +387,8 @@ TEST(calibrate, target_more_cube) EXPECT_EQ(test_get_max_metric_id(target), 0); EXPECT_STREQ(fieldstat_get_metric_name(target, 0), "counter"); - struct fieldstat_tag_list *tag_list = fieldstat_cube_get_tags(target, cube_id); - EXPECT_STREQ(tag_list->tag[0].key, TEST_SHARED_TAG.key); + struct field_list *tag_list = fieldstat_cube_get_tags(target, cube_id); + EXPECT_STREQ(tag_list->field[0].key, TEST_SHARED_TAG.key); EXPECT_EQ(fieldstat_find_cube(target, &TEST_SHARED_TAG, 1), 0); EXPECT_EQ(fieldstat_find_cube(target, &TEST_TAG_STRING, 1), FS_ERR_INVALID_KEY); @@ -414,10 +415,10 @@ TEST(calibrate, master_more_cube) EXPECT_EQ(cube_ids[1], cube_id2); free(cube_ids); - struct fieldstat_tag_list *tag_list = fieldstat_cube_get_tags(target, cube_id); - EXPECT_STREQ(tag_list->tag[0].key, TEST_SHARED_TAG.key); - struct fieldstat_tag_list *tag_list2 = fieldstat_cube_get_tags(target, cube_id2); - EXPECT_STREQ(tag_list2->tag[0].key, TEST_TAG_STRING.key); + struct field_list *tag_list = fieldstat_cube_get_tags(target, cube_id); + EXPECT_STREQ(tag_list->field[0].key, TEST_SHARED_TAG.key); + struct field_list *tag_list2 = fieldstat_cube_get_tags(target, cube_id2); + EXPECT_STREQ(tag_list2->field[0].key, TEST_TAG_STRING.key); EXPECT_EQ(fieldstat_find_cube(target, &TEST_TAG_STRING, 1), 1); EXPECT_EQ(fieldstat_find_cube(target, &TEST_SHARED_TAG, 1), 0); @@ -439,8 +440,8 @@ TEST(calibrate, master_change_cube) fieldstat_calibrate(master, target); - struct fieldstat_tag_list *tag_list = fieldstat_cube_get_tags(target, cube_id); - EXPECT_STREQ(tag_list->tag[0].key, TEST_TAG_STRING.key); + struct field_list *tag_list = fieldstat_cube_get_tags(target, cube_id); + EXPECT_STREQ(tag_list->field[0].key, TEST_TAG_STRING.key); EXPECT_EQ(fieldstat_find_cube(target, &TEST_TAG_STRING, 1), 0); @@ -453,7 +454,7 @@ TEST(calibrate, master_many_cube) { struct fieldstat *master = fieldstat_new(); int registered_cube = 3000; // will trigger realloc 1 times - struct fieldstat_tag shared_tag = TEST_SHARED_TAG; + struct field shared_tag = TEST_SHARED_TAG; for (int i = 0; i < registered_cube; i++) { shared_tag.value_longlong = i; int cube_id = fieldstat_create_cube(master, &shared_tag, 1, SAMPLING_MODE_COMPREHENSIVE, 10); @@ -493,7 +494,7 @@ TEST(calibrate, master_many_cube) // calibrate调用时,依次比较每个cube id,id:0时,将master[0] 同步,同步时,会先删除A,然后添加B' // replica:B' B (B' B) -// calibrate 继续,同步master[1],replica[1]不存在,创建新的cube。此时,不仅从id->cube 的数组中删除掉B,且从cube tag->id 的字典中删除掉B。可能会错误的删除掉B',导致两个map的对应不一致。 +// calibrate 继续,同步master[1],replica[1]不存在,创建新的cube。此时,不仅从id->cube 的数组中删除掉B,且从cube field->id 的字典中删除掉B。可能会错误的删除掉B',导致两个map的对应不一致。 // replica:B' / (B ) // 例如:find_cube(B)-> 返回1。 @@ -501,8 +502,8 @@ TEST(calibrate, master_many_cube) TEST(calibrate, issue_calibrate_wrong) { struct fieldstat *master = fieldstat_new(); - const struct fieldstat_tag *tag_A = &TEST_SHARED_TAG; - const struct fieldstat_tag *tag_B = &TEST_TAG_INT; + const struct field *tag_A = &TEST_SHARED_TAG; + const struct field *tag_B = &TEST_TAG_INT; int cube_idA = fieldstat_create_cube(master, tag_A, 1, SAMPLING_MODE_COMPREHENSIVE, 1); int cube_idB = fieldstat_create_cube(master, tag_B, 1, SAMPLING_MODE_COMPREHENSIVE, 1); struct fieldstat *target = fieldstat_fork(master); @@ -521,8 +522,8 @@ TEST(calibrate, issue_calibrate_wrong) EXPECT_EQ(fieldstat_find_cube(target, tag_A, 1), FS_ERR_INVALID_KEY); EXPECT_EQ(fieldstat_find_cube(target, tag_B, 1), cubes_id_ret[0]); - struct fieldstat_tag_list *tag_list = fieldstat_cube_get_tags(target, cubes_id_ret[0]); - EXPECT_STREQ(tag_list->tag[0].key, tag_B->key); + struct field_list *tag_list = fieldstat_cube_get_tags(target, cubes_id_ret[0]); + EXPECT_STREQ(tag_list->field[0].key, tag_B->key); fieldstat_tag_list_arr_free(tag_list, 1); fieldstat_free(master); @@ -533,8 +534,8 @@ TEST(calibrate, issue_calibrate_wrong) TEST(calibrate, delete_first_cube) { struct fieldstat *master = fieldstat_new(); - const struct fieldstat_tag *tag_A = &TEST_SHARED_TAG; - const struct fieldstat_tag *tag_B = &TEST_TAG_INT; + const struct field *tag_A = &TEST_SHARED_TAG; + const struct field *tag_B = &TEST_TAG_INT; int cube_idA = fieldstat_create_cube(master, tag_A, 1, SAMPLING_MODE_COMPREHENSIVE, 1); int cube_idB = fieldstat_create_cube(master, tag_B, 1, SAMPLING_MODE_COMPREHENSIVE, 1); struct fieldstat *target = fieldstat_fork(master); @@ -553,8 +554,8 @@ TEST(calibrate, delete_first_cube) EXPECT_EQ(fieldstat_find_cube(target, tag_A, 1), FS_ERR_INVALID_KEY); EXPECT_EQ(fieldstat_find_cube(target, tag_B, 1), 1); - struct fieldstat_tag_list *tag_list = fieldstat_cube_get_tags(target, 1); - EXPECT_STREQ(tag_list->tag[0].key, tag_B->key); + struct field_list *tag_list = fieldstat_cube_get_tags(target, 1); + EXPECT_STREQ(tag_list->field[0].key, tag_B->key); fieldstat_tag_list_arr_free(tag_list, 1); fieldstat_free(master); diff --git a/test/test_write_json_file.cpp b/test/test_write_json_file.cpp index f4dd7f8..1b5fd5f 100644 --- a/test/test_write_json_file.cpp +++ b/test/test_write_json_file.cpp @@ -24,8 +24,8 @@ extern "C" { [[gnu::unused]] static struct fieldstat_easy *get_hist_fieldstat_easy() { - struct fieldstat_tag global_tags[2]; - struct fieldstat_tag cell_tags[2]; + struct field global_tags[2]; + struct field cell_tags[2]; global_tags[0].key = "rule_id"; global_tags[0].type = TAG_INTEGER; @@ -59,7 +59,7 @@ extern "C" { } static void write_hll(struct fieldstat *instance) { - struct fieldstat_tag shared_tags[1]; + struct field shared_tags[1]; shared_tags[0].key = "rule_id"; shared_tags[0].type = TAG_INTEGER; @@ -85,8 +85,8 @@ static void write_hll(struct fieldstat *instance) { } void write_histogram(struct fieldstat *instance) { - struct fieldstat_tag shared_tags[2]; - struct fieldstat_tag cell_tags[2]; + struct field shared_tags[2]; + struct field cell_tags[2]; shared_tags[0].key = "rule_id"; shared_tags[0].type = TAG_INTEGER; @@ -123,8 +123,8 @@ void write_histogram(struct fieldstat *instance) { // static struct fieldstat_easy *get_table_fieldstat_easy() // { -// struct fieldstat_tag global_tags[2]; -// struct fieldstat_tag cell_tags; +// struct field global_tags[2]; +// struct field cell_tags; // global_tags[0].key = "policy_id"; // global_tags[0].type = TAG_INTEGER; @@ -166,7 +166,7 @@ void fieldstat_easy_to_file(struct fieldstat_easy *fse, const char *file_path) } void write_table(struct fieldstat *instance) { - struct fieldstat_tag shared_tags[2]; + struct field shared_tags[2]; shared_tags[0].key = "policy_id"; shared_tags[0].type = TAG_INTEGER; shared_tags[0].value_longlong = 1; @@ -180,7 +180,7 @@ void write_table(struct fieldstat *instance) { "GTPC-RECORD", "BGP-RECORD", "PROXY-EVENT", "DOS-SKETCH-RECORD", "STATISTICS-RULE-METRIC", "OBJECT-STATISTICS-METRIC"}; - struct fieldstat_tag cell_tags; + struct field cell_tags; cell_tags.key = "send_log"; cell_tags.type = TAG_CSTRING; cell_tags.value_str = "true"; diff --git a/test/utils.cpp b/test/utils.cpp index b53e4e4..7fa9825 100644 --- a/test/utils.cpp +++ b/test/utils.cpp @@ -32,24 +32,24 @@ string gen_rand_string(int len) /* taglist wrapper */ /* -------------------------------------------------------------------------- */ -Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const struct fieldstat_tag_list *tag_list) { - tag_list_c.tag = (struct fieldstat_tag *)malloc(sizeof(struct fieldstat_tag) * tag_list->n_tag); - tag_list_c.n_tag = tag_list->n_tag; - for (size_t i = 0; i < tag_list->n_tag; i++) +Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const struct field_list *tag_list) { + tag_list_c.field = (struct field *)malloc(sizeof(struct field) * tag_list->n_field); + tag_list_c.n_field = tag_list->n_field; + for (size_t i = 0; i < tag_list->n_field; i++) { // copy the tag_list - tag_list_c.tag[i].key = strdup(tag_list->tag[i].key); - tag_list_c.tag[i].type = tag_list->tag[i].type; - switch (tag_list->tag[i].type) + tag_list_c.field[i].key = strdup(tag_list->field[i].key); + tag_list_c.field[i].type = tag_list->field[i].type; + switch (tag_list->field[i].type) { case TAG_INTEGER: - tag_list_c.tag[i].value_longlong = tag_list->tag[i].value_longlong; + tag_list_c.field[i].value_longlong = tag_list->field[i].value_longlong; break; case TAG_DOUBLE: - tag_list_c.tag[i].value_double = tag_list->tag[i].value_double; + tag_list_c.field[i].value_double = tag_list->field[i].value_double; break; case TAG_CSTRING: - tag_list_c.tag[i].value_str = strdup(tag_list->tag[i].value_str); + tag_list_c.field[i].value_str = strdup(tag_list->field[i].value_str); break; default: break; @@ -59,84 +59,84 @@ Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const struct fieldstat_ta Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const char * key, int value) { - tag_list_c.tag = (struct fieldstat_tag *)malloc(sizeof(struct fieldstat_tag)); - tag_list_c.n_tag = 1; - tag_list_c.tag[0].key = strdup(key); - tag_list_c.tag[0].type = TAG_INTEGER; - tag_list_c.tag[0].value_longlong = value; + tag_list_c.field = (struct field *)malloc(sizeof(struct field)); + tag_list_c.n_field = 1; + tag_list_c.field[0].key = strdup(key); + tag_list_c.field[0].type = TAG_INTEGER; + tag_list_c.field[0].value_longlong = value; } Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const char * key, const char *value) { - tag_list_c.tag = (struct fieldstat_tag *)malloc(sizeof(struct fieldstat_tag)); - tag_list_c.n_tag = 1; - tag_list_c.tag[0].key = strdup(key); - tag_list_c.tag[0].type = TAG_CSTRING; - tag_list_c.tag[0].value_str = strdup(value); + tag_list_c.field = (struct field *)malloc(sizeof(struct field)); + tag_list_c.n_field = 1; + tag_list_c.field[0].key = strdup(key); + tag_list_c.field[0].type = TAG_CSTRING; + tag_list_c.field[0].value_str = strdup(value); } Fieldstat_tag_list_wrapper::~Fieldstat_tag_list_wrapper() { - for (size_t i = 0; i < tag_list_c.n_tag; i++) { - free((char *)tag_list_c.tag[i].key); - if (tag_list_c.tag[i].type == TAG_CSTRING) { - free((char *)tag_list_c.tag[i].value_str); + for (size_t i = 0; i < tag_list_c.n_field; i++) { + free((char *)tag_list_c.field[i].key); + if (tag_list_c.field[i].type == TAG_CSTRING) { + free((char *)tag_list_c.field[i].value_str); } } - free(tag_list_c.tag); + free(tag_list_c.field); } Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(std::uniform_int_distribution &dist, int tag_count) { - tag_list_c.tag = (struct fieldstat_tag *)malloc(sizeof(struct fieldstat_tag) * tag_count); - tag_list_c.n_tag = tag_count; + tag_list_c.field = (struct field *)malloc(sizeof(struct field) * tag_count); + tag_list_c.n_field = tag_count; std::mt19937 rng(1); for (int i = 0; i < tag_count; i++) { - tag_list_c.tag[i].key = strdup(gen_rand_string(10).c_str()); + tag_list_c.field[i].key = strdup(gen_rand_string(10).c_str()); int rand_ret = rand() % 3; if (rand_ret == 0) { - tag_list_c.tag[i].type = TAG_INTEGER; - tag_list_c.tag[i].value_longlong = static_cast(dist(rng)); + tag_list_c.field[i].type = TAG_INTEGER; + tag_list_c.field[i].value_longlong = static_cast(dist(rng)); } else if (rand_ret == 1) { - tag_list_c.tag[i].type = TAG_DOUBLE; - tag_list_c.tag[i].value_double = static_cast(dist(rng)) + 0.5; + tag_list_c.field[i].type = TAG_DOUBLE; + tag_list_c.field[i].value_double = static_cast(dist(rng)) + 0.5; } else { - tag_list_c.tag[i].type = TAG_CSTRING; - tag_list_c.tag[i].value_str = strdup(gen_rand_string(10).c_str()); + tag_list_c.field[i].type = TAG_CSTRING; + tag_list_c.field[i].value_str = strdup(gen_rand_string(10).c_str()); } } } Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper() { - tag_list_c.tag = NULL; - tag_list_c.n_tag = 0; + tag_list_c.field = NULL; + tag_list_c.n_field = 0; } Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const Fieldstat_tag_list_wrapper &tag_list_wrapper){ - const struct fieldstat_tag_list *tag_list = tag_list_wrapper.get_c_struct(); - tag_list_c.tag = (struct fieldstat_tag *)malloc(sizeof(struct fieldstat_tag) * tag_list->n_tag); - tag_list_c.n_tag = tag_list->n_tag; - for (size_t i = 0; i < tag_list->n_tag; i++) + const struct field_list *tag_list = tag_list_wrapper.get_c_struct(); + tag_list_c.field = (struct field *)malloc(sizeof(struct field) * tag_list->n_field); + tag_list_c.n_field = tag_list->n_field; + for (size_t i = 0; i < tag_list->n_field; i++) { // copy the tag_list - tag_list_c.tag[i].key = strdup(tag_list->tag[i].key); - tag_list_c.tag[i].type = tag_list->tag[i].type; - switch (tag_list->tag[i].type) + tag_list_c.field[i].key = strdup(tag_list->field[i].key); + tag_list_c.field[i].type = tag_list->field[i].type; + switch (tag_list->field[i].type) { case TAG_INTEGER: - tag_list_c.tag[i].value_longlong = tag_list->tag[i].value_longlong; + tag_list_c.field[i].value_longlong = tag_list->field[i].value_longlong; break; case TAG_DOUBLE: - tag_list_c.tag[i].value_double = tag_list->tag[i].value_double; + tag_list_c.field[i].value_double = tag_list->field[i].value_double; break; case TAG_CSTRING: - tag_list_c.tag[i].value_str = strdup(tag_list->tag[i].value_str); + tag_list_c.field[i].value_str = strdup(tag_list->field[i].value_str); break; default: break; @@ -144,38 +144,38 @@ Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const Fieldstat_tag_list_ } } -const struct fieldstat_tag *Fieldstat_tag_list_wrapper::get_tag() const +const struct field *Fieldstat_tag_list_wrapper::get_tag() const { - return tag_list_c.tag; + return tag_list_c.field; } size_t Fieldstat_tag_list_wrapper::get_tag_count() const { - return tag_list_c.n_tag; + return tag_list_c.n_field; } -const struct fieldstat_tag_list *Fieldstat_tag_list_wrapper::get_c_struct() const +const struct field_list *Fieldstat_tag_list_wrapper::get_c_struct() const { return &tag_list_c; } void Fieldstat_tag_list_wrapper::print_tag_list() const { - printf("tag_list_c.n_tag: %zu\n", tag_list_c.n_tag); - for (size_t i = 0; i < tag_list_c.n_tag; i++) + printf("tag_list_c.n_field: %zu\n", tag_list_c.n_field); + for (size_t i = 0; i < tag_list_c.n_field; i++) { - printf("tag_list_c.tag[%zu].key: %s\n", i, tag_list_c.tag[i].key); - printf("tag_list_c.tag[%zu].type: %d\n", i, (int)tag_list_c.tag[i].type); - switch (tag_list_c.tag[i].type) + printf("tag_list_c.field[%zu].key: %s\n", i, tag_list_c.field[i].key); + printf("tag_list_c.field[%zu].type: %d\n", i, (int)tag_list_c.field[i].type); + switch (tag_list_c.field[i].type) { case TAG_INTEGER: - printf("tag_list_c.tag[%zu].value_longlong: %lld\n", i, tag_list_c.tag[i].value_longlong); + printf("tag_list_c.field[%zu].value_longlong: %lld\n", i, tag_list_c.field[i].value_longlong); break; case TAG_DOUBLE: - printf("tag_list_c.tag[%zu].value_double: %lf\n", i, tag_list_c.tag[i].value_double); + printf("tag_list_c.field[%zu].value_double: %lf\n", i, tag_list_c.field[i].value_double); break; case TAG_CSTRING: - printf("tag_list_c.tag[%zu].value_str: %s\n", i, tag_list_c.tag[i].value_str); + printf("tag_list_c.field[%zu].value_str: %s\n", i, tag_list_c.field[i].value_str); break; default: break; @@ -187,20 +187,20 @@ void Fieldstat_tag_list_wrapper::print_tag_list() const string Fieldstat_tag_list_wrapper::to_string() const { string str = ""; - for (size_t i = 0; i < tag_list_c.n_tag; i++) + for (size_t i = 0; i < tag_list_c.n_field; i++) { - str += tag_list_c.tag[i].key; + str += tag_list_c.field[i].key; str += ":"; - switch (tag_list_c.tag[i].type) + switch (tag_list_c.field[i].type) { case TAG_INTEGER: - str += std::to_string(tag_list_c.tag[i].value_longlong); + str += std::to_string(tag_list_c.field[i].value_longlong); break; case TAG_DOUBLE: - str += std::to_string(tag_list_c.tag[i].value_double); + str += std::to_string(tag_list_c.field[i].value_double); break; case TAG_CSTRING: - str += tag_list_c.tag[i].value_str; + str += tag_list_c.field[i].value_str; break; default: break; @@ -212,30 +212,30 @@ string Fieldstat_tag_list_wrapper::to_string() const bool Fieldstat_tag_list_wrapper::operator==(const Fieldstat_tag_list_wrapper &tag_list_wrapper) const { - const struct fieldstat_tag_list *tag_list = tag_list_wrapper.get_c_struct(); - if (tag_list_c.n_tag != tag_list->n_tag) { + const struct field_list *tag_list = tag_list_wrapper.get_c_struct(); + if (tag_list_c.n_field != tag_list->n_field) { return false; } - for (size_t i = 0; i < tag_list_c.n_tag; i++) { - if (strcmp((char *)tag_list_c.tag[i].key, (char *)tag_list->tag[i].key) != 0) { + for (size_t i = 0; i < tag_list_c.n_field; i++) { + if (strcmp((char *)tag_list_c.field[i].key, (char *)tag_list->field[i].key) != 0) { return false; } - if (tag_list_c.tag[i].type != tag_list->tag[i].type) { + if (tag_list_c.field[i].type != tag_list->field[i].type) { return false; } - switch (tag_list_c.tag[i].type) { + switch (tag_list_c.field[i].type) { case TAG_INTEGER: - if (tag_list_c.tag[i].value_longlong != tag_list->tag[i].value_longlong) { + if (tag_list_c.field[i].value_longlong != tag_list->field[i].value_longlong) { return false; } break; case TAG_DOUBLE: - if (tag_list_c.tag[i].value_double != tag_list->tag[i].value_double) { + if (tag_list_c.field[i].value_double != tag_list->field[i].value_double) { return false; } break; case TAG_CSTRING: - if (strcmp((char *)tag_list_c.tag[i].value_str, (char *)tag_list->tag[i].value_str) != 0) { + if (strcmp((char *)tag_list_c.field[i].value_str, (char *)tag_list->field[i].value_str) != 0) { return false; } break; @@ -248,7 +248,7 @@ bool Fieldstat_tag_list_wrapper::operator==(const Fieldstat_tag_list_wrapper &ta Fieldstat_tag_list_wrapper& Fieldstat_tag_list_wrapper::sort_tag_list() { - std::sort(tag_list_c.tag, tag_list_c.tag + tag_list_c.n_tag, [](const struct fieldstat_tag &a, const struct fieldstat_tag &b) { + std::sort(tag_list_c.field, tag_list_c.field + tag_list_c.n_field, [](const struct field &a, const struct field &b) { return strcmp((char *)a.key, (char *)b.key) < 0; }); return *this; diff --git a/test/utils.hpp b/test/utils.hpp index 28dea2b..f414de9 100644 --- a/test/utils.hpp +++ b/test/utils.hpp @@ -3,16 +3,16 @@ #include #include "fieldstat.h" -const struct fieldstat_tag TEST_TAG_STRING = {"STRING KEY_", TAG_CSTRING, {.value_str = "100.1"}}; -const struct fieldstat_tag_list TEST_TAG_LIST_STRING = {(struct fieldstat_tag *)&TEST_TAG_STRING, 1}; -const struct fieldstat_tag TEST_TAG_STRING_collided = {"collided", TAG_CSTRING, {.value_str = "2"}}; -const struct fieldstat_tag TEST_TAG_INT = {"INT key_", TAG_INTEGER, {.value_longlong = 100}}; -const struct fieldstat_tag_list TEST_TAG_LIST_INT = {(struct fieldstat_tag *)&TEST_TAG_INT, 1}; -const struct fieldstat_tag TEST_TAG_INT_collided = {"collided", TAG_INTEGER, {.value_longlong = 2}}; -const struct fieldstat_tag TEST_TAG_DOUBLE = {"DOUBLE key_", TAG_DOUBLE, {.value_double = 100.1}}; -const struct fieldstat_tag_list TEST_TAG_LIST_DOUBLE = {(struct fieldstat_tag *)&TEST_TAG_DOUBLE, 1}; -const struct fieldstat_tag TEST_TAG_DOUBLE_collided = {"collided", TAG_DOUBLE, {.value_double = 2.0}}; -const struct fieldstat_tag TEST_SHARED_TAG = {"shared", TAG_INTEGER, {.value_longlong = 1}}; +const struct field TEST_TAG_STRING = {"STRING KEY_", TAG_CSTRING, {.value_str = "100.1"}}; +const struct field_list TEST_TAG_LIST_STRING = {(struct field *)&TEST_TAG_STRING, 1}; +const struct field TEST_TAG_STRING_collided = {"collided", TAG_CSTRING, {.value_str = "2"}}; +const struct field TEST_TAG_INT = {"INT key_", TAG_INTEGER, {.value_longlong = 100}}; +const struct field_list TEST_TAG_LIST_INT = {(struct field *)&TEST_TAG_INT, 1}; +const struct field TEST_TAG_INT_collided = {"collided", TAG_INTEGER, {.value_longlong = 2}}; +const struct field TEST_TAG_DOUBLE = {"DOUBLE key_", TAG_DOUBLE, {.value_double = 100.1}}; +const struct field_list TEST_TAG_LIST_DOUBLE = {(struct field *)&TEST_TAG_DOUBLE, 1}; +const struct field TEST_TAG_DOUBLE_collided = {"collided", TAG_DOUBLE, {.value_double = 2.0}}; +const struct field TEST_SHARED_TAG = {"shared", TAG_INTEGER, {.value_longlong = 1}}; const struct timeval TEST_TIMEVAL = {100, 10000}; const long long TEST_TIMEVAL_LONG = 100010; // 100s * 1000 + 10000us / 1000 = 100010ms @@ -20,7 +20,7 @@ std::string gen_rand_string(int len); class Fieldstat_tag_list_wrapper { public: - explicit Fieldstat_tag_list_wrapper(const struct fieldstat_tag_list *tag_list_c); + explicit Fieldstat_tag_list_wrapper(const struct field_list *tag_list_c); explicit Fieldstat_tag_list_wrapper(const char * key, int value); explicit Fieldstat_tag_list_wrapper(const char * key, const char *value); explicit Fieldstat_tag_list_wrapper(std::uniform_int_distribution &dist, int tag_count); @@ -31,13 +31,13 @@ public: ~Fieldstat_tag_list_wrapper(); bool operator==(const Fieldstat_tag_list_wrapper &tag_list_wrapper) const; - const struct fieldstat_tag *get_tag() const; + const struct field *get_tag() const; size_t get_tag_count() const; - const struct fieldstat_tag_list *get_c_struct() const; + const struct field_list *get_c_struct() const; void print_tag_list() const; Fieldstat_tag_list_wrapper& sort_tag_list(); private: - struct fieldstat_tag_list tag_list_c; + struct field_list tag_list_c; }; -- cgit v1.2.3 From 58e206384b2b8e4afb63284f471a64f3b6fe424a Mon Sep 17 00:00:00 2001 From: chenzizhan Date: Fri, 12 Jul 2024 14:02:33 +0800 Subject: register metric to cube --- include/fieldstat/fieldstat.h | 12 +- src/cube.c | 314 +++++++++++++++++++++++++++++++++------ src/cube.h | 27 +++- src/exporter/cjson_exporter.c | 11 +- src/fieldstat.c | 283 ++++++----------------------------- src/fieldstat_easy.c | 16 +- test/test_easy_fs.cpp | 2 +- test/test_empty_tags.cpp | 6 +- test/test_exporter_json.cpp | 72 ++++----- test/test_fuzz_test.cpp | 22 ++- test/test_merge.cpp | 111 +++++--------- test/test_metric_counter.cpp | 16 +- test/test_metric_histogram.cpp | 8 +- test/test_metric_hll.cpp | 8 +- test/test_performance.cpp | 41 +++-- test/test_register_and_reset.cpp | 97 ++++++------ test/test_write_json_file.cpp | 8 +- 17 files changed, 528 insertions(+), 526 deletions(-) (limited to 'test/test_write_json_file.cpp') diff --git a/include/fieldstat/fieldstat.h b/include/fieldstat/fieldstat.h index 92e8ceb..f9dcfda 100644 --- a/include/fieldstat/fieldstat.h +++ b/include/fieldstat/fieldstat.h @@ -90,14 +90,14 @@ int fieldstat_destroy_cube(struct fieldstat *instance, int cube_id); * @param metric_name: name of the metric. Cannot be NULL. Must be unique. * @return metric id>=0 if success. If failed, return FS_ERR_NULL_HANDLER, FS_ERR_INVALID_KEY(when metric_name is not unique in this cube) */ -int fieldstat_register_counter(struct fieldstat *instance, const char *metric_name); +int fieldstat_register_counter(struct fieldstat *instance, int cube_id, const char *metric_name); /* * @brief refer to fieldstat_register_counter. * @param precision: the bigger, the larger memory consumption, while accuracy improved. Must be in [4, 18]. * @return metric id if success. If failed, return FS_ERR_NULL_HANDLER, FS_ERR_INVALID_KEY(when metric_name is not unique in this cube), or FS_ERR_INVALID_PARAM(if precision not in range) */ -int fieldstat_register_hll(struct fieldstat *instance, const char *metric_name, unsigned char precision); +int fieldstat_register_hll(struct fieldstat *instance, int cube_id, const char *metric_name, unsigned char precision); /* * @brief refer to fieldstat_register_counter. @@ -106,7 +106,7 @@ int fieldstat_register_hll(struct fieldstat *instance, const char *metric_name, * @param significant_figures: the precision of the histogram. Must be in [1, 5]. * @return metric id if success. If failed, return FS_ERR_NULL_HANDLER, FS_ERR_INVALID_KEY(when metric_name is not unique in this cube), or FS_ERR_INVALID_PARAM(if any of the 3 params are out of range) */ -int fieldstat_register_hist(struct fieldstat *instance, const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures); +int fieldstat_register_hist(struct fieldstat *instance, int cube_id, const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures); /* * @brief let the value of counter metric of cell_id increase by `increment`. @@ -180,15 +180,15 @@ void fieldstat_get_cubes(const struct fieldstat *instance, int **cube_ids, int * /* * @brief Get all the registered metrics by fieldstat_register_counter, fieldstat_register_hll, fieldstat_register_hist. */ -void fieldstat_get_metrics(const struct fieldstat *instance, int **metric_id_out, size_t *n_metric); +void fieldstat_cube_get_metrics(const struct fieldstat *instance, int cube_id, int **metric_id_out, size_t *n_metric); void fieldstat_get_metric_in_cell(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int **metric_id_out, size_t *n_metric_out); // query the name of the metric, return NULL if metric_id is invalid. -const char *fieldstat_get_metric_name(const struct fieldstat *instance, int metric_id); +const char *fieldstat_get_metric_name(const struct fieldstat *instance, int cube_id, int metric_id); // query the type of the metric. return (enum metric_type)-1 if metric_id is invalid. -enum metric_type fieldstat_get_metric_type(const struct fieldstat *instance, int metric_id); +enum metric_type fieldstat_get_metric_type(const struct fieldstat *instance, int cube_id, int metric_id); /* get the cell_dimensions added to cube when calling fieldstat_counter_incrby, fieldstat_counter_set, fieldstat_hll_add, fieldstat_hist_record. diff --git a/src/cube.c b/src/cube.c index a01b775..71e2acd 100644 --- a/src/cube.c +++ b/src/cube.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "uthash.h" #define XXH_INLINE_ALL @@ -46,7 +47,8 @@ struct cube { struct spread_sketch *spread_sketch; }; size_t max_n_cell; - + struct metric_manifest_manager *manifest_manager; + struct field *cube_dimensions; size_t n_dimensions; @@ -95,20 +97,20 @@ static void fieldstat_free_tag_array(struct field *fields, size_t n_tags) free(fields); } -void add_cube_to_position(struct cube_manager *instance, struct cube *cube, int id) +void add_cube_to_position(struct cube_manager *pthis, struct cube *cube, int id) { - if (id >= instance->cube_size) { - struct cube **old_cube_arr = instance->cube; - instance->cube = calloc(instance->cube_size * 2, sizeof(struct cube *)); - memcpy(instance->cube, old_cube_arr, sizeof(struct cube *) * instance->cube_size); + if (id >= pthis->cube_size) { + struct cube **old_cube_arr = pthis->cube; + pthis->cube = calloc(pthis->cube_size * 2, sizeof(struct cube *)); + memcpy(pthis->cube, old_cube_arr, sizeof(struct cube *) * pthis->cube_size); free(old_cube_arr); - instance->cube_size *= 2; + pthis->cube_size *= 2; } - instance->cube[id] = cube; + pthis->cube[id] = cube; - if (id >= instance->cube_cnt) { - instance->cube_cnt = id + 1; + if (id >= pthis->cube_cnt) { + pthis->cube_cnt = id + 1; } } @@ -356,12 +358,15 @@ void cube_manager_calibrate(struct cube_manager *pthis, const struct cube_manage { struct cube *node_in_master, *node_in_dest, *tmp; - // exist in self but not in master + HASH_ITER(hh, pthis->hash_table, node_in_dest, tmp) { HASH_FIND(hh, master->hash_table, node_in_dest->key, node_in_dest->key_len, node_in_master); - if (node_in_master == NULL) { + if (node_in_master == NULL) { // exist in self but not in master cube_manager_delete(pthis, node_in_dest); + } else { + metric_manifest_manager_free(node_in_dest->manifest_manager); + node_in_dest->manifest_manager = metric_manifest_manager_copy(node_in_master->manifest_manager); } } @@ -373,6 +378,14 @@ void cube_manager_calibrate(struct cube_manager *pthis, const struct cube_manage cube_manager_add(pthis, cube_fork(node_in_master)); } } + + // for (int i = 0; i < pthis->cube_cnt; i++) { + // if (pthis->cube[i] == NULL) { + // continue; + // } + // metric_manifest_manager_free(pthis->cube[i]->manifest_manager); + // pthis->cube[i]->manifest_manager = metric_manifest_manager_copy(master->cube[i]->manifest_manager); + // } } struct cube_manager *cube_manager_fork(const struct cube_manager *src) @@ -386,10 +399,11 @@ struct cube_manager *cube_manager_fork(const struct cube_manager *src) return pthis; } -void cube_manager_merge(struct cube_manager *dest, const struct cube_manager *src) +int cube_manager_merge(struct cube_manager *dest, const struct cube_manager *src) { struct cube *node = NULL; struct cube *tmp = NULL; + int ret = FS_OK; HASH_ITER(hh, src->hash_table, node, tmp) { struct cube *node_in_dest = NULL; HASH_FIND(hh, dest->hash_table, node->key, node->key_len, node_in_dest); @@ -397,9 +411,14 @@ void cube_manager_merge(struct cube_manager *dest, const struct cube_manager *sr if (node_in_dest == NULL) { cube_manager_add(dest, cube_copy(node)); } else { - cube_merge(node_in_dest, node); + int tmp_ret = cube_merge(node_in_dest, node); + if (tmp_ret != FS_OK) { + ret = tmp_ret; + } } } + + return ret; } void cube_manager_reset(struct cube_manager *pthis) @@ -561,6 +580,7 @@ struct cube *cube_info_new(const struct field *dimensions, size_t n_dimensions, struct cube *cube_new(const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, size_t max_n_cell) { struct cube *cube = cube_info_new(dimensions, n_dimensions, mode, max_n_cell); + cube->manifest_manager = metric_manifest_manager_new(); switch (mode) { @@ -603,6 +623,7 @@ void cube_free(struct cube *cube) { fieldstat_free_tag_array(cube->cube_dimensions, cube->n_dimensions); free(cube->key); + metric_manifest_manager_free(cube->manifest_manager); free(cube); } @@ -630,8 +651,18 @@ void cube_reset(struct cube *cube) { } } -void cube_set_primary_metric(struct cube *cube, int metric_id) { +int cube_set_primary_metric(struct cube *cube, int metric_id) { + const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); + if (manifest == NULL) { + return FS_ERR_INVALID_METRIC_ID; + } + if (cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || + (cube->sampling_mode == SAMPLING_MODE_TOPK && manifest->type != METRIC_TYPE_COUNTER) || + (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && manifest->type != METRIC_TYPE_HLL)) { + return FS_ERR_INVALID_PARAM; + } cube->primary_metric_id = metric_id; + return FS_OK; } struct cell *get_cell_in_comprehensive_cube(struct cube *cube, const struct field *dimensions, size_t n_dimension) { @@ -754,10 +785,106 @@ struct cell *get_cell_in_spread_sketch_cube(struct cube *cube, const struct fiel return cell_data; } +union metric_parameter *construct_parameters(enum metric_type type, ...) +{ + union metric_parameter *paras = (union metric_parameter *)malloc(sizeof(union metric_parameter)); + va_list ap; + va_start(ap, type); + switch (type) { + case METRIC_TYPE_COUNTER: + break; + case METRIC_TYPE_HLL: + paras->hll.precision = (char)va_arg(ap, int); + break; + case METRIC_TYPE_HISTOGRAM: + paras->hdr.lowest_trackable_value = va_arg(ap, long long); + paras->hdr.highest_trackable_value = va_arg(ap, long long); + paras->hdr.significant_figures = va_arg(ap, int); + break; + default: + assert(0); + } + va_end(ap); + return paras; +} + +int cube_register_counter(struct cube *cube, const char *metric_name) { + struct metric_manifest *metric = malloc(sizeof(struct metric_manifest)); + metric->name = strdup(metric_name); + metric->parameters = construct_parameters(METRIC_TYPE_COUNTER); + metric->type = METRIC_TYPE_COUNTER; + + int id = metric_manifest_manager_add(cube->manifest_manager, metric); + if (id < 0) { + free(metric->name); + free(metric->parameters); + free(metric); + return FS_ERR_INVALID_KEY; + } -int cube_histogram_record(struct cube *cube, const struct metric_manifest *manifest, const struct field *dimensions, size_t n_dimensions, long long value) { - assert(manifest->type == METRIC_TYPE_HISTOGRAM); - assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->primary_metric_id != manifest->id)); + metric->id = id; + return id; +} + +int cube_register_hll(struct cube *cube,const char *metric_name, unsigned char precision) { + if (precision < 4 || precision > 18) { + return FS_ERR_INVALID_PARAM; + } + + struct metric_manifest *metric = malloc(sizeof(struct metric_manifest)); + metric->name = strdup(metric_name); + metric->parameters = construct_parameters(METRIC_TYPE_HLL, precision); + metric->type = METRIC_TYPE_HLL; + + int id = metric_manifest_manager_add(cube->manifest_manager, metric); + if (id < 0) { + free(metric->name); + free(metric->parameters); + free(metric); + return FS_ERR_INVALID_KEY; + } + + metric->id = id; + return id; +} + +int cube_register_hist(struct cube *cube,const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures) { + // refer to hdr_histogram.h for the rules of parameters. Just copy them here + if (lowest_trackable_value < 1) { + return FS_ERR_INVALID_PARAM; + } + if (significant_figures < 1 || significant_figures > 5) { + return FS_ERR_INVALID_PARAM; + } + if (lowest_trackable_value * 2 > highest_trackable_value) + { + return FS_ERR_INVALID_PARAM; + } + + struct metric_manifest *metric = malloc(sizeof(struct metric_manifest)); + metric->name = strdup(metric_name); + metric->parameters = construct_parameters(METRIC_TYPE_HISTOGRAM, lowest_trackable_value, highest_trackable_value, significant_figures); + metric->type = METRIC_TYPE_HISTOGRAM; + + int id = metric_manifest_manager_add(cube->manifest_manager, metric); + if (id < 0) { + free(metric->name); + free(metric->parameters); + free(metric); + return FS_ERR_INVALID_KEY; + } + metric->id = id; + + return id; +} + +int cube_histogram_record(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, long long value) { + assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->primary_metric_id != metric_id)); + + const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); + if (manifest == NULL || manifest->type != METRIC_TYPE_HISTOGRAM) { + return FS_ERR_INVALID_METRIC_ID; + } struct cell *cell_data = NULL; switch (cube->sampling_mode) { @@ -765,10 +892,10 @@ int cube_histogram_record(struct cube *cube, const struct metric_manifest *manif cell_data = get_cell_in_comprehensive_cube(cube, dimensions, n_dimensions); break;} case SAMPLING_MODE_TOPK: { - cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, manifest->id); + cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} case SAMPLING_MODE_SPREADSKETCH: { - cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, 0, manifest->id); + cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} default: assert(0); @@ -787,12 +914,16 @@ int cube_histogram_record(struct cube *cube, const struct metric_manifest *manif return FS_OK; } -int cube_hll_add(struct cube *cube, const struct metric_manifest *manifest, const struct field *dimensions, size_t n_dimensions, const char *key, size_t key_len) { - assert(manifest->type == METRIC_TYPE_HLL); - assert(cube->sampling_mode != SAMPLING_MODE_TOPK || cube->primary_metric_id != manifest->id); +int cube_hll_add(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, const char *key, size_t key_len) { + assert(cube->sampling_mode != SAMPLING_MODE_TOPK || cube->primary_metric_id != metric_id); + + const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); + if (manifest == NULL || manifest->type != METRIC_TYPE_HLL) { + return FS_ERR_INVALID_METRIC_ID; + } uint64_t hash = 0; // just any value, if we do not need to update the primary metric of spread sketch cube, hash value is not used - if (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && cube->primary_metric_id == manifest->id) { + if (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && cube->primary_metric_id == metric_id) { hash = XXH3_64bits(key, key_len); } struct cell *cell_data = NULL; @@ -801,10 +932,10 @@ int cube_hll_add(struct cube *cube, const struct metric_manifest *manifest, cons cell_data = get_cell_in_comprehensive_cube(cube, dimensions, n_dimensions); break;} case SAMPLING_MODE_TOPK: { - cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, manifest->id); + cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} case SAMPLING_MODE_SPREADSKETCH: { - cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, hash, manifest->id); + cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, hash, metric_id); break;} default: assert(0); @@ -835,13 +966,16 @@ uint64_t field_array_to_hash(const struct field *field, size_t n_dimensions) { return XXH3_64bits_digest(&state); } -int cube_hll_add_field(struct cube *cube, const struct metric_manifest *manifest, const struct field *dimensions, size_t n_dimensions, const struct field *tags_key, size_t n_tag_key) +int cube_hll_add_field(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, const struct field *tags_key, size_t n_tag_key) { - assert(manifest->type == METRIC_TYPE_HLL); - assert(cube->sampling_mode != SAMPLING_MODE_TOPK || (cube->primary_metric_id != manifest->id)); + assert(cube->sampling_mode != SAMPLING_MODE_TOPK || (cube->primary_metric_id != metric_id)); + const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); + if (manifest == NULL || manifest->type != METRIC_TYPE_HLL) { + return FS_ERR_INVALID_METRIC_ID; + } uint64_t hash = 0; // just any value, if we do not need to update the primary metric of spread sketch cube, hash value is not used - if (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && cube->primary_metric_id == manifest->id) { + if (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && cube->primary_metric_id == metric_id) { hash = field_array_to_hash(tags_key, n_tag_key); } struct cell *cell_data = NULL; @@ -850,10 +984,10 @@ int cube_hll_add_field(struct cube *cube, const struct metric_manifest *manifest cell_data = get_cell_in_comprehensive_cube(cube, dimensions, n_dimensions); break;} case SAMPLING_MODE_TOPK: { - cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, manifest->id); + cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} case SAMPLING_MODE_SPREADSKETCH: { - cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, hash, manifest->id); + cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, hash, metric_id); break;} default: assert(0); @@ -871,23 +1005,27 @@ int cube_hll_add_field(struct cube *cube, const struct metric_manifest *manifest return FS_OK; } -int cube_counter_incrby(struct cube *cube, const struct metric_manifest *manifest, const struct field *dimensions, size_t n_dimensions, long long increment) { - assert(manifest->type == METRIC_TYPE_COUNTER); +int cube_counter_incrby(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, long long increment) { assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || - (cube->sampling_mode == SAMPLING_MODE_TOPK && (cube->primary_metric_id != manifest->id || increment >= 0)) || - (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && cube->primary_metric_id != manifest->id) + (cube->sampling_mode == SAMPLING_MODE_TOPK && (cube->primary_metric_id != metric_id || increment >= 0)) || + (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && cube->primary_metric_id != metric_id) ); + const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); + if (manifest == NULL || manifest->type != METRIC_TYPE_COUNTER) { + return FS_ERR_INVALID_METRIC_ID; + } + struct cell *cell_data = NULL; switch (cube->sampling_mode) { case SAMPLING_MODE_COMPREHENSIVE: { cell_data = get_cell_in_comprehensive_cube(cube, dimensions, n_dimensions); break;} case SAMPLING_MODE_TOPK: { - cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, increment, manifest->id); + cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, increment, metric_id); break;} case SAMPLING_MODE_SPREADSKETCH: { - cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, 0, manifest->id); + cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} default: assert(0); @@ -904,9 +1042,13 @@ int cube_counter_incrby(struct cube *cube, const struct metric_manifest *manifes return FS_OK; } -int cube_counter_set(struct cube *cube, const struct metric_manifest *manifest, const struct field *dimensions, size_t n_dimensions, long long value) { - assert(manifest->type == METRIC_TYPE_COUNTER); - assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->primary_metric_id != manifest->id)); +int cube_counter_set(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, long long value) { + assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->primary_metric_id != metric_id)); + + const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); + if (manifest == NULL || manifest->type != METRIC_TYPE_COUNTER) { + return FS_ERR_INVALID_METRIC_ID; + } struct cell *cell_data = NULL; switch (cube->sampling_mode) { @@ -914,10 +1056,10 @@ int cube_counter_set(struct cube *cube, const struct metric_manifest *manifest, cell_data = get_cell_in_comprehensive_cube(cube, dimensions, n_dimensions); break;} case SAMPLING_MODE_TOPK: { - cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, manifest->id); + cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} case SAMPLING_MODE_SPREADSKETCH: { - cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, 0, manifest->id); + cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} default: assert(0); @@ -953,12 +1095,33 @@ struct cube *cube_copy(const struct cube *cube) break; } + cube_dup->manifest_manager = metric_manifest_manager_copy(cube->manifest_manager); + return cube_dup; } -void cube_merge(struct cube *dest, const struct cube *src) +int cube_merge(struct cube *dest, const struct cube *src) { - assert(dest->sampling_mode == src->sampling_mode); + if (dest->sampling_mode != src->sampling_mode) { + return FS_ERR_INVALID_PARAM; + } + + size_t n_metric_src = 0; + const struct metric_manifest **list_src = metric_manifest_manager_list(src->manifest_manager, &n_metric_src); + size_t n_metric_dst = 0; + const struct metric_manifest **list_dst = metric_manifest_manager_list(dest->manifest_manager, &n_metric_dst); + int len_min = n_metric_src < n_metric_dst ? n_metric_src : n_metric_dst; + for (int i = 0; i < len_min; i++) { + if (list_src[i]->type != list_dst[i]->type) { + return FS_ERR_INVALID_PARAM; + } + if (strcmp(list_src[i]->name, list_dst[i]->name) != 0) { + return FS_ERR_INVALID_PARAM; + } + } + for (int i = n_metric_dst; i < n_metric_src; i++) { + metric_manifest_manager_add(dest->manifest_manager, metric_manifest_copy(list_src[i])); + } switch (dest->sampling_mode) { @@ -975,15 +1138,39 @@ void cube_merge(struct cube *dest, const struct cube *src) assert(0); break; } + + return FS_OK; } struct cube *cube_fork(const struct cube *cube) { - struct cube *ret = cube_new(cube->cube_dimensions, cube->n_dimensions, cube->sampling_mode, cube->max_n_cell); + struct cube *ret = cube_info_new(cube->cube_dimensions, cube->n_dimensions, cube->sampling_mode, cube->max_n_cell); ret->primary_metric_id = cube->primary_metric_id; + ret->manifest_manager = metric_manifest_manager_copy(cube->manifest_manager); + switch (cube->sampling_mode) { + case SAMPLING_MODE_TOPK: + ret->topk = heavy_keeper_new(cube->max_n_cell); + heavy_keeper_set_exdata_schema(ret->topk, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); + break; + case SAMPLING_MODE_COMPREHENSIVE: + ret->comprehensive = hash_table_new(cube->max_n_cell); + hash_table_set_exdata_schema(ret->comprehensive, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); + break; + case SAMPLING_MODE_SPREADSKETCH: + ret->spread_sketch = spread_sketch_new(cube->max_n_cell); + spread_sketch_set_exdata_schema(ret->spread_sketch, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); + break; + default: + assert(0); + break; + } return ret; } +/* -------------------------------------------------------------------------- */ +/* query */ +/* -------------------------------------------------------------------------- */ + struct tmp_sorted_data_spread_sketch_cell { double hll_value; struct cell *data; @@ -1236,6 +1423,37 @@ struct field_list *cube_get_identifier(const struct cube *cube) { return tag_list; } -enum sampling_mode cube_get_sampling_mode(const struct cube *cube) { - return cube->sampling_mode; +const char *cube_get_metric_name(const struct cube *cube, int metric_id) { + const struct metric_manifest *metric = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); + if (metric == NULL) { + printf("metric is null\n"); + return NULL; + } + + return metric->name; +} + +enum metric_type cube_get_metric_type(const struct cube *cube, int metric_id) { + const struct metric_manifest *metric = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); + if (metric == NULL) { + return (enum metric_type)(-1); + } + + return metric->type; +} + +void cube_get_metrics(const struct cube *cube, int **metric_id_out, size_t *n_metric) +{ + const struct metric_manifest **list = metric_manifest_manager_list(cube->manifest_manager, n_metric); + if (*n_metric == 0) { + *metric_id_out = NULL; + return; + } + + int *tmp_ids = (int *)malloc(sizeof(int) * (*n_metric)); + *metric_id_out = tmp_ids; + + for (int i = 0; i < *n_metric; i++) { + tmp_ids[i] = list[i]->id; + } } diff --git a/src/cube.h b/src/cube.h index 6802b2d..8b6db1c 100644 --- a/src/cube.h +++ b/src/cube.h @@ -17,15 +17,20 @@ struct cube *cube_new(const struct field *dimensions, size_t n_dimensions, enum void cube_free(struct cube *cube); void cube_reset(struct cube *cube); struct cube *cube_copy(const struct cube *cube); -void cube_merge(struct cube *dest, const struct cube *src); +int cube_merge(struct cube *dest, const struct cube *src); struct cube *cube_fork(const struct cube *cube); // only copy the cube configurations, leave the cells empty -int cube_histogram_record(struct cube *cube, const struct metric_manifest *manifest, const struct field *dimensions, size_t n_dimensions, long long value); -int cube_hll_add(struct cube *cube, const struct metric_manifest *manifest, const struct field *dimensions, size_t n_dimensions, const char *key, size_t key_len); -int cube_hll_add_field(struct cube *cube, const struct metric_manifest *manifest, const struct field *dimensions, size_t n_dimensions, const struct field *tags_key, size_t n_tag_key); -int cube_counter_incrby(struct cube *cube, const struct metric_manifest *manifest, const struct field *dimensions, size_t n_dimensions, long long increment); -int cube_counter_set(struct cube *cube, const struct metric_manifest *manifest, const struct field *dimensions, size_t n_dimensions, long long value); +int cube_register_counter(struct cube *cube, const char *metric_name); +int cube_register_hll(struct cube *cube,const char *metric_name, unsigned char precision); +int cube_register_hist(struct cube *cube,const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures); +int cube_histogram_record(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, long long value); +int cube_hll_add(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, const char *key, size_t key_len); +int cube_hll_add_field(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, const struct field *tags_key, size_t n_tag_key); +int cube_counter_incrby(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, long long increment); +int cube_counter_set(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, long long value); + +/* ---------------------------------- query --------------------------------- */ int cube_counter_get(const struct cube *cube, int metric_id, const struct field_list *dimensions, long long *value); int cube_hll_get(const struct cube *cube, int metric_id, const struct field_list *dimensions, double *value); int cube_histogram_value_at_percentile(const struct cube *cube, int metric_id, const struct field_list *dimensions, double percentile, long long *value); @@ -35,10 +40,16 @@ int cube_get_serialization(const struct cube *cube, int metric_id, const struct int cube_get_cell_count(const struct cube *cube); enum sampling_mode cube_get_sampling_mode(const struct cube *cube); void cube_get_cells(const struct cube *cube, struct field_list **tag_list, size_t *n_cell); +void cube_get_metrics(const struct cube *cube, int **metric_id_out, size_t *n_metric); void cube_get_metrics_in_cell(const struct cube *cube, const struct field_list *dimensions, int **metric_id_out, size_t *n_metric_out); -void cube_set_primary_metric(struct cube *cube, int metric_id); +int cube_set_primary_metric(struct cube *cube, int metric_id); struct field_list *cube_get_identifier(const struct cube *cube); +const char *cube_get_metric_name(const struct cube *cube, int metric_id); +enum metric_type cube_get_metric_type(const struct cube *cube, int metric_id); +/* -------------------------------------------------------------------------- */ +/* cube manager */ +/* -------------------------------------------------------------------------- */ struct cube *cube_manager_get_cube_by_id(const struct cube_manager *manager, int cube_id); // the cube will be taken over by the manager, user do not free it. @@ -47,7 +58,7 @@ void cube_manager_delete(struct cube_manager *pthis, struct cube *cube); // the int cube_manager_find(const struct cube_manager *pthis, const struct field *cube_dimensions, size_t n_dimensions); struct cube_manager *cube_manager_new(); void cube_manager_free(struct cube_manager *pthis); -void cube_manager_merge(struct cube_manager *dest, const struct cube_manager *src); +int cube_manager_merge(struct cube_manager *dest, const struct cube_manager *src); void cube_manager_reset(struct cube_manager *pthis); void cube_manager_calibrate(struct cube_manager *pthis, const struct cube_manager *master); diff --git a/src/exporter/cjson_exporter.c b/src/exporter/cjson_exporter.c index 9466f01..3fecf40 100644 --- a/src/exporter/cjson_exporter.c +++ b/src/exporter/cjson_exporter.c @@ -524,16 +524,17 @@ int cell_iter_next(struct cell_iter *iter) { /* -------------------------------------------------------------------------- */ struct export_kv_pair *cell_query_with_iter(const struct cell_iter *iter, int metric_id) { - enum metric_type type = fieldstat_get_metric_type(iter->instance, metric_id); + int cube_id = iter->cube_ids[iter->curr_cube_idx]; + enum metric_type type = fieldstat_get_metric_type(iter->instance, cube_id, metric_id); struct export_kv_pair *ret = NULL; if (type == METRIC_TYPE_COUNTER) { long long value; - int tmp_ret = fieldstat_counter_get(iter->instance, iter->cube_ids[iter->curr_cube_idx], &iter->tag_list[iter->curr_cell_idx], metric_id, &value); + int tmp_ret = fieldstat_counter_get(iter->instance, cube_id, &iter->tag_list[iter->curr_cell_idx], metric_id, &value); if (tmp_ret < 0) { return NULL; } ret = malloc(sizeof(struct export_kv_pair)); - ret->key = strdup(fieldstat_get_metric_name(iter->instance, metric_id)); + ret->key = strdup(fieldstat_get_metric_name(iter->instance, cube_id, metric_id)); ret->type = TAG_INTEGER; ret->value_longlong = value; return ret; @@ -541,12 +542,12 @@ struct export_kv_pair *cell_query_with_iter(const struct cell_iter *iter, int me if (type == METRIC_TYPE_HLL || type == METRIC_TYPE_HISTOGRAM) { char *value; size_t len; - fieldstat_get_serialized_blob(iter->instance, iter->cube_ids[iter->curr_cube_idx], metric_id, &iter->tag_list[iter->curr_cell_idx], &value, &len); + fieldstat_get_serialized_blob(iter->instance, cube_id, metric_id, &iter->tag_list[iter->curr_cell_idx], &value, &len); if (value == NULL) { return NULL; } ret = malloc(sizeof(struct export_kv_pair)); - ret->key = strdup(fieldstat_get_metric_name(iter->instance, metric_id)); + ret->key = strdup(fieldstat_get_metric_name(iter->instance, cube_id, metric_id)); ret->type = TAG_CSTRING; ret->value_str = value; return ret; diff --git a/src/fieldstat.c b/src/fieldstat.c index b847bd5..0e2fb81 100644 --- a/src/fieldstat.c +++ b/src/fieldstat.c @@ -3,7 +3,6 @@ #include #include #include -#include #include "cjson/cJSON.h" #include "uthash.h" @@ -11,92 +10,11 @@ #include "fieldstat.h" #include "metrics/metric.h" #include "cube.h" -#include "metric_manifest.h" - struct fieldstat { - struct metric_manifest_manager *manifest_manager; - struct cube_manager *cube_manager; }; -union metric_parameter *construct_parameters(enum metric_type type, ...) -{ - union metric_parameter *paras = (union metric_parameter *)malloc(sizeof(union metric_parameter)); - va_list ap; - va_start(ap, type); - switch (type) { - case METRIC_TYPE_COUNTER: - break; - case METRIC_TYPE_HLL: - paras->hll.precision = (char)va_arg(ap, int); - break; - case METRIC_TYPE_HISTOGRAM: - paras->hdr.lowest_trackable_value = va_arg(ap, long long); - paras->hdr.highest_trackable_value = va_arg(ap, long long); - paras->hdr.significant_figures = va_arg(ap, int); - break; - default: - assert(0); - } - va_end(ap); - return paras; -} - -void tag_array_copy(struct field *tags_dst, const struct field *tags_src, size_t n_field) -{ - for (size_t i = 0; i < n_field; i++) { - tags_dst[i].key = strdup(tags_src[i].key); - tags_dst[i].type = tags_src[i].type; - switch (tags_src[i].type) - { - case TAG_INTEGER: - tags_dst[i].value_longlong = tags_src[i].value_longlong; - break; - case TAG_CSTRING: - tags_dst[i].value_str = strdup(tags_src[i].value_str); - break; - case TAG_DOUBLE: - tags_dst[i].value_double = tags_src[i].value_double; - break; - default: - break; - } - } -} - -bool is_tag_array_same(const struct field *tags1, const struct field *tags2, size_t n_field) -{ - for (size_t i = 0; i < n_field; i++) { - if (tags1[i].type != tags2[i].type) { - return false; - } - if (strcmp(tags1[i].key, tags2[i].key) != 0) { - return false; - } - switch (tags1[i].type) - { - case TAG_INTEGER: - if (tags1[i].value_longlong != tags2[i].value_longlong) { - return false; - } - break; - case TAG_CSTRING: - if (strcmp(tags1[i].value_str, tags2[i].value_str) != 0) { - return false; - } - break; - case TAG_DOUBLE: - if (tags1[i].value_double != tags2[i].value_double) { - return false; - } - break; - default: - break; - } - } - return 0; -} /* -------------------------------------------------------------------------- */ /* fieldstat */ @@ -106,8 +24,6 @@ struct fieldstat *fieldstat_new() { struct fieldstat *instance = calloc(1, sizeof(struct fieldstat)); - instance->manifest_manager = metric_manifest_manager_new(); - instance->cube_manager = cube_manager_new(); return instance; @@ -121,8 +37,6 @@ void fieldstat_free(struct fieldstat *instance) cube_manager_free(instance->cube_manager); - metric_manifest_manager_free(instance->manifest_manager); - free(instance); } @@ -200,96 +114,41 @@ int fieldstat_cube_set_primary_metric(struct fieldstat *instance, int cube_id, i if (cube == NULL) { return FS_ERR_INVALID_CUBE_ID; } - const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(instance->manifest_manager, metric_id); - if (manifest == NULL) { - return FS_ERR_INVALID_METRIC_ID; - } - if (cube_get_sampling_mode(cube) == SAMPLING_MODE_COMPREHENSIVE || - (cube_get_sampling_mode(cube) == SAMPLING_MODE_TOPK && manifest->type != METRIC_TYPE_COUNTER) || - (cube_get_sampling_mode(cube) == SAMPLING_MODE_SPREADSKETCH && manifest->type != METRIC_TYPE_HLL)) { - return FS_ERR_INVALID_PARAM; - } - - cube_set_primary_metric(cube, metric_id); - - return FS_OK; + + return cube_set_primary_metric(cube, metric_id); } /* -------------------------------------------------------------------------- */ /* metric register */ /* -------------------------------------------------------------------------- */ -int fieldstat_register_counter(struct fieldstat *instance, const char *metric_name) -{ - struct metric_manifest *metric = malloc(sizeof(struct metric_manifest)); - metric->name = strdup(metric_name); - metric->parameters = construct_parameters(METRIC_TYPE_COUNTER); - metric->type = METRIC_TYPE_COUNTER; - - int id = metric_manifest_manager_add(instance->manifest_manager, metric); - if (id < 0) { - free(metric->name); - free(metric->parameters); - free(metric); - return FS_ERR_INVALID_KEY; +// cppcheck-suppress [constParameterPointer, unmatchedSuppression] +int fieldstat_register_counter(struct fieldstat *instance, int cube_id, const char *metric_name) +{ + struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); + if (cube == NULL) { + return FS_ERR_INVALID_CUBE_ID; } - - metric->id = id; - return id; + return cube_register_counter(cube, metric_name); } -int fieldstat_register_hll(struct fieldstat *instance, const char *metric_name, unsigned char precision) +// cppcheck-suppress [constParameterPointer, unmatchedSuppression] +int fieldstat_register_hll(struct fieldstat *instance, int cube_id, const char *metric_name, unsigned char precision) { - if (precision < 4 || precision > 18) { - return FS_ERR_INVALID_PARAM; - } - - struct metric_manifest *metric = malloc(sizeof(struct metric_manifest)); - metric->name = strdup(metric_name); - metric->parameters = construct_parameters(METRIC_TYPE_HLL, precision); - metric->type = METRIC_TYPE_HLL; - - int id = metric_manifest_manager_add(instance->manifest_manager, metric); - if (id < 0) { - free(metric->name); - free(metric->parameters); - free(metric); - return FS_ERR_INVALID_KEY; + struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); + if (cube == NULL) { + return FS_ERR_INVALID_CUBE_ID; } - - metric->id = id; - return id; + return cube_register_hll(cube, metric_name, precision); } -int fieldstat_register_hist(struct fieldstat *instance, const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures) +// cppcheck-suppress [constParameterPointer, unmatchedSuppression] +int fieldstat_register_hist(struct fieldstat *instance, int cube_id, const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures) { - // refer to hdr_histogram.h for the rules of parameters. Just copy them here - if (lowest_trackable_value < 1) { - return FS_ERR_INVALID_PARAM; - } - if (significant_figures < 1 || significant_figures > 5) { - return FS_ERR_INVALID_PARAM; - } - if (lowest_trackable_value * 2 > highest_trackable_value) - { - return FS_ERR_INVALID_PARAM; - } - - - struct metric_manifest *metric = malloc(sizeof(struct metric_manifest)); - metric->name = strdup(metric_name); - metric->parameters = construct_parameters(METRIC_TYPE_HISTOGRAM, lowest_trackable_value, highest_trackable_value, significant_figures); - metric->type = METRIC_TYPE_HISTOGRAM; - - int id = metric_manifest_manager_add(instance->manifest_manager, metric); - if (id < 0) { - free(metric->name); - free(metric->parameters); - free(metric); - return FS_ERR_INVALID_KEY; + struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); + if (cube == NULL) { + return FS_ERR_INVALID_CUBE_ID; } - metric->id = id; - - return id; + return cube_register_hist(cube, metric_name, lowest_trackable_value, highest_trackable_value, significant_figures); } /* -------------------------------------------------------------------------- */ @@ -303,12 +162,8 @@ int fieldstat_counter_incrby(struct fieldstat *instance, int cube_id, int metric if (cube == NULL) { return FS_ERR_INVALID_CUBE_ID; } - const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(instance->manifest_manager, metric_id); - if (manifest == NULL || manifest->type != METRIC_TYPE_COUNTER) { - return FS_ERR_INVALID_METRIC_ID; - } - - return cube_counter_incrby(cube, manifest, cell_dimensions, n_dimensions, increment); + + return cube_counter_incrby(cube, metric_id, cell_dimensions, n_dimensions, increment); } // cppcheck-suppress [constParameterPointer, unmatchedSuppression] @@ -318,12 +173,8 @@ int fieldstat_counter_set(struct fieldstat *instance, int cube_id, int metric_id if (cube == NULL) { return FS_ERR_INVALID_CUBE_ID; } - const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(instance->manifest_manager, metric_id); - if (manifest == NULL || manifest->type != METRIC_TYPE_COUNTER) { - return FS_ERR_INVALID_METRIC_ID; - } - return cube_counter_set(cube, manifest, cell_dimensions, n_dimensions, value); + return cube_counter_set(cube, metric_id, cell_dimensions, n_dimensions, value); } // cppcheck-suppress [constParameterPointer, unmatchedSuppression] @@ -333,12 +184,8 @@ int fieldstat_hll_add(struct fieldstat *instance, int cube_id, int metric_id, co if (cube == NULL) { return FS_ERR_INVALID_CUBE_ID; } - const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(instance->manifest_manager, metric_id); - if (manifest == NULL || manifest->type != METRIC_TYPE_HLL) { - return FS_ERR_INVALID_METRIC_ID; - } - return cube_hll_add(cube, manifest, cell_dimensions, n_dimensions, key, key_len); + return cube_hll_add(cube, metric_id, cell_dimensions, n_dimensions, key, key_len); } // cppcheck-suppress [constParameterPointer, unmatchedSuppression] @@ -348,12 +195,8 @@ int fieldstat_hll_add_field(struct fieldstat *instance, int cube_id, int metric_ if (cube == NULL) { return FS_ERR_INVALID_CUBE_ID; } - const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(instance->manifest_manager, metric_id); - if (manifest == NULL || manifest->type != METRIC_TYPE_HLL) { - return FS_ERR_INVALID_METRIC_ID; - } - return cube_hll_add_field(cube, manifest, cell_dimensions, n_dimensions, item, item_len); + return cube_hll_add_field(cube, metric_id, cell_dimensions, n_dimensions, item, item_len); } // cppcheck-suppress [constParameterPointer, unmatchedSuppression] @@ -363,12 +206,8 @@ int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id if (cube == NULL) { return FS_ERR_INVALID_CUBE_ID; } - const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(instance->manifest_manager, metric_id); - if (manifest == NULL || manifest->type != METRIC_TYPE_HISTOGRAM) { - return FS_ERR_INVALID_METRIC_ID; - } - return cube_histogram_record(cube, manifest, cell_dimensions, n_dimensions, value); + return cube_histogram_record(cube, metric_id, cell_dimensions, n_dimensions, value); } int fieldstat_merge(struct fieldstat *instance, const struct fieldstat *src) @@ -377,27 +216,7 @@ int fieldstat_merge(struct fieldstat *instance, const struct fieldstat *src) return FS_ERR_NULL_HANDLER; } - size_t n_metric_src = 0; - const struct metric_manifest **list_src = metric_manifest_manager_list(src->manifest_manager, &n_metric_src); - size_t n_metric_dst = 0; - const struct metric_manifest **list_dst = metric_manifest_manager_list(instance->manifest_manager, &n_metric_dst); - int len_min = n_metric_src < n_metric_dst ? n_metric_src : n_metric_dst; - for (int i = 0; i < len_min; i++) { - if (list_src[i]->type != list_dst[i]->type) { - return FS_ERR_INVALID_PARAM; - } - if (strcmp(list_src[i]->name, list_dst[i]->name) != 0) { - return FS_ERR_INVALID_PARAM; - } - } - for (int i = n_metric_dst; i < n_metric_src; i++) { - metric_manifest_manager_add(instance->manifest_manager, metric_manifest_copy(list_src[i])); - } - - - cube_manager_merge(instance->cube_manager, src->cube_manager); - - return FS_OK; + return cube_manager_merge(instance->cube_manager, src->cube_manager); } struct fieldstat *fieldstat_fork(const struct fieldstat *instance) @@ -408,16 +227,12 @@ struct fieldstat *fieldstat_fork(const struct fieldstat *instance) struct fieldstat *new_instance = calloc(1, sizeof(struct fieldstat)); new_instance->cube_manager = cube_manager_fork(instance->cube_manager); - new_instance->manifest_manager = metric_manifest_manager_copy(instance->manifest_manager); - return new_instance; } int fieldstat_calibrate(const struct fieldstat *master, struct fieldstat *replica) { cube_manager_calibrate(replica->cube_manager, master->cube_manager); - metric_manifest_manager_free(replica->manifest_manager); - replica->manifest_manager = metric_manifest_manager_copy(master->manifest_manager); return FS_OK; } @@ -430,22 +245,6 @@ void fieldstat_get_cubes(const struct fieldstat *instance, int **cube_ids, int * cube_manager_list(instance->cube_manager, cube_ids, n_cube); } -void fieldstat_get_metrics(const struct fieldstat *instance, int **metric_id_out, size_t *n_metric) -{ - const struct metric_manifest **list = metric_manifest_manager_list(instance->manifest_manager, n_metric); - if (*n_metric == 0) { - *metric_id_out = NULL; - return; - } - - int *tmp_ids = (int *)malloc(sizeof(int) * (*n_metric)); - *metric_id_out = tmp_ids; - - for (int i = 0; i < *n_metric; i++) { - tmp_ids[i] = list[i]->id; - } -} - struct field_list *fieldstat_cube_get_tags(const struct fieldstat *instance, int cube_id) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); @@ -530,24 +329,23 @@ void fieldstat_tag_list_arr_free(struct field_list *tag_list, size_t n_cell) free(tag_list); } -const char *fieldstat_get_metric_name(const struct fieldstat *instance, int metric_id) +const char *fieldstat_get_metric_name(const struct fieldstat *instance, int cube_id, int metric_id) { - const struct metric_manifest *metric = metric_manifest_manager_get_by_id(instance->manifest_manager, metric_id); - if (metric == NULL) { + const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); + if (cube == NULL) { + printf("cube is NULL\n"); return NULL; } - - return metric->name; + return cube_get_metric_name(cube, metric_id); } -enum metric_type fieldstat_get_metric_type(const struct fieldstat *instance, int metric_id) +enum metric_type fieldstat_get_metric_type(const struct fieldstat *instance, int cube_id, int metric_id) { - const struct metric_manifest *metric = metric_manifest_manager_get_by_id(instance->manifest_manager, metric_id); - if (metric == NULL) { + const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); + if (cube == NULL) { return (enum metric_type)(-1); } - - return metric->type; + return cube_get_metric_type(cube, metric_id); } void fieldstat_cube_get_cells(const struct fieldstat *instance, int cube_id, struct field_list **cell_dimensions, size_t *n_cell) @@ -592,4 +390,9 @@ void fieldstat_get_metric_in_cell(const struct fieldstat *instance, int cube_id, { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); return cube_get_metrics_in_cell(cube, cell_dimensions, metric_id_out, n_metric_out); -} \ No newline at end of file +} + +void fieldstat_cube_get_metrics(const struct fieldstat *instance, int cube_id, int **metric_id_out, size_t *n_metric) { + const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); + cube_get_metrics(cube, metric_id_out, n_metric); +} diff --git a/src/fieldstat_easy.c b/src/fieldstat_easy.c index b5f811c..ef1a921 100644 --- a/src/fieldstat_easy.c +++ b/src/fieldstat_easy.c @@ -192,17 +192,17 @@ int fieldstat_easy_register_counter(struct fieldstat_easy *fse, const char *name pthread_spin_lock(&fse->fsu[i].lock); } - int ret = fieldstat_register_counter(fse->fsu[0].active, name); // try to register + int ret = fieldstat_register_counter(fse->fsu[0].active, 0, name); // try to register if (ret < 0) { for (int i = 0; i < fse->max_thread_num; i++) { pthread_spin_unlock(&fse->fsu[i].lock); } return ret; } - fieldstat_register_counter(fse->fsu[0].read_only, name); + fieldstat_register_counter(fse->fsu[0].read_only, 0, name); for (int i = 1; i < fse->max_thread_num; i++) { - fieldstat_register_counter(fse->fsu[i].active, name); - fieldstat_register_counter(fse->fsu[i].read_only, name); + fieldstat_register_counter(fse->fsu[i].active, 0, name); + fieldstat_register_counter(fse->fsu[i].read_only, 0, name); } for (int i = 0; i < fse->max_thread_num; i++) { @@ -218,17 +218,17 @@ int fieldstat_easy_register_histogram(struct fieldstat_easy *fse, const char *na pthread_spin_lock(&fse->fsu[i].lock); } - int ret = fieldstat_register_hist(fse->fsu[0].active, name, lowest_trackable_value, highest_trackable_value, significant_figures); // try to register + int ret = fieldstat_register_hist(fse->fsu[0].active, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); // try to register if (ret < 0) { for (int i = 0; i < fse->max_thread_num; i++) { pthread_spin_unlock(&fse->fsu[i].lock); } return ret; } - fieldstat_register_hist(fse->fsu[0].read_only, name, lowest_trackable_value, highest_trackable_value, significant_figures); + fieldstat_register_hist(fse->fsu[0].read_only, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); for (int i = 1; i < fse->max_thread_num; i++) { - fieldstat_register_hist(fse->fsu[i].active, name, lowest_trackable_value, highest_trackable_value, significant_figures); - fieldstat_register_hist(fse->fsu[i].read_only, name, lowest_trackable_value, highest_trackable_value, significant_figures); + fieldstat_register_hist(fse->fsu[i].active, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); + fieldstat_register_hist(fse->fsu[i].read_only, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); } for (int i = 0; i < fse->max_thread_num; i++) { diff --git a/test/test_easy_fs.cpp b/test/test_easy_fs.cpp index 8b6ef85..e723828 100644 --- a/test/test_easy_fs.cpp +++ b/test/test_easy_fs.cpp @@ -305,6 +305,6 @@ TEST(test_easy_fieldstat, accuracy_in_multithread) int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); - testing::GTEST_FLAG(filter) = "test_easy_fieldstat.accuracy_in_multithread"; + // testing::GTEST_FLAG(filter) = "test_easy_fieldstat.accuracy_in_multithread"; return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/test/test_empty_tags.cpp b/test/test_empty_tags.cpp index 54e243a..1d1484a 100644 --- a/test/test_empty_tags.cpp +++ b/test/test_empty_tags.cpp @@ -26,7 +26,7 @@ TEST(test_empty_tag, add_many_times) struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 1); - int metric_id = fieldstat_register_counter(instance, "metric"); + int metric_id = fieldstat_register_counter(instance, cube_id, "metric"); fieldstat_counter_incrby(instance, cube_id, metric_id, NULL, 0, 1); fieldstat_counter_incrby(instance, cube_id, metric_id, NULL, 0, 1); @@ -39,7 +39,7 @@ struct fieldstat *test_empty_my_init(enum sampling_mode mode = SAMPLING_MODE_COM { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, NULL, 0, mode, 1); - int metric_id = fieldstat_register_counter(instance, "metric"); + int metric_id = fieldstat_register_counter(instance, cube_id, "metric"); fieldstat_counter_incrby(instance, cube_id, metric_id, NULL, 0, 1); return instance; @@ -98,7 +98,7 @@ TEST(test_empty_tag, merge_spreadsketch) { struct fieldstat *instance_src = fieldstat_new(); int cube_id = fieldstat_create_cube(instance_src, NULL, 0, SAMPLING_MODE_SPREADSKETCH, 1); - int metric_id = fieldstat_register_hll(instance_src, "metric", 4); + int metric_id = fieldstat_register_hll(instance_src, cube_id, "metric", 4); fieldstat_hll_add(instance_src, cube_id, metric_id, NULL, 0, "1", 1); struct fieldstat *instance_dst = fieldstat_new(); diff --git a/test/test_exporter_json.cpp b/test/test_exporter_json.cpp index 259091b..288bdac 100644 --- a/test/test_exporter_json.cpp +++ b/test/test_exporter_json.cpp @@ -168,8 +168,8 @@ void topk_init(struct fieldstat *instance, unsigned int test_expected_big_count) { const char *metric_name[TEST_METRIC_NUM] = {"topk1", "topk2"}; int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_TOPK, TEST_TOPK_STANDARD_K); - int m1 = fieldstat_register_counter(instance, metric_name[0]); - int m2 = fieldstat_register_counter(instance, metric_name[1]); + int m1 = fieldstat_register_counter(instance, cube_id, metric_name[0]); + int m2 = fieldstat_register_counter(instance, cube_id, metric_name[1]); std::function topk_add = [instance, cube_id, m1, m2](const Fieldstat_tag_list_wrapper *my_tags, unsigned int counts[TEST_METRIC_NUM]) { @@ -187,9 +187,9 @@ TEST(export_test, cjson_export_with_fixed_tag_and_many_metrics_on_one_cube_of_co // new instance struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, tag_list_num); - int id_counter = fieldstat_register_counter(instance, "counter"); - int id_gauge = fieldstat_register_hll(instance, "gauge", g_hll_standard->cfg.precision); - int id_histogram = fieldstat_register_hist(instance, "histogram", + int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); + int id_gauge = fieldstat_register_hll(instance, cube_id, "gauge", g_hll_standard->cfg.precision); + int id_histogram = fieldstat_register_hist(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); Fieldstat_tag_list_wrapper *fields[tag_list_num]; @@ -294,10 +294,10 @@ TEST(export_test, only_registered_but_not_added_export_null_with_global_tag) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); - fieldstat_register_counter(instance, "counter"); - fieldstat_register_hll(instance, "gauge", g_hll_standard->cfg.precision); - fieldstat_register_hist(instance, "histogram", + int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); + fieldstat_register_counter(instance, cube_id, "counter"); + fieldstat_register_hll(instance, cube_id, "gauge", g_hll_standard->cfg.precision); + fieldstat_register_hist(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); // add global field @@ -313,9 +313,9 @@ TEST(export_test, skip_two_empty_cube_and_export_last_one_with_global_tag) (void)fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); (void)fieldstat_create_cube(instance, TEST_TAG_SHARED2, 3, SAMPLING_MODE_COMPREHENSIVE, 3); int cube_id_3 = fieldstat_create_cube(instance, TEST_TAG_SHARED3, 1, SAMPLING_MODE_COMPREHENSIVE, 3); - (void)fieldstat_register_counter(instance, "counter"); - (void)fieldstat_register_hll(instance, "gauge", g_hll_standard->cfg.precision); - int id_histogram = fieldstat_register_hist(instance, "histogram", + (void)fieldstat_register_counter(instance, cube_id_3, "counter"); + (void)fieldstat_register_hll(instance, cube_id_3, "gauge", g_hll_standard->cfg.precision); + int id_histogram = fieldstat_register_hist(instance, cube_id_3, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); const int tag_num = 1; @@ -361,10 +361,10 @@ TEST(export_test, skip_empty_metrics_given_cube_deleted) { int cube_id_del = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED2, 3, SAMPLING_MODE_COMPREHENSIVE, 3); fieldstat_destroy_cube(instance, cube_id_del); - (void)fieldstat_register_counter(instance, "counter"); - (void)fieldstat_register_counter(instance, "counter2"); - int metric_id = fieldstat_register_counter(instance, "counter3"); - (void)fieldstat_register_counter(instance, "counter4"); + (void)fieldstat_register_counter(instance, cube_id, "counter"); + (void)fieldstat_register_counter(instance, cube_id, "counter2"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter3"); + (void)fieldstat_register_counter(instance, cube_id, "counter4"); const int tag_num = 1; Fieldstat_tag_list_wrapper *fields[tag_num]; @@ -408,7 +408,7 @@ TEST(export_test, enable_delta_and_export_twice_without_new_metric) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); - int id_counter = fieldstat_register_counter(instance, "counter"); + int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, id_counter, &TEST_TAG_INT, 1, 1); // export test @@ -477,8 +477,8 @@ TEST(export_test, enable_delta_and_export_twice_with_new_metric_and_omit_histogr { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); - int id_counter = fieldstat_register_counter(instance, "counter"); - int id_histogram = fieldstat_register_hist(instance, "histogram", + int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); + int id_histogram = fieldstat_register_hist(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); fieldstat_counter_incrby(instance, cube_id, id_counter, &TEST_TAG_INT, 1, 1); fieldstat_hist_record(instance, cube_id, id_histogram, &TEST_TAG_INT, 1, 123); @@ -516,7 +516,7 @@ TEST(export_test, enable_delta_and_export_twice_with_new_metric_and_omit_histogr struct timeval new_ts = TEST_TIMEVAL; new_ts.tv_sec += 1; - int id_counter2 = fieldstat_register_counter(instance, "counter2"); + int id_counter2 = fieldstat_register_counter(instance, cube_id, "counter2"); fieldstat_counter_incrby(instance, cube_id, id_counter2, &TEST_TAG_INT, 1, 1); fieldstat_counter_incrby(instance, cube_id, id_counter, &TEST_TAG_INT, 1, 10); @@ -559,8 +559,8 @@ TEST(export_test, enable_delta_and_export_three_times_skipping_cube_with_no_coun { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); - int id_counter = fieldstat_register_counter(instance, "counter"); - int id_histogram = fieldstat_register_hist(instance, "histogram", + int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); + int id_histogram = fieldstat_register_hist(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); fieldstat_counter_incrby(instance, cube_id, id_counter, &TEST_TAG_INT, 1, 1); fieldstat_hist_record(instance, cube_id, id_histogram, &TEST_TAG_STRING, 1, 123); @@ -668,13 +668,14 @@ TEST(export_test, enable_delta_and_export_instance_with_many_cells_with_global_t { struct fieldstat *instance = fieldstat_new(); int cube_id1 = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); - int id_counter1 = fieldstat_register_counter(instance, "counter"); + int id_counter1 = fieldstat_register_counter(instance, cube_id1, "counter"); fieldstat_counter_incrby(instance, cube_id1, id_counter1, &TEST_TAG_INT, 1, 11); fieldstat_counter_incrby(instance, cube_id1, id_counter1, &TEST_TAG_STRING, 1, 12); int cube_id2 = fieldstat_create_cube(instance, TEST_TAG_SHARED3, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_counter_incrby(instance, cube_id2, id_counter1, &TEST_TAG_INT, 1, 21); - fieldstat_counter_incrby(instance, cube_id2, id_counter1, &TEST_TAG_DOUBLE, 1, 22); + int id_counter2 = fieldstat_register_counter(instance, cube_id2, "counter"); + fieldstat_counter_incrby(instance, cube_id2, id_counter2, &TEST_TAG_INT, 1, 21); + fieldstat_counter_incrby(instance, cube_id2, id_counter2, &TEST_TAG_DOUBLE, 1, 22); // export test struct fieldstat_json_exporter *fieldstat_json_exporter = fieldstat_json_exporter_new(); @@ -753,7 +754,7 @@ void test_reset_one_round(std::functionget_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_COMPREHENSIVE, CELL_MAX); EXPECT_EQ(cube_id, i); + + fieldstat_register_counter(master, cube_id, metric_name[METRIC_ID_COUNTER]); + fieldstat_register_hll(master, cube_id, metric_name[METRIC_ID_HLL], 6); } - // init metric - fieldstat_register_counter(master, metric_name[METRIC_ID_COUNTER]); - fieldstat_register_hll(master, metric_name[METRIC_ID_HLL], 6); + // all the possible fields Fieldstat_tag_list_wrapper *tag_list_wrapper[FLOW_NUM]; fill_random_tag_of_length_1_to_3(tag_list_wrapper, FLOW_NUM); @@ -121,6 +122,8 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ shared_tags[cube_id_to_change] = new_tag; fieldstat_destroy_cube(master, cube_id_to_change); int cube_id_new = fieldstat_create_cube(master, new_tag->get_tag(), new_tag->get_tag_count(), SAMPLING_MODE_COMPREHENSIVE, CELL_MAX); + fieldstat_register_counter(master, cube_id_new, metric_name[METRIC_ID_COUNTER]); + fieldstat_register_hll(master, cube_id_new, metric_name[METRIC_ID_HLL], 6); EXPECT_EQ(cube_id_new, cube_id_to_change); // should new the cube in the hole leaved by the destroyed cube // calibrate for (int j = 0; j < INSTANCE_NUM; j++) { @@ -219,9 +222,9 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ shared_tags[i] = new Fieldstat_tag_list_wrapper("shared_tag", i); int cube_id = fieldstat_create_cube(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_TOPK, CELL_MAX); EXPECT_EQ(cube_id, i); + fieldstat_register_counter(master, cube_id, "topk"); } - // init metric - fieldstat_register_counter(master, "topk"); + // all the possible fields Fieldstat_tag_list_wrapper *tag_list_wrapper[FLOW_NUM]; fill_with_elephant_flows(tag_list_wrapper, FLOW_NUM); @@ -257,6 +260,7 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ shared_tags[cube_id_to_change] = new_tag; fieldstat_destroy_cube(master, cube_id_to_change); int cube_id_new = fieldstat_create_cube(master, new_tag->get_tag(), new_tag->get_tag_count(), SAMPLING_MODE_TOPK, CELL_MAX); + fieldstat_register_counter(master, cube_id_new, "topk"); EXPECT_EQ(cube_id_new, cube_id_to_change); // should new the cube in the hole leaved by the destroyed cube // calibrate for (int j = 0; j < INSTANCE_NUM; j++) { @@ -335,9 +339,10 @@ TEST(Fuzz_test, add_and_reset_with_randomly_generated_flows_and_randomly_chosen_ fill_with_elephant_flows(tag_list_wrapper, FLOW_NUM); struct fieldstat *instance = fieldstat_new(); - int primary_metric_id = fieldstat_register_counter(instance, "counter"); - int counter2_id = fieldstat_register_counter(instance, "counter2"); + int cube_id = fieldstat_create_cube(instance,NULL,0,SAMPLING_MODE_TOPK, 1); // K = 1, just to increase the possibility of FS_ERR_TOO_MANY_CELLS + int primary_metric_id = fieldstat_register_counter(instance, cube_id, "counter"); + int counter2_id = fieldstat_register_counter(instance, cube_id, "counter2"); fieldstat_counter_incrby(instance, cube_id, primary_metric_id, tag_list_wrapper[0]->get_tag(), tag_list_wrapper[0]->get_tag_count(), 1); fieldstat_counter_incrby(instance, cube_id, counter2_id, tag_list_wrapper[0]->get_tag(), tag_list_wrapper[0]->get_tag_count(), 1); @@ -388,9 +393,10 @@ TEST(Fuzz_test, simple_one_for_perf) shared_tags[i] = new Fieldstat_tag_list_wrapper("shared_tag", i); int cube_id = fieldstat_create_cube(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_TOPK, CELL_MAX); EXPECT_EQ(cube_id, i); + fieldstat_register_counter(master, cube_id, "topk"); } // init metric - fieldstat_register_counter(master, "topk"); + // all the possible fields Fieldstat_tag_list_wrapper *tag_list_wrapper[FLOW_NUM]; fill_with_elephant_flows(tag_list_wrapper, FLOW_NUM); diff --git a/test/test_merge.cpp b/test/test_merge.cpp index 7a07baf..ecf45fd 100644 --- a/test/test_merge.cpp +++ b/test/test_merge.cpp @@ -46,51 +46,12 @@ double merge_test_fieldstat_hll_get(const struct fieldstat *instance, int cube_i return ret; } -TEST(unit_test_merge, test_metric_name_mapping_by_adding_metric_to_dest) -{ - struct fieldstat *instance = fieldstat_new(); - - int cube_id1 = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id_1 = fieldstat_register_counter(instance, "shared name"); - struct fieldstat *instance_dest = fieldstat_fork(instance); - - int metric_id_only_src = fieldstat_register_counter(instance, "metric_name cube1 cube2"); - fieldstat_counter_incrby(instance, cube_id1, metric_id_1, &TEST_TAG_STRING, 1, 1); - fieldstat_counter_incrby(instance, cube_id1, metric_id_only_src, &TEST_TAG_STRING, 1, 2); - int cube_id2 = fieldstat_create_cube(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_counter_incrby(instance, cube_id2, metric_id_only_src, &TEST_TAG_STRING, 1, 3); - - EXPECT_EQ(fieldstat_merge(instance_dest, instance), FS_OK); - - int *cube_id; - int n_cube; - fieldstat_get_cubes(instance_dest, &cube_id, &n_cube); - EXPECT_TRUE(n_cube == 2); - EXPECT_TRUE(cube_id[0] == cube_id1); - - int *metric_ids; - size_t n_metrics; - fieldstat_get_metrics(instance_dest, &metric_ids, &n_metrics); - EXPECT_EQ(n_metrics, 2); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, metric_ids[0]), "shared name"); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, metric_ids[1]), "metric_name cube1 cube2"); - - EXPECT_EQ(merge_test_fieldstat_counter_get(instance_dest, cube_id1, metric_ids[0]), 1); // shared name - EXPECT_EQ(merge_test_fieldstat_counter_get(instance_dest, cube_id1, metric_ids[1]), 2); // metric_name cube1 cube2 on cube1 - EXPECT_EQ(merge_test_fieldstat_counter_get(instance_dest, cube_id[1], metric_ids[1]), 3); // metric_name cube1 cube2 on cube2 - - fieldstat_free(instance); - fieldstat_free(instance_dest); - free(cube_id); - free(metric_ids); -} - TEST(unit_test_merge, cube_shared_tag_mapping_with_new_cube) { struct fieldstat *instance = fieldstat_new(); (void)fieldstat_create_cube(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int cube_id2 = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_counter(instance, "metric in cube 2"); + int metric_id = fieldstat_register_counter(instance,cube_id2,"metric in cube 2"); fieldstat_counter_incrby(instance, cube_id2, metric_id, &TEST_TAG_STRING, 1, 1); struct fieldstat *instance_dest = fieldstat_new(); int cube_id_dest = fieldstat_create_cube(instance_dest, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); @@ -127,7 +88,7 @@ TEST(unit_test_merge, new_cube_and_metric_to_empty_comprehensive) { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_counter(instance, "metric_name"); + fieldstat_register_counter(instance, 0, "metric_name"); struct fieldstat *instance_dest = fieldstat_new(); @@ -137,7 +98,7 @@ TEST(unit_test_merge, new_cube_and_metric_to_empty_comprehensive) int n_cube; fieldstat_get_cubes(instance_dest, &cube_id_dest, &n_cube); EXPECT_TRUE(n_cube == 1); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0), "metric_name"); + EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, cube_id_dest[0], 0), "metric_name"); fieldstat_free(instance); fieldstat_free(instance_dest); @@ -148,7 +109,7 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_comprehensive) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_counter(instance, "metric_name"); + int metric_id = fieldstat_register_counter(instance, 0, "metric_name"); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -160,7 +121,7 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_comprehensive) fieldstat_get_cubes(instance_dest, &cube_id_dest, &n_cube); EXPECT_TRUE(n_cube == 1); free(cube_id_dest); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0), "metric_name"); + EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, cube_id_dest[0], 0), "metric_name"); long long measure = merge_test_fieldstat_counter_get(instance, cube_id, metric_id); EXPECT_EQ(measure, 10086); @@ -180,14 +141,14 @@ TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_comprehens { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_counter(instance, "metric_name"); + int metric_id = fieldstat_register_counter(instance, cube_id, "metric_name"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, 5); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); fieldstat_merge(instance_dest, instance); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0), "metric_name"); + EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, cube_id, 0), "metric_name"); long long measure = merge_test_fieldstat_counter_get(instance_dest, cube_id, metric_id); EXPECT_EQ(measure, 10); @@ -199,7 +160,7 @@ TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_a { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 2); // limit is 2 - int metric_id = fieldstat_register_counter(instance, "metric name"); + int metric_id = fieldstat_register_counter(instance, cube_id, "metric name"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, 1); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -227,14 +188,14 @@ TEST(unit_test_merge, new_too_many_cells_on_multiple_metric_given_source_cube_re { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 2); - int metric_id1 = fieldstat_register_counter(instance, "metric name1"); - int metric_id2 = fieldstat_register_counter(instance, "metric name2"); + int metric_id1 = fieldstat_register_counter(instance, cube_id, "metric name1"); + int metric_id2 = fieldstat_register_counter(instance, cube_id, "metric name2"); fieldstat_counter_incrby(instance, cube_id, metric_id1, &TEST_TAG_STRING, 1, 1); // 1st cell on metric name1 struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); fieldstat_reset(instance); - int metric_id3 = fieldstat_register_counter(instance, "metric name3"); + int metric_id3 = fieldstat_register_counter(instance, cube_id, "metric name3"); fieldstat_counter_incrby(instance, cube_id, metric_id3, &TEST_TAG_INT, 1, 2); // 2nd cell on metric name3, this is a metric dest dont have fieldstat_counter_incrby(instance, cube_id, metric_id2, &TEST_TAG_DOUBLE, 1, 3); // 3nd cell on metric name2 fieldstat_merge(instance_dest, instance); @@ -243,12 +204,12 @@ TEST(unit_test_merge, new_too_many_cells_on_multiple_metric_given_source_cube_re size_t n_metrics = 0; fieldstat_get_metric_in_cell(instance_dest, 0, &TEST_TAG_LIST_STRING, &metric_ids, &n_metrics); EXPECT_EQ(n_metrics, 1); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, metric_ids[0]), "metric name1"); + EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0, metric_ids[0]), "metric name1"); free(metric_ids); fieldstat_get_metric_in_cell(instance_dest, 0, &TEST_TAG_LIST_INT, &metric_ids, &n_metrics); EXPECT_EQ(n_metrics, 1); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, metric_ids[0]), "metric name3"); + EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0, metric_ids[0]), "metric name3"); free(metric_ids); // 3nd cell failed to merge, because max sampling is 2 fieldstat_get_metric_in_cell(instance_dest, 0, &TEST_TAG_LIST_DOUBLE, &metric_ids, &n_metrics); @@ -262,7 +223,7 @@ TEST(unit_test_merge, new_cube_and_metric_to_empty_topk) { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_TOPK, 10); - fieldstat_register_counter(instance, "metric_name"); + fieldstat_register_counter(instance, 0, "metric_name"); struct fieldstat *instance_dest = fieldstat_new(); @@ -272,7 +233,7 @@ TEST(unit_test_merge, new_cube_and_metric_to_empty_topk) int n_cube; fieldstat_get_cubes(instance_dest, &cube_id_dest, &n_cube); EXPECT_TRUE(n_cube == 1); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0), "metric_name"); + EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, cube_id_dest[0], 0), "metric_name"); fieldstat_free(instance); fieldstat_free(instance_dest); @@ -283,7 +244,7 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_topk) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); - int metric_id = fieldstat_register_counter(instance, "metric_name"); + int metric_id = fieldstat_register_counter(instance, cube_id, "metric_name"); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -295,7 +256,7 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_topk) fieldstat_get_cubes(instance_dest, &cube_id_dest, &n_cube); EXPECT_TRUE(n_cube == 1); free(cube_id_dest); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0), "metric_name"); + EXPECT_STREQ(fieldstat_get_metric_name(instance_dest,cube_id_dest[0], 0), "metric_name"); long long measure = merge_test_fieldstat_counter_get(instance, cube_id, metric_id); EXPECT_EQ(measure, 10086); @@ -315,7 +276,7 @@ TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_topk) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); - int metric_id = fieldstat_register_counter(instance, "metric_name"); + int metric_id = fieldstat_register_counter(instance, cube_id, "metric_name"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, 5); struct fieldstat *instance_dest = fieldstat_new(); @@ -328,7 +289,7 @@ TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_topk) EXPECT_TRUE(n_cube == 1); int ret_cube_id = cube_id_dest[0]; free(cube_id_dest); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0), "metric_name"); + EXPECT_STREQ(fieldstat_get_metric_name(instance_dest,cube_id_dest[0], 0), "metric_name"); struct field_list *tag_list = NULL; size_t n_cell = 0; @@ -346,7 +307,7 @@ TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_a { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 2); - int metric_id = fieldstat_register_counter(instance, "metric name"); + int metric_id = fieldstat_register_counter(instance, cube_id, "metric name"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, 1); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -374,7 +335,7 @@ struct fieldstat *topk_test_push_flows(vector &flo { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, K); - int metric_id = fieldstat_register_counter(instance, "metric name"); + int metric_id = fieldstat_register_counter(instance, cube_id, "metric name"); for (size_t i = 0; i < flows_in_test.size(); i++) { fieldstat_counter_incrby(instance, cube_id, metric_id, flows_in_test[i]->get_tag(), flows_in_test[i]->get_tag_count(), count); } @@ -489,8 +450,8 @@ TEST(unit_test_merge, primary_metric_has_no_value) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 2); - int metric_primary = fieldstat_register_counter(instance, "primary"); - int metric_operated = fieldstat_register_counter(instance, "operated"); + int metric_primary = fieldstat_register_counter(instance, cube_id, "primary"); + int metric_operated = fieldstat_register_counter(instance, cube_id, "operated"); fieldstat_counter_incrby(instance, cube_id, metric_operated, &TEST_TAG_STRING, 1, 1); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -514,15 +475,15 @@ TEST(unit_test_merge, primary_metric_id_different) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 2); - int metric_primary = fieldstat_register_counter(instance, "primary"); - int metric_2 = fieldstat_register_counter(instance, "2"); + int metric_primary = fieldstat_register_counter(instance, cube_id, "primary"); + int metric_2 = fieldstat_register_counter(instance, cube_id, "2"); fieldstat_counter_incrby(instance, cube_id, metric_primary, &TEST_TAG_STRING, 1, 100); fieldstat_counter_incrby(instance, cube_id, metric_2, &TEST_TAG_STRING, 1, 1); struct fieldstat *instance_dst = fieldstat_new(); int cube_id_dst = fieldstat_create_cube(instance_dst, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 2); - fieldstat_register_counter(instance_dst, "2"); - int metric_primary_dst = fieldstat_register_counter(instance_dst, "primary"); + fieldstat_register_counter(instance_dst, cube_id_dst, "2"); + int metric_primary_dst = fieldstat_register_counter(instance_dst, cube_id_dst, "primary"); fieldstat_cube_set_primary_metric(instance_dst, cube_id_dst, metric_primary_dst); EXPECT_EQ(fieldstat_merge(instance_dst, instance), FS_ERR_INVALID_PARAM); @@ -534,7 +495,7 @@ TEST(unit_test_merge, primary_metric_id_different) TEST(unit_test_merge, new_cube_and_metric_to_empty_spreadsketch) { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_SPREADSKETCH, 10); - fieldstat_register_hll(instance, "metric", 6); + fieldstat_register_hll(instance, 0, "metric", 6); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -543,7 +504,7 @@ TEST(unit_test_merge, new_cube_and_metric_to_empty_spreadsketch) { int n_cube; fieldstat_get_cubes(instance_dest, &cube_id_dest, &n_cube); EXPECT_TRUE(n_cube == 1); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0), "metric"); + EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, cube_id_dest[0], 0), "metric"); free(cube_id_dest); fieldstat_free(instance); @@ -553,7 +514,7 @@ TEST(unit_test_merge, new_cube_and_metric_to_empty_spreadsketch) { TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_spreadsketch) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 10); - int metric_id = fieldstat_register_hll(instance, "metric", 6); + int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 6); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -565,8 +526,7 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_spreadsketch) { int n_cube; fieldstat_get_cubes(instance_dest, &cube_id_dest, &n_cube); EXPECT_TRUE(n_cube == 1); - free(cube_id_dest); - EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, 0), "metric"); + EXPECT_STREQ(fieldstat_get_metric_name(instance_dest, cube_id_dest[0], 0), "metric"); long long measure = merge_test_fieldstat_hll_get(instance, cube_id, metric_id); EXPECT_NEAR(measure, 2, 0.3); @@ -577,6 +537,7 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_spreadsketch) { EXPECT_EQ(tag_list->n_field, 1); EXPECT_STREQ(tag_list->field[0].key, TEST_TAG_STRING.key); + free(cube_id_dest); fieldstat_free(instance); fieldstat_free(instance_dest); fieldstat_tag_list_arr_free(tag_list, n_cell); @@ -585,7 +546,7 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_spreadsketch) { TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_spreadsketch) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 10); - int metric_id = fieldstat_register_hll(instance, "metric", 6); + int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 6); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, "1", 1); struct fieldstat *instance_dest = fieldstat_new(); @@ -609,7 +570,7 @@ TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_spreadsket TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_and_get_different_cube_spreadsketch) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 2); - int metric_id = fieldstat_register_hll(instance, "metric", 6); + int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 6); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, "1", 1); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -641,7 +602,7 @@ TEST(unit_test_merge, gen_dest_full_all_src_inserted_given_src_flows_larger_spre SpreadSketchZipfGenerator flow_generator(1.0, K); // exactly the number of cells, so there will be almost all(in case of hash collision happen) cells added successfully struct fieldstat *instance_src = fieldstat_new(); int cube_id = fieldstat_create_cube(instance_src, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, K); - int metric_id = fieldstat_register_hll(instance_src, "metric", 6); + int metric_id = fieldstat_register_hll(instance_src, cube_id, "metric", 6); struct fieldstat *instance_dest = fieldstat_fork(instance_src); const char dest_key[] = "key of dest"; const char src_key[] = "key of src"; @@ -699,7 +660,7 @@ TEST(unit_test_merge, merge_accuracy_test_gen_dest_full_some_inserted_and_some_m SpreadSketchZipfGenerator flow_generator(1.0, K); // exactly the number of cells, so there will be almost all(in case of hash collision happen) cells added successfully struct fieldstat *instance_src = fieldstat_new(); int cube_id = fieldstat_create_cube(instance_src, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, K); - int metric_id = fieldstat_register_hll(instance_src, "metric", 6); + int metric_id = fieldstat_register_hll(instance_src, cube_id, "metric", 6); struct fieldstat *instance_dest = fieldstat_fork(instance_src); std::unordered_map> flow_cnt; diff --git a/test/test_metric_counter.cpp b/test/test_metric_counter.cpp index 675c42f..c6774f9 100644 --- a/test/test_metric_counter.cpp +++ b/test/test_metric_counter.cpp @@ -13,7 +13,7 @@ struct fieldstat *test_init_standard_instance() int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, 0); - int metric_id = fieldstat_register_counter(instance, "czz_test counter metric"); + int metric_id = fieldstat_register_counter(instance, cube_id, "czz_test counter metric"); EXPECT_EQ(metric_id, 0); return instance; @@ -35,7 +35,7 @@ void test_assert_standard_instance(const struct fieldstat *instance) int ret_cell_id = ret_cube_id_arr[0]; free(ret_cube_id_arr); EXPECT_EQ(ret_cell_id, 0); - const char *name = fieldstat_get_metric_name(instance, 0); + const char *name = fieldstat_get_metric_name(instance, ret_cell_id, 0); EXPECT_STREQ(name, "czz_test counter metric"); struct field_list *tag_list = NULL; @@ -111,7 +111,7 @@ TEST(metric_test_counter, topk_add_and_test_accuracy) { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_TOPK, 10); - fieldstat_register_counter(instance, "test"); + fieldstat_register_counter(instance, 0, "test"); int tag_list_num = 10000; Fieldstat_tag_list_wrapper *fields[tag_list_num]; @@ -179,7 +179,7 @@ TEST(metric_test_counter, add_with_wrong_metric_id_expecting_fail) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_TOPK, 10); - int metric_id = fieldstat_register_counter(instance, "test"); + int metric_id = fieldstat_register_counter(instance, 0, "test"); int ret = fieldstat_counter_incrby(instance, cube_id, metric_id + 1, &TEST_TAG_INT, 1, 1); EXPECT_EQ(ret, FS_ERR_INVALID_METRIC_ID); @@ -193,8 +193,8 @@ TEST(metric_test_counter, add_and_query_on_dummy_cell_of_topk) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); - fieldstat_register_counter(instance, "primary"); // also the dummy one - int metric_id = fieldstat_register_counter(instance, "using"); + fieldstat_register_counter(instance, cube_id, "primary"); // also the dummy one + int metric_id = fieldstat_register_counter(instance, cube_id, "using"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); @@ -216,8 +216,8 @@ TEST(metric_test_counter, primary_counter_add_after_first) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); - int metric_id_primary = fieldstat_register_counter(instance, "primary"); - int metric_id2 = fieldstat_register_counter(instance, "using"); + int metric_id_primary = fieldstat_register_counter(instance, cube_id, "primary"); + int metric_id2 = fieldstat_register_counter(instance, cube_id, "using"); fieldstat_cube_set_primary_metric(instance, cube_id, metric_id_primary); diff --git a/test/test_metric_histogram.cpp b/test/test_metric_histogram.cpp index 06fdd17..84244bf 100644 --- a/test/test_metric_histogram.cpp +++ b/test/test_metric_histogram.cpp @@ -12,7 +12,7 @@ struct fieldstat *test_init_standard_instance_one_cube_one_metric_one_cell_hdr() int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, 0); - int metric_id = fieldstat_register_hist(instance, "czz_test hdr metric", 1, 600000, 3); + int metric_id = fieldstat_register_hist(instance, cube_id, "czz_test hdr metric", 1, 600000, 3); EXPECT_EQ(metric_id, 0); return instance; @@ -27,7 +27,7 @@ void test_assert_standard_instance(const struct fieldstat *instance) int ret_cell_id = ret_cube_id_arr[0]; free(ret_cube_id_arr); EXPECT_EQ(ret_cell_id, 0); - const char *name = fieldstat_get_metric_name(instance, 0); + const char *name = fieldstat_get_metric_name(instance, ret_cell_id, 0); EXPECT_STREQ(name, "czz_test hdr metric"); @@ -121,7 +121,7 @@ TEST(metric_test_histogram, add_with_wrong_metric_id_expecting_fail) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_hist(instance, "czz_test", 1, 600000, 3); + int metric_id = fieldstat_register_hist(instance, cube_id, "czz_test", 1, 600000, 3); int ret = fieldstat_hist_record(instance, cube_id, metric_id + 1, &TEST_TAG_INT, 1, 1); EXPECT_EQ(ret, FS_ERR_INVALID_METRIC_ID); @@ -170,7 +170,7 @@ TEST(metric_test_histogram, can_add_0value) // histogram only allow min_val > 0, { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_hist(instance, "czz_test", 1, 600000, 3); + int metric_id = fieldstat_register_hist(instance, cube_id, "czz_test", 1, 600000, 3); int ret = fieldstat_hist_record(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 0); EXPECT_EQ(ret, 0); diff --git a/test/test_metric_hll.cpp b/test/test_metric_hll.cpp index 7c38de2..66ef404 100644 --- a/test/test_metric_hll.cpp +++ b/test/test_metric_hll.cpp @@ -14,7 +14,7 @@ struct fieldstat *test_init_standard_instance_one_cube_one_metric_one_cell_hll(b int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, 0); - int metric_id = fieldstat_register_hll(instance, "czz_test hll metric", 10); + int metric_id = fieldstat_register_hll(instance, cube_id, "czz_test hll metric", 10); EXPECT_EQ(metric_id, 0); return instance; @@ -29,7 +29,7 @@ void test_assert_standard_instance(const struct fieldstat *instance) int ret_cell_id = ret_cube_id_arr[0]; free(ret_cube_id_arr); EXPECT_EQ(ret_cell_id, 0); - const char *name = fieldstat_get_metric_name(instance, 0); + const char *name = fieldstat_get_metric_name(instance, ret_cell_id, 0); EXPECT_STREQ(name, "czz_test hll metric"); struct field_list *tag_list = NULL; @@ -212,7 +212,7 @@ TEST(metric_test_hll, add_with_wrong_metric_id_expecting_fail) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_hll(instance, "czz_test hll metric", 10); + int metric_id = fieldstat_register_hll(instance, cube_id, "czz_test hll metric", 10); int ret = fieldstat_hll_add(instance, cube_id, metric_id + 1, &TEST_TAG_INT, 1, "hello", 5); EXPECT_EQ(ret, FS_ERR_INVALID_METRIC_ID); @@ -227,7 +227,7 @@ TEST(metric_test_hll, spread_sketch_add_and_test_accuracy) struct fieldstat *instance = fieldstat_new(); int K = 10; fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_SPREADSKETCH, K); - fieldstat_register_hll(instance, "testss", 6); + fieldstat_register_hll(instance, 0, "testss", 6); int n_flows = 100000; std::unordered_map> flow_cnt; diff --git a/test/test_performance.cpp b/test/test_performance.cpp index 5931a81..2a8a8e9 100644 --- a/test/test_performance.cpp +++ b/test/test_performance.cpp @@ -48,7 +48,7 @@ TEST(test_performance, merge_performance_one_instance_comprehensive_counter_empt fieldstat_counter_incrby(instance, cube_id, metric_id, fields, n_field, 1); }; auto metric_register_func = [](struct fieldstat *instance) { - return fieldstat_register_counter(instance, "metric name"); + return fieldstat_register_counter(instance, 0, "metric name"); }; double elapsed = perform_merge_test(metric_add_func, metric_register_func, SAMPLING_MODE_COMPREHENSIVE, true); @@ -65,7 +65,7 @@ TEST(test_performance, merge_performance_one_instance_comprehensive_hll_empty_de fieldstat_hll_add(instance, cube_id, metric_id, fields, n_field, "hello", 5); }; auto metric_register_func = [](struct fieldstat *instance) { - return fieldstat_register_hll(instance, "hll metric", 6); + return fieldstat_register_hll(instance, 0, "hll metric", 6); }; double elapsed = perform_merge_test(metric_add_func, metric_register_func, SAMPLING_MODE_COMPREHENSIVE, true); @@ -75,14 +75,11 @@ TEST(test_performance, merge_performance_one_instance_comprehensive_hll_empty_de TEST(test_performance, merge_performance_one_instance_comprehensive_histogram_empty_dest) { - // int metric_id = fieldstat_register_hist(instance, cube_id, "czz_test", 1, 100000, 1); - // int ret = fieldstat_hist_record(instance, cube_id, metric_id, cell_id, 1234); - auto metric_add_func = [](struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, int n_field) { fieldstat_hist_record(instance, cube_id, metric_id, fields, n_field, 1234); }; auto metric_register_func = [](struct fieldstat *instance) { - return fieldstat_register_hist(instance, "histogram metric", 1, 100000, 1); + return fieldstat_register_hist(instance, 0, "histogram metric", 1, 100000, 1); }; double elapsed = perform_merge_test(metric_add_func, metric_register_func, SAMPLING_MODE_COMPREHENSIVE, true); @@ -96,7 +93,7 @@ TEST(test_performance, merge_performance_one_instance_topk_counter_empty_dest) fieldstat_counter_incrby(instance, cube_id, metric_id, fields, n_field, rand() % 1000); }; auto metric_register_func = [](struct fieldstat *instance) { - return fieldstat_register_counter(instance, "metric name"); + return fieldstat_register_counter(instance, 0, "metric name"); }; double elapsed = perform_merge_test(metric_add_func, metric_register_func, SAMPLING_MODE_TOPK, true); @@ -110,7 +107,7 @@ TEST(test_performance, merge_performance_one_instance_comprehensive_counter_full fieldstat_counter_incrby(instance, cube_id, metric_id, fields, n_field, 1); }; auto metric_register_func = [](struct fieldstat *instance) { - return fieldstat_register_counter(instance, "metric name"); + return fieldstat_register_counter(instance, 0, "metric name"); }; double elapsed = perform_merge_test(metric_add_func, metric_register_func, SAMPLING_MODE_COMPREHENSIVE, false); @@ -124,7 +121,7 @@ TEST(test_performance, merge_performance_one_instance_comprehensive_hll_full_des fieldstat_hll_add(instance, cube_id, metric_id, fields, n_field, "hello", 5); }; auto metric_register_func = [](struct fieldstat *instance) { - return fieldstat_register_hll(instance, "hll metric", 6); + return fieldstat_register_hll(instance, 0, "hll metric", 6); }; double elapsed = perform_merge_test(metric_add_func, metric_register_func, SAMPLING_MODE_COMPREHENSIVE, false); @@ -138,7 +135,7 @@ TEST(test_performance, merge_performance_one_instance_comprehensive_histogram_fu fieldstat_hist_record(instance, cube_id, metric_id, fields, n_field, 1234); }; auto metric_register_func = [](struct fieldstat *instance) { - return fieldstat_register_hist(instance, "histogram metric", 1, 100000, 1); + return fieldstat_register_hist(instance, 0, "histogram metric", 1, 100000, 1); }; double elapsed = perform_merge_test(metric_add_func, metric_register_func, SAMPLING_MODE_COMPREHENSIVE, false); @@ -152,7 +149,7 @@ TEST(test_performance, merge_performance_one_instance_topk_counter_full_dest) fieldstat_counter_incrby(instance, cube_id, metric_id, fields, n_field, rand() % 1000); }; auto metric_register_func = [](struct fieldstat *instance) { - return fieldstat_register_counter(instance, "metric name"); + return fieldstat_register_counter(instance,0, "metric name"); }; double elapsed = perform_merge_test(metric_add_func, metric_register_func, SAMPLING_MODE_TOPK, false); @@ -166,10 +163,10 @@ struct fieldstat *construct_fs_with_many_empty_cubes(int cube_num, int metric_nu struct field tmp_tag = TEST_TAG_INT; for (int i = 0; i < cube_num; i++) { tmp_tag.value_longlong = i; - fieldstat_create_cube(instance, &tmp_tag, 1, mode, 1000); + int cube_id = fieldstat_create_cube(instance, &tmp_tag, 1, mode, 1000); for (int j = 0; j < metric_num; j++) { - fieldstat_register_counter(instance, std::to_string(j).c_str()); + fieldstat_register_counter(instance, cube_id, std::to_string(j).c_str()); } } return instance; @@ -223,7 +220,7 @@ TEST(test_performance, performance_test_add_cells_comprehensive) // getchar(); struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, cell_count); - fieldstat_register_counter(instance, "test"); + fieldstat_register_counter(instance, 0, "test"); clock_t start = clock(); for (size_t i = 0; i < cell_count; i++) { @@ -250,7 +247,7 @@ TEST(test_performance, performance_test_add_cells_topk) } struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_TOPK, 1000); - fieldstat_register_counter(instance, "test"); + fieldstat_register_counter(instance, 0, "test"); // getchar(); clock_t start = clock(); @@ -271,7 +268,7 @@ TEST(test_performance, performance_test_add_cells_histogram_record) { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_hist(instance, "test", 1, 100000, 3); + fieldstat_register_hist(instance, 0, "test", 1, 100000, 3); size_t test_num = 100000; long long vals[test_num]; for (size_t i = 0; i < test_num; i++) { @@ -292,7 +289,7 @@ TEST(test_performance, performance_test_add_cells_hll_add) { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_hll(instance, "test", 6); + fieldstat_register_hll(instance, 0, "test", 6); size_t test_num = 100000; std::string vals[test_num]; for (size_t i = 0; i < test_num; i++) { @@ -329,7 +326,7 @@ TEST(test_performance, performance_test_add_cells_comprehensive_5_tags) // getchar(); struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, cell_count); - fieldstat_register_counter(instance, "test"); + fieldstat_register_counter(instance, 0, "test"); clock_t start = clock(); for (size_t i = 0; i < cell_count; i++) { @@ -350,7 +347,7 @@ TEST(test_performance, performance_test_add_cells_histogram_record_5tags) { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_hist(instance, "test", 1, 100000, 3); + fieldstat_register_hist(instance, 0, "test", 1, 100000, 3); size_t test_num = 100000; long long vals[test_num]; for (size_t i = 0; i < test_num; i++) { @@ -378,7 +375,7 @@ TEST(test_performance, performance_test_add_cells_hll_add_5tags) { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_hll(instance, "test", 6); + fieldstat_register_hll(instance, 0, "test", 6); size_t test_num = 100000; std::string vals[test_num]; for (size_t i = 0; i < test_num; i++) { @@ -426,7 +423,7 @@ TEST(test_performance, export_many_cells) for (int j = 0; j < METRIC_NUM; j++) { string metric_name = "metric name" + to_string(i) + to_string(j); - int metric_id = fieldstat_register_counter(instance, metric_name.c_str()); + int metric_id = fieldstat_register_counter(instance, cube_id, metric_name.c_str()); for (int k = 0; k < MAX_CELL_NUM; k++) { fieldstat_counter_incrby(instance, cube_id, metric_id, fields[rand() % TAG_NUM]->get_tag(), 1, 1); @@ -500,7 +497,7 @@ struct fieldstat *construct_fs_with_many_cells(int cell_num, enum sampling_mode { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT, 1, mode, cell_num); - fieldstat_register_counter(instance, "test"); + fieldstat_register_counter(instance, 0, "test"); struct field tmp_tag = TEST_TAG_INT; for (int i = 0; i < cell_num; i++) { tmp_tag.value_longlong = i; diff --git a/test/test_register_and_reset.cpp b/test/test_register_and_reset.cpp index d94e935..36902e1 100644 --- a/test/test_register_and_reset.cpp +++ b/test/test_register_and_reset.cpp @@ -19,7 +19,7 @@ TEST(test_register, delete_comprehensive_cube_with_cells_and_metrics) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); fieldstat_destroy_cube(instance, cube_id); @@ -36,7 +36,7 @@ TEST(test_register, delete_topk_cube_with_cells_and_metrics) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); fieldstat_destroy_cube(instance, cube_id); @@ -52,8 +52,8 @@ TEST(test_register, delete_spreadsketch_cube_with_cells_and_metrics) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 10); - int metric_id1 = fieldstat_register_counter(instance, "counter"); - int metric_primary = fieldstat_register_hll(instance, "hll_primary", 5); + int metric_id1 = fieldstat_register_counter(instance, cube_id, "counter"); + int metric_primary = fieldstat_register_hll(instance, cube_id, "hll_primary", 5); fieldstat_cube_set_primary_metric(instance, cube_id, metric_primary); fieldstat_counter_incrby(instance, cube_id, metric_id1, &TEST_TAG_INT, 1, 1); fieldstat_hll_add_field(instance, cube_id, metric_primary, &TEST_TAG_INT, 1, &TEST_TAG_DOUBLE, 1); @@ -72,7 +72,7 @@ int test_get_max_metric_id(const struct fieldstat *instance) { int *metric_id_out; size_t n_metric; - (void)fieldstat_get_metrics(instance, &metric_id_out, &n_metric); + (void)fieldstat_cube_get_metrics(instance, 0, &metric_id_out, &n_metric); free(metric_id_out); return n_metric - 1; } @@ -81,7 +81,7 @@ TEST(test_register, reset_and_try_to_query_cell_comprehensive) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); fieldstat_reset(instance); @@ -100,7 +100,7 @@ TEST(test_register, reset_and_try_to_query_cell_topk) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); fieldstat_reset(instance); @@ -119,7 +119,7 @@ TEST(test_register, reset_and_try_to_query_cell_spreadsketch) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 10); - int metric_id = fieldstat_register_hll(instance, "hll", 5); + int metric_id = fieldstat_register_hll(instance, cube_id, "hll", 5); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_INT, 1, "12abc", 5); fieldstat_reset(instance); @@ -138,7 +138,7 @@ TEST(test_register, reset_and_new_cell_comprehensive) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 2); - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, 1); int ret = fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, 1); @@ -155,7 +155,7 @@ TEST(test_register, reset_and_new_cell_topk) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 1); - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 100);//100: bigger value int ret = fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, 1); EXPECT_EQ(ret, FS_ERR_TOO_MANY_CELLS); @@ -171,7 +171,7 @@ TEST(test_register, reset_and_new_cell_spreadsketch) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 1); - int metric_id = fieldstat_register_hll(instance, "hll", 5); + int metric_id = fieldstat_register_hll(instance, cube_id, "hll", 5); // spread sketch will store more data than expected cell number 1. So loop for many cells first to trigger the error struct field test_tag_long = TEST_TAG_INT; for (int i = 0; i < 10000; i++) { @@ -192,7 +192,7 @@ TEST(test_register, ensure_recovery_more_faster_comprehensive) { struct fieldstat *instance = fieldstat_new(); int cell_num = 1000; int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, cell_num); - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); struct field test_tag_long = TEST_TAG_INT; clock_t start = clock(); @@ -222,7 +222,7 @@ TEST(test_register, ensure_recovery_more_faster_topk) { struct fieldstat *instance = fieldstat_new(); int cell_num = 1000; int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, cell_num); - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); struct field test_tag_long = TEST_TAG_INT; clock_t start = clock(); @@ -252,7 +252,7 @@ TEST(test_register, ensure_recovery_more_faster_spreadsketch) { struct fieldstat *instance = fieldstat_new(); int cell_num = 1000; int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, cell_num); - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_hll(instance, cube_id, "counter", 6); struct field test_tag_long = TEST_TAG_INT; clock_t start = clock(); @@ -273,7 +273,6 @@ TEST(test_register, ensure_recovery_more_faster_spreadsketch) { end = clock(); clock_t duration_reset = end - start; - printf("initialize: %ld, reset: %ld\n", duration_initialize, duration_reset); EXPECT_LT(duration_reset, duration_initialize); fieldstat_free(instance); @@ -288,11 +287,11 @@ TEST(test_register, register_many_cubes) shared_tag.value_longlong = i; int cube_id = fieldstat_create_cube(instance, &shared_tag, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, i); + fieldstat_register_counter(instance, cube_id, "counter"); } // try to use the cube - int metric_id = fieldstat_register_counter(instance, "counter"); for (int i = 0; i < registered_cube; i++) { - fieldstat_counter_incrby(instance, i, metric_id, &TEST_TAG_INT, 1, i); + fieldstat_counter_incrby(instance, i, 0, &TEST_TAG_INT, 1, i); } for (int i = 0; i < registered_cube; i++) { @@ -314,7 +313,7 @@ TEST(test_register, add_many_tagged_cells) test_tag_long[i] = TEST_TAG_INT; // will trigger realloc } - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, test_tag_long, n_field, 10086); long long result; @@ -335,7 +334,7 @@ TEST(test_register, add_long_tagged_cells) long_string[5000] = '\0'; test_tag_long.value_str = long_string; - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &test_tag_long, 1, 10086); long long result; @@ -353,7 +352,7 @@ TEST(test_register, register_many_metrics) int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = 0; for (int i = 0; i < 200; i++) { - metric_id = fieldstat_register_counter(instance, (std::string("counter ") + std::to_string(i)).c_str()); + metric_id = fieldstat_register_counter(instance, cube_id, (std::string("counter ") + std::to_string(i)).c_str()); EXPECT_EQ(metric_id, i); } @@ -383,8 +382,8 @@ TEST(test_register, fork_registered_info_with_cube_and_metric) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_counter(instance, "counter"); - int metric_id2 = fieldstat_register_counter(instance, "counter2"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); + int metric_id2 = fieldstat_register_counter(instance, cube_id, "counter2"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); int cube_id_del = fieldstat_create_cube(instance, &TEST_TAG_DOUBLE_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_create_cube(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); @@ -407,12 +406,14 @@ TEST(test_register, fork_registered_info_with_cube_and_metric) tag_list = fieldstat_cube_get_tags(dup, cube_ids[1]); EXPECT_STREQ(tag_list->field[0].key, TEST_TAG_DOUBLE.key); - free(cube_ids); + fieldstat_tag_list_arr_free(tag_list, 1); - EXPECT_STREQ(fieldstat_get_metric_name(dup, metric_id), "counter"); - EXPECT_STREQ(fieldstat_get_metric_name(dup, metric_id2), "counter2"); + EXPECT_STREQ(fieldstat_get_metric_name(dup, cube_ids[0], metric_id), "counter"); + EXPECT_STREQ(fieldstat_get_metric_name(dup, cube_ids[0], metric_id2), "counter2"); + EXPECT_EQ(fieldstat_get_metric_name(dup, cube_ids[1], metric_id), nullptr); + free(cube_ids); fieldstat_free(dup); fieldstat_free(instance); } @@ -424,8 +425,8 @@ TEST(test_register, unregister_cube_on_wrong_instance) int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int cube_id2 = fieldstat_create_cube(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_counter(instance, "counter"); - int metric_id2 = fieldstat_register_counter(instance, "counter2"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); + int metric_id2 = fieldstat_register_counter(instance, cube_id2, "counter2"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); fieldstat_counter_incrby(instance, cube_id2, metric_id2, &TEST_TAG_INT, 1, 1); @@ -444,7 +445,7 @@ TEST(test_register, unregister_cube_on_wrong_instance) long long val_deleted_once; fieldstat_counter_get(instance_dst, cube_id, &TEST_TAG_LIST_INT,metric_id, &val_deleted_once); EXPECT_EQ(val_deleted_once, 1); - long long val_merged_twice; + long long val_merged_twice = -1; fieldstat_counter_get(instance_dst, cube_id2, &TEST_TAG_LIST_INT, metric_id2, &val_merged_twice); EXPECT_EQ(val_merged_twice, 2); @@ -457,7 +458,7 @@ TEST(test_register, register_many_cells_on_unlimited_sized_cube) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 0); - int metric_id = fieldstat_register_counter(instance, "counter"); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); struct field test_tag = {"abc", TAG_INTEGER, {.value_longlong = 0}}; for (int i = 0; i < 10000; i++) { test_tag.value_longlong = i; @@ -497,8 +498,10 @@ TEST(test_register, find_cube) { TEST(test_register, register_metric_twice) { struct fieldstat *instance = fieldstat_new(); - fieldstat_register_counter(instance, "counter"); - int metric_id2 = fieldstat_register_counter(instance, "counter"); + int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + + fieldstat_register_counter(instance, cube_id, "counter"); + int metric_id2 = fieldstat_register_counter(instance, cube_id, "counter"); EXPECT_EQ(metric_id2, FS_ERR_INVALID_KEY); fieldstat_free(instance); } @@ -507,14 +510,14 @@ TEST(calibrate, target_one_more_metric) { struct fieldstat *master = fieldstat_new(); int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_counter(master, "counter"); + fieldstat_register_counter(master, cube_id, "counter"); struct fieldstat *target = fieldstat_fork(master); - EXPECT_EQ(fieldstat_register_counter(target, "counter2"), 1); + EXPECT_EQ(fieldstat_register_counter(target, cube_id, "counter2"), 1); fieldstat_calibrate(master, target); EXPECT_EQ(test_get_max_metric_id(target), 0); - EXPECT_STREQ(fieldstat_get_metric_name(target, 0), "counter"); + EXPECT_STREQ(fieldstat_get_metric_name(target, cube_id, 0), "counter"); struct field_list *tag_list = fieldstat_cube_get_tags(target, cube_id); EXPECT_STREQ(tag_list->field[0].key, TEST_SHARED_TAG.key); @@ -527,15 +530,15 @@ TEST(calibrate, master_one_more_metric) { struct fieldstat *master = fieldstat_new(); int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_counter(master, "counter"); + fieldstat_register_counter(master, cube_id, "counter"); struct fieldstat *target = fieldstat_fork(master); - EXPECT_EQ(fieldstat_register_counter(master, "counter2"), 1); + EXPECT_EQ(fieldstat_register_counter(master, cube_id, "counter2"), 1); fieldstat_calibrate(master, target); EXPECT_EQ(test_get_max_metric_id(target), 1); - EXPECT_STREQ(fieldstat_get_metric_name(target, 0), "counter"); - EXPECT_STREQ(fieldstat_get_metric_name(target, 1), "counter2"); + EXPECT_STREQ(fieldstat_get_metric_name(target, cube_id,0), "counter"); + EXPECT_STREQ(fieldstat_get_metric_name(target, cube_id,1), "counter2"); struct field_list *tag_list = fieldstat_cube_get_tags(target, cube_id); EXPECT_STREQ(tag_list->field[0].key, TEST_SHARED_TAG.key); @@ -549,16 +552,16 @@ TEST(calibrate, different_metric) { struct fieldstat *master = fieldstat_new(); int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_counter(master, "counter"); + fieldstat_register_counter(master, cube_id, "counter"); struct fieldstat *target = fieldstat_fork(master); - EXPECT_EQ(fieldstat_register_counter(target, "counter2"), 1); - EXPECT_EQ(fieldstat_register_counter(master, "hi i am master new"), 1); + EXPECT_EQ(fieldstat_register_counter(target, cube_id, "counter2"), 1); + EXPECT_EQ(fieldstat_register_counter(master, cube_id, "hi i am master new"), 1); fieldstat_calibrate(master, target); EXPECT_EQ(test_get_max_metric_id(target), 1); - EXPECT_STREQ(fieldstat_get_metric_name(target, 0), "counter"); - EXPECT_STREQ(fieldstat_get_metric_name(target, 1), "hi i am master new"); + EXPECT_STREQ(fieldstat_get_metric_name(target, cube_id, 0), "counter"); + EXPECT_STREQ(fieldstat_get_metric_name(target, cube_id, 1), "hi i am master new"); struct field_list *tag_list = fieldstat_cube_get_tags(target, cube_id); EXPECT_STREQ(tag_list->field[0].key, TEST_SHARED_TAG.key); @@ -571,11 +574,11 @@ TEST(calibrate, target_more_cube) { struct fieldstat *master = fieldstat_new(); int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_counter(master, "counter"); + fieldstat_register_counter(master, cube_id, "counter"); struct fieldstat *target = fieldstat_fork(master); int cube_id2 = fieldstat_create_cube(target, &TEST_TAG_STRING, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id2, 1); - fieldstat_register_counter(target, "counter2"); + fieldstat_register_counter(target, cube_id, "counter2"); fieldstat_calibrate(master, target); @@ -587,7 +590,7 @@ TEST(calibrate, target_more_cube) free(cube_ids); EXPECT_EQ(test_get_max_metric_id(target), 0); - EXPECT_STREQ(fieldstat_get_metric_name(target, 0), "counter"); + EXPECT_STREQ(fieldstat_get_metric_name(target, cube_id, 0), "counter"); struct field_list *tag_list = fieldstat_cube_get_tags(target, cube_id); EXPECT_STREQ(tag_list->field[0].key, TEST_SHARED_TAG.key); @@ -634,7 +637,6 @@ TEST(calibrate, master_change_cube) { struct fieldstat *master = fieldstat_new(); int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_counter(master, "counter"); struct fieldstat *target = fieldstat_fork(master); fieldstat_destroy_cube(master, cube_id); fieldstat_create_cube(master, &TEST_TAG_STRING, 1, SAMPLING_MODE_COMPREHENSIVE, 10); @@ -766,5 +768,6 @@ TEST(calibrate, delete_first_cube) int main(int argc, char *argv[]) { testing::InitGoogleTest(&argc, argv); + // testing::GTEST_FLAG(filter) = "test_register.ensure_recovery_more_faster_spreadsketch"; return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/test/test_write_json_file.cpp b/test/test_write_json_file.cpp index 1b5fd5f..1c6a969 100644 --- a/test/test_write_json_file.cpp +++ b/test/test_write_json_file.cpp @@ -71,7 +71,7 @@ static void write_hll(struct fieldstat *instance) { for(unsigned int i = 0; i < sizeof(hll_name) / sizeof(hll_name[0]); i++) { - int hll_id = fieldstat_register_hll(instance, hll_name[i], 5); + int hll_id = fieldstat_register_hll(instance, cube_id, hll_name[i], 5); for(int j = 0; j < 100; j++) { @@ -112,7 +112,7 @@ void write_histogram(struct fieldstat *instance) { for(unsigned int i = 0; i < sizeof(hist_names)/sizeof(hist_names[0]); i++) { - int hist_id = fieldstat_register_hist(instance, hist_names[i], 1, 600000, 3); + int hist_id = fieldstat_register_hist(instance, cube_id, hist_names[i], 1, 600000, 3); for(int j = 0; j < 100; j++) { @@ -188,9 +188,9 @@ void write_table(struct fieldstat *instance) { int cube_id = fieldstat_create_cube(instance, shared_tags, 2, SAMPLING_MODE_COMPREHENSIVE, 100); - int counter_id_0 = fieldstat_register_counter(instance, "T_success_log"); + int counter_id_0 = fieldstat_register_counter(instance, cube_id, "T_success_log"); - int counter_id_1 = fieldstat_register_counter(instance, "T_fail_log"); + int counter_id_1 = fieldstat_register_counter(instance, cube_id, "T_fail_log"); for(unsigned int i = 0; i < sizeof(cell_tag_value)/sizeof(cell_tag_value[0]); i++) { -- cgit v1.2.3 From 6b3dcefab5b4049a3f40be9faab6a05c79a8bb5b Mon Sep 17 00:00:00 2001 From: chenzizhan Date: Fri, 12 Jul 2024 18:37:40 +0800 Subject: renames --- CMakeLists.txt | 4 +- include/fieldstat/fieldstat new.h | 240 ----------- include/fieldstat/fieldstat.h | 20 +- readme_fieldstat.md | 2 +- readme_fieldstat_easy.md | 2 +- src/cells/hash_table.c | 230 +++++++++++ src/cells/hash_table.h | 30 ++ src/cells/heavy_keeper.c | 822 +++++++++++++++++++++++++++++++++++++ src/cells/heavy_keeper.h | 48 +++ src/cells/spread_sketch.c | 366 +++++++++++++++++ src/cells/spread_sketch.h | 41 ++ src/cube.c | 75 ++-- src/exporter/cjson_exporter.c | 46 +-- src/exporter/fieldstat_exporter.py | 16 +- src/fieldstat.c | 10 +- src/fieldstat_easy.c | 10 +- src/metrics/python_api.c | 4 +- src/tags/heavy_keeper.c | 822 ------------------------------------- src/tags/heavy_keeper.h | 48 --- src/tags/spread_sketch.c | 365 ---------------- src/tags/spread_sketch.h | 41 -- src/tags/tag_map.c | 230 ----------- src/tags/tag_map.h | 30 -- test/CMakeLists.txt | 2 +- test/profiling/CMakeLists.txt | 2 +- test/profiling/main.c | 18 +- test/test_easy_fs.cpp | 6 +- test/test_empty_tags.cpp | 2 +- test/test_exporter_json.cpp | 62 +-- test/test_fuzz_test.cpp | 6 +- test/test_merge.cpp | 28 +- test/test_metric_histogram.cpp | 52 +-- test/test_metric_hll.cpp | 4 +- test/test_performance.cpp | 20 +- test/test_register_and_reset.cpp | 32 +- test/test_write_json_file.cpp | 34 +- test/utils.cpp | 42 +- test/utils.hpp | 16 +- 38 files changed, 1794 insertions(+), 2034 deletions(-) delete mode 100644 include/fieldstat/fieldstat new.h create mode 100644 src/cells/hash_table.c create mode 100644 src/cells/hash_table.h create mode 100644 src/cells/heavy_keeper.c create mode 100644 src/cells/heavy_keeper.h create mode 100644 src/cells/spread_sketch.c create mode 100644 src/cells/spread_sketch.h delete mode 100644 src/tags/heavy_keeper.c delete mode 100644 src/tags/heavy_keeper.h delete mode 100644 src/tags/spread_sketch.c delete mode 100644 src/tags/spread_sketch.h delete mode 100644 src/tags/tag_map.c delete mode 100644 src/tags/tag_map.h (limited to 'test/test_write_json_file.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index 06c35b7..80c6cd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,14 +98,14 @@ include_directories(${PROJECT_SOURCE_DIR}/vendors) include_directories(${PROJECT_SOURCE_DIR}/src) include_directories(${PROJECT_SOURCE_DIR}/include/fieldstat) include_directories(${PROJECT_SOURCE_DIR}/src/metrics) -include_directories(${PROJECT_SOURCE_DIR}/src/tags) +include_directories(${PROJECT_SOURCE_DIR}/src/cells) include_directories(${PROJECT_SOURCE_DIR}/src/utils) file(GLOB SRC "src/*.c" "src/metrics/*.c" - "src/tags/*.c" + "src/cells/*.c" "src/exporter/*.c" "src/utils/*.c" "vendors/cjson/*.c" diff --git a/include/fieldstat/fieldstat new.h b/include/fieldstat/fieldstat new.h deleted file mode 100644 index f9dcfda..0000000 --- a/include/fieldstat/fieldstat new.h +++ /dev/null @@ -1,240 +0,0 @@ -#pragma once -#include -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -#define FS_OK 0 -#define FS_ERR_TOO_MANY_CELLS -1 -#define FS_ERR_NULL_HANDLER -2 -#define FS_ERR_INVALID_CUBE_ID -3 -#define FS_ERR_INVALID_METRIC_ID -4 -#define FS_ERR_INVALID_TAG -5 -#define FS_ERR_INVALID_PARAM -6 -#define FS_ERR_INVALID_KEY -7 - -enum metric_type -{ - METRIC_TYPE_COUNTER, - METRIC_TYPE_HLL, - METRIC_TYPE_HISTOGRAM, -}; - -enum field_type -{ - TAG_INTEGER, - TAG_DOUBLE, - TAG_CSTRING, -}; - -enum sampling_mode { - SAMPLING_MODE_COMPREHENSIVE, - SAMPLING_MODE_TOPK, - SAMPLING_MODE_SPREADSKETCH, -}; - -struct field { - const char *key; - enum field_type type; - union{ - long long value_longlong; - double value_double; - const char *value_str; - }; -}; - -struct fieldstat; -struct fieldstat *fieldstat_new(); -void fieldstat_free(struct fieldstat *instance); -// copy only registered cubes and metrics, not including cells. Used to new a instance of the same schema. -struct fieldstat *fieldstat_fork(const struct fieldstat *instance); - -/* - * let the configuration of target be the same as master, no matter what the configuration of target is. - * the configurations will be kept as much as possible, like cells in the same cube will be kept, but the cells in different cubes will be deleted. - * @ return FS_OK or FS_ERR_NULL_HANDLER -*/ -int fieldstat_calibrate(const struct fieldstat *master, struct fieldstat *replica); -/* - * @brief add an cube to this instance. Cube represents an template with a user-defined set of cells and metrics. - * @param cube_dimensions: tags that are shared by all cells in this cube. This is the key of the cube. Can be NULL. Must be unique. Shared_tags are ordered, which means that {"TAG_KEY": "123", "TAG_KEY2": "456"} and {"TAG_KEY2": "456", "TAG_KEY": "123"} are map to different cube. - * @param n_dimension: number of field in dimension. - * @param mode: sampling mode. Refer to enum sampling_mode. - * @param max_n_cell: max number of samplings(cells) in each cube. When mode is TOPK, max_n_cell > 0, while in COMPREHENSIVE mode, max_n_cell can be 0, meaning that there is no limit. - * @return cube id, if success; otherwise, return FS_ERR_NULL_HANDLER, or FS_ERR_INVALID_PARAM when (max_n_cell == 0 && mode == TOPK). return FS_ERR_INVALID_KEY when the cube_dimensions is not unique. -*/ -int fieldstat_create_cube(struct fieldstat *instance, const struct field *cube_dimensions, size_t n_dimension, enum sampling_mode mode, size_t max_n_cell); - -/* - @brief Change the topk cube primary metric id. When fieldstat_counter_add or fieldstat_counter_set are called on the primary metric, the topk record of such cell will be updated. - the default primary metric id is 0. - @return FS_OK, FS_ERR_NULL_HANDLER or FS_ERR_INVALID_CUBE_ID. - FS_ERR_INVALID_METRIC_ID when the metric is not registered to instance. - FS_ERR_INVALID_PARAM when the cube is not a topk sampling cube, or the metric is not a counter. - -*/ -int fieldstat_cube_set_primary_metric(struct fieldstat *instance, int cube_id, int metric_id); - -/* - * @brief Delete the cube of cube_id. All the cells and metrics are deleted. The cube_id may be reused by other new cubes. Increase the corresponding cube_version by 1. - * @return FS_OK, FS_ERR_NULL_HANDLER or FS_ERR_INVALID_CUBE_ID -*/ -int fieldstat_destroy_cube(struct fieldstat *instance, int cube_id); - -/* - * @brief add a metric to the cube of cube_id. One metric may be associated with different cells. - * @param metric_name: name of the metric. Cannot be NULL. Must be unique. - * @return metric id>=0 if success. If failed, return FS_ERR_NULL_HANDLER, FS_ERR_INVALID_KEY(when metric_name is not unique in this cube) -*/ -int fieldstat_register_counter(struct fieldstat *instance, int cube_id, const char *metric_name); - -/* - * @brief refer to fieldstat_register_counter. - * @param precision: the bigger, the larger memory consumption, while accuracy improved. Must be in [4, 18]. - * @return metric id if success. If failed, return FS_ERR_NULL_HANDLER, FS_ERR_INVALID_KEY(when metric_name is not unique in this cube), or FS_ERR_INVALID_PARAM(if precision not in range) -*/ -int fieldstat_register_hll(struct fieldstat *instance, int cube_id, const char *metric_name, unsigned char precision); - -/* - * @brief refer to fieldstat_register_counter. - * @param lowest_trackable_value: the lowest value that can be tracked (distinguishable from 0) by the histogram. Must be >= 1. - * @param highest_trackable_value: the highest value to be tracked by the histogram. Must be >= 2 * lowest_trackable_value. - * @param significant_figures: the precision of the histogram. Must be in [1, 5]. - * @return metric id if success. If failed, return FS_ERR_NULL_HANDLER, FS_ERR_INVALID_KEY(when metric_name is not unique in this cube), or FS_ERR_INVALID_PARAM(if any of the 3 params are out of range) -*/ -int fieldstat_register_hist(struct fieldstat *instance, int cube_id, const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures); - -/* - * @brief let the value of counter metric of cell_id increase by `increment`. - * @param cube_id: cube id, previously returned by fieldstat_create_cube. - * @param metric_id: metric id, previously returned by fieldstat_register_counter. - * @param increment: increment of the counter metric. Can be negative. - * @return FS_OK if success. FS_ERR_NULL_HANDLER, FS_ERR_INVALID_CUBE_ID, FS_ERR_INVALID_METRIC_ID if fail. - * FS_ERR_INVALID_PARAM when cube is topk, metric is primary metric, and increment is negative. - * FS_ERR_TOO_MANY_CELLS when the cube is full. - * In comprehensive mode, a full cube cannot be added any more cells. - * In topk mode, every increment matters, so even the cube is full, the cell can also replace the least frequent cell. -*/ -int fieldstat_counter_incrby(struct fieldstat *instance, int cube_id, int metric_id, const struct field *cell_dimensions, size_t n_dimensions, long long increment); - -/* - * @brief let the value of counter metric equal to value. Other annotations refer to fieldstat_counter_incrby. - * @return Refer to fieldstat_counter_incrby. What's more, be cautious to call this function if the metric is a primary metric of a topk cube, - * in such case, FS_ERR_INVALID_PARAM will be the output when the value is set to a smaller one(increment is negative). -*/ -int fieldstat_counter_set(struct fieldstat *instance, int cube_id, int metric_id, const struct field *cell_dimensions, size_t n_dimensions, long long value); - -/* - * @brief add a key to the hll metric of cell_id. HLL approximates the number of distinct elements in a set of `key`s. - * @param key: key of the hll metric. Cannot be NULL. - * @param key_len: strlen(key). - * @return FS_OK if success. FS_ERR_NULL_HANDLER, FS_ERR_INVALID_CUBE_ID, FS_ERR_INVALID_METRIC_ID if fail. - * Since topk only support counter, FS_ERR_INVALID_PARAM is returned when the cube is topk. -*/ -int fieldstat_hll_add(struct fieldstat *instance, int cube_id, int metric_id, const struct field *cell_dimensions, size_t n_dimensions, const char *key, size_t key_len); -int fieldstat_hll_add_field(struct fieldstat *instance, int cube_id, int metric_id, const struct field *cell_dimensions, size_t n_dimensions, const struct field *item, size_t item_len); - - -/* - * @brief Add a value to the histogram metric of cell_id. Histogram will record the distribution of the values. - The value bigger than highest_trackable_value will be set to highest_trackable_value. The value less than lowest_trackable_value will be tried to record, and, if succeed, remains in the record as -inf(most of the time) or 0(if value == 0) - * @param value: value of the histogram metric. - * @return FS_OK if success. FS_ERR_NULL_HANDLER, FS_ERR_INVALID_CUBE_ID, FS_ERR_INVALID_METRIC_ID if fail. - * FS_ERR_INVALID_PARAM when value is less than 0, or the cube is topk. -*/ -int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id, const struct field *cell_dimensions, size_t n_dimensions, long long value); - -/* - * @brief Delete all the cells, also the content of every metrics. The cube and metrics are not deleted. Increase cell_version by 1. - Note that the cell record won't be deleted at once, they just seem to be deleted. The cell record will be deleted when they are not used since the last reset and until the next reset. -*/ -void fieldstat_reset(struct fieldstat *instance); - -/* - @brief Merge the instance. The registered cubes and metrics are merged even if there are no cells added. - @return 0 if success. return FS_ERR_INVALID_PARAM when the registered cubes or metrics between dest and src of the same keys has different types or configurations(like different primary metric). -*/ -int fieldstat_merge(struct fieldstat *instance, const struct fieldstat *src); - -/* -------------------------------------------------------------------------- */ -/* query */ -/* -------------------------------------------------------------------------- */ - -struct field_list -{ - struct field *field; - size_t n_field; -}; - -/* - * @brief Get all the registered cubes. - * @param cube_ids: the cube ids. The caller should free it. Use it like: int *cube_ids; fieldstat_get_cubes(instance, &cube_ids, &n_cube); for (int i = 0; i < n_cube; i++) { printf("%d\n", cube_ids[i]); } free(cube_ids); - * @param n_cube: Length of cube_ids. -*/ -void fieldstat_get_cubes(const struct fieldstat *instance, int **cube_ids, int *n_cube); - -/* - * @brief Get all the registered metrics by fieldstat_register_counter, fieldstat_register_hll, fieldstat_register_hist. -*/ -void fieldstat_cube_get_metrics(const struct fieldstat *instance, int cube_id, int **metric_id_out, size_t *n_metric); - -void fieldstat_get_metric_in_cell(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int **metric_id_out, size_t *n_metric_out); - -// query the name of the metric, return NULL if metric_id is invalid. -const char *fieldstat_get_metric_name(const struct fieldstat *instance, int cube_id, int metric_id); - -// query the type of the metric. return (enum metric_type)-1 if metric_id is invalid. -enum metric_type fieldstat_get_metric_type(const struct fieldstat *instance, int cube_id, int metric_id); - -/* - get the cell_dimensions added to cube when calling fieldstat_counter_incrby, fieldstat_counter_set, fieldstat_hll_add, fieldstat_hist_record. -*/ -void fieldstat_cube_get_cells(const struct fieldstat *instance, int cube_id, struct field_list **cell_dimensions, size_t *n_cell); - -/* - get the field of fieldstat_create_cube. User free them by calling fieldstat_tag_list_arr_free(struct field_list *, 1) - return NULL when ID is invalid. -*/ -struct field_list *fieldstat_cube_get_tags(const struct fieldstat *instance, int cube_id); - -/* - return a cube id corresponding to `cube_dimensions`. FS_ERR_INVALID_KEY is returned if the cube is not found. -*/ -int fieldstat_find_cube(const struct fieldstat *instance, const struct field *cube_dimensions, size_t n_dimensions); - -/* - get the cell numbers in a cube. Return FS_ERR_INVALID_CUBE_ID if cube_id is invalid. -*/ -int fieldstat_get_used_sampling(const struct fieldstat *instance, int cube_id); - -/* - * @brief Get the value of a metric of a cell. - * @param cube_id: cube id, previously returned by fieldstat_get_cubes. - * @param metric_id: metric id, previously returned by fieldstat_get_max_metric_id. - * @param cell_dimensions: previously returned by fieldstat_get_cells_used_by_metric. - * @param value_out: the value of the metric. If the cell is not found, *value_out is set to 0. - * @return FS_OK if success. FS_ERR_NULL_HANDLER, FS_ERR_INVALID_CUBE_ID, FS_ERR_INVALID_METRIC_ID if fail. -*/ -int fieldstat_counter_get(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, long long *value); - -/* - @brief Get an approximate count of the number of distinct elements in the cell. Other information refer to fieldstat_counter_get. - @return >= 0 if success. FS_ERR_INVALID_PARAM if precision is invalid. -*/ -int fieldstat_hll_get(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, double *value); -long long fieldstat_hist_value_at_percentile(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, double percentile); -long long fieldstat_hist_count_le_value(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, long long value); - -// get the base 64 encoded string of the serialized blob of a cell -void fieldstat_get_serialized_blob(const struct fieldstat *instance, int cube_id, int metric_id, const struct field_list *cell_dimensions, char **blob, size_t *blob_size); - -void fieldstat_tag_list_arr_free(struct field_list *tag_list, size_t n_cell); - - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/include/fieldstat/fieldstat.h b/include/fieldstat/fieldstat.h index c121a48..dc3db94 100644 --- a/include/fieldstat/fieldstat.h +++ b/include/fieldstat/fieldstat.h @@ -26,15 +26,15 @@ enum metric_type enum field_type { - TAG_INTEGER, // TODO: rename - TAG_DOUBLE, - TAG_CSTRING, + FIELD_VALUE_INTEGER, + FIELD_VALUE_DOUBLE, + FIELD_VALUE_CSTRING, }; enum sampling_mode { SAMPLING_MODE_COMPREHENSIVE, SAMPLING_MODE_TOPK, - SAMPLING_MODE_SPREADSKETCH, // TODO: rename TOP_CARDINALITY // todo: 问问gpt cardinality,unique.... + SAMPLING_MODE_TOP_CARDINALITY, }; struct field { @@ -106,7 +106,7 @@ int fieldstat_register_hll(struct fieldstat *instance, int cube_id, const char * * @param significant_figures: the precision of the histogram. Must be in [1, 5]. * @return metric id if success. If failed, return FS_ERR_NULL_HANDLER, FS_ERR_INVALID_KEY(when metric_name is not unique in this cube), or FS_ERR_INVALID_PARAM(if any of the 3 params are out of range) */ -int fieldstat_register_hist(struct fieldstat *instance, int cube_id, const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures); +int fieldstat_register_histogram(struct fieldstat *instance, int cube_id, const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures); /* * @brief let the value of counter metric of cell_id increase by `increment`. @@ -146,7 +146,7 @@ int fieldstat_hll_add_field(struct fieldstat *instance, int cube_id, int metric_ * @return FS_OK if success. FS_ERR_NULL_HANDLER, FS_ERR_INVALID_CUBE_ID, FS_ERR_INVALID_METRIC_ID if fail. * FS_ERR_INVALID_PARAM when value is less than 0, or the cube is topk. */ -int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id, const struct field *cell_dimensions, size_t n_dimensions, long long value); // todo: 重命名,hist,不管符号冲突问题了 +int fieldstat_histogram_record(struct fieldstat *instance, int cube_id, int metric_id, const struct field *cell_dimensions, size_t n_dimensions, long long value); /* * @brief Delete all the cells, also the content of every metrics. The cube and metrics are not deleted. Increase cell_version by 1. @@ -178,7 +178,7 @@ struct field_list void fieldstat_get_cubes(const struct fieldstat *instance, int **cube_ids, int *n_cube); /* - * @brief Get all the registered metrics by fieldstat_register_counter, fieldstat_register_hll, fieldstat_register_hist. + * @brief Get all the registered metrics by fieldstat_register_counter, fieldstat_register_hll, fieldstat_register_histogram. */ void fieldstat_cube_get_metrics(const struct fieldstat *instance, int cube_id, int **metric_id_out, size_t *n_metric); @@ -191,7 +191,7 @@ const char *fieldstat_get_metric_name(const struct fieldstat *instance, int cube enum metric_type fieldstat_get_metric_type(const struct fieldstat *instance, int cube_id, int metric_id); /* - get the cell_dimensions added to cube when calling fieldstat_counter_incrby, fieldstat_counter_set, fieldstat_hll_add, fieldstat_hist_record. + get the cell_dimensions added to cube when calling fieldstat_counter_incrby, fieldstat_counter_set, fieldstat_hll_add, fieldstat_histogram_record. */ void fieldstat_cube_get_cells(const struct fieldstat *instance, int cube_id, struct field_list **cell_dimensions, size_t *n_cell); @@ -226,8 +226,8 @@ int fieldstat_counter_get(const struct fieldstat *instance, int cube_id, const s @return >= 0 if success. FS_ERR_INVALID_PARAM if precision is invalid. */ int fieldstat_hll_get(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, double *value); -long long fieldstat_hist_value_at_percentile(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, double percentile); -long long fieldstat_hist_count_le_value(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, long long value); +long long fieldstat_histogram_value_at_percentile(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, double percentile); +long long fieldstat_histogram_count_le_value(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, long long value); // get the base 64 encoded string of the serialized blob of a cell void fieldstat_get_serialized_blob(const struct fieldstat *instance, int cube_id, int metric_id, const struct field_list *cell_dimensions, char **blob, size_t *blob_size); diff --git a/readme_fieldstat.md b/readme_fieldstat.md index cc17426..42c6680 100644 --- a/readme_fieldstat.md +++ b/readme_fieldstat.md @@ -42,7 +42,7 @@ Download fieldstat4 rpm from https://repo.geedge.net/pulp/content/ and install r struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, YOUR_SHARED_TAG, YOUR_SHARED_TAG_LENGTH, SAMPLING_MODE_TOPK, MAX_CELL_NUMBER); int metric_counter_id = fieldstat_register_counter(instance, cube_id, "any metric name", 0/1); -int metric_histogram_id = fieldstat_register_histogram(instance, cube_id, "any metric name", THE_MINIMUM_NUMBER_TO_RECORD, THE_MAXIMUM_NUMBER_TO_RECORD, PRECISION); +int metric_histogram_id = fieldstat_register_histogramogram(instance, cube_id, "any metric name", THE_MINIMUM_NUMBER_TO_RECORD, THE_MAXIMUM_NUMBER_TO_RECORD, PRECISION); int metric_hll_id = fieldstat_register_hll(instance, cube_id, "any metric name", PRECISION); int cell_id = fieldstat_cube_add(instance, cube_id, YOUR_TAG, YOUR_TAG_LENGTH, THE_PRIMARY_METRIC); if (cell_id != -1) { diff --git a/readme_fieldstat_easy.md b/readme_fieldstat_easy.md index 14f0927..c6f39cd 100644 --- a/readme_fieldstat_easy.md +++ b/readme_fieldstat_easy.md @@ -172,7 +172,7 @@ const int N_THREADS = 3; struct field global_tags[1]; struct field tmptag; tmptag.key = "app id"; -tmptag.type = TAG_INTEGER; +tmptag.type = FIELD_VALUE_INTEGER; tmptag.value_longlong = 1; global_tags[0] = tmptag; diff --git a/src/cells/hash_table.c b/src/cells/hash_table.c new file mode 100644 index 0000000..8394565 --- /dev/null +++ b/src/cells/hash_table.c @@ -0,0 +1,230 @@ +#include "hash_table.h" + +#include +#include +#include +#include + +#include "uthash.h" + +#include "fieldstat.h" +#include "exdata.h" + +struct tag_exdata_item { + char *key; + size_t key_len; + void *exdata; + bool dying; + UT_hash_handle hh; +}; + +struct hash_table { // todo: 文件改名字 + struct tag_exdata_item *tag_id_map; + int current_cell_num; + int max_cell_num; + + exdata_new_cb new_fn; + exdata_free_cb free_fn; + exdata_merge_cb merge_fn; + exdata_reset_cb reset_fn; + exdata_copy_cb copy_fn; +}; +static void *default_new_fn(void *arg) { + return NULL; +} + +static void default_free_fn(void *exdata) { + return; +} + +static void default_merge_fn(void *dest, void *src) { + return; +} + +static void default_reset_fn(void *exdata) { + return; +} + +static void *default_copy_fn(void *exdata) { + return exdata; +} + + +struct hash_table *hash_table_new(int max_query_num) { + struct hash_table *pthis = calloc(1, sizeof(struct hash_table)); + + pthis->max_cell_num = max_query_num; + + pthis->new_fn = default_new_fn; + pthis->free_fn = default_free_fn; + pthis->merge_fn = default_merge_fn; + pthis->reset_fn = default_reset_fn; + pthis->copy_fn = default_copy_fn; + return pthis; +} + +void hash_table_free(struct hash_table *pthis) { + struct tag_exdata_item *item, *tmp; + HASH_ITER(hh, pthis->tag_id_map, item, tmp) { + HASH_DEL(pthis->tag_id_map, item); + free(item->key); + pthis->free_fn(item->exdata); + free(item); + } + free(pthis); +} + +void hash_table_reset(struct hash_table *pthis) { + struct tag_exdata_item *node, *tmp; + HASH_ITER(hh, pthis->tag_id_map, node, tmp) { + if (!node->dying) { + node->dying = true; + pthis->reset_fn(node->exdata); + continue; + } + HASH_DEL(pthis->tag_id_map, node); + free(node->key); + pthis->free_fn(node->exdata); + free(node); + } + + pthis->current_cell_num = 0; +} + +static char *my_keydup(const char *key, size_t key_len) { + char *ret = calloc(1, key_len + 1); + memcpy(ret, key, key_len); + return ret; +} + +int hash_table_add(struct hash_table *pthis, const char *key, size_t key_len, void *arg) { + struct tag_exdata_item *item; + HASH_FIND(hh, pthis->tag_id_map, key, key_len, item); + if (item != NULL && !item->dying) { + return 1; + } + + if (pthis->current_cell_num >= pthis->max_cell_num) { + return 0; + } + + if (item != NULL) { + assert(item->dying); + item->dying = false; + pthis->current_cell_num++; + return 1; + } + + item = calloc(1, sizeof(struct tag_exdata_item)); + item->key = my_keydup(key, key_len); + item->key_len = key_len; + item->exdata = pthis->new_fn(arg); + item->dying = false; + HASH_ADD_KEYPTR(hh, pthis->tag_id_map, item->key, key_len, item); + + pthis->current_cell_num++; + return 1; +} + +void hash_table_set_exdata_schema(struct hash_table *pthis, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn) { + pthis->new_fn = new_fn; + pthis->free_fn = free_fn; + pthis->merge_fn = merge_fn; + pthis->reset_fn = reset_fn; + pthis->copy_fn = copy_fn; +} + +void *hash_table_get0_exdata(struct hash_table *pthis, const char *key, size_t key_len) { + struct tag_exdata_item *item; + HASH_FIND(hh, pthis->tag_id_map, key, key_len, item); + if (item == NULL || item->dying) { + return NULL; + } + return item->exdata; +} + +int hash_table_get_count(const struct hash_table *pthis) { + return pthis->current_cell_num; +} + +size_t hash_table_list(const struct hash_table *pthis, void **exdatas, size_t n_exdatas) { + size_t actual_len = pthis->current_cell_num; + if (actual_len == 0) { + return 0; + } + + struct tag_exdata_item *item, *tmp; + size_t i = 0; + HASH_ITER(hh, pthis->tag_id_map, item, tmp) { + if (item->dying) { + continue; + } + if (i >= n_exdatas) { + break; + } + exdatas[i] = item->exdata; + i++; + } + return actual_len < n_exdatas ? actual_len : n_exdatas; +} + +int hash_table_merge(struct hash_table *dest, struct hash_table *src) { + struct tag_exdata_item *item_src, *tmp; + struct tag_exdata_item *item_dst; + HASH_ITER(hh, src->tag_id_map, item_src, tmp) { + if (item_src->dying) { + continue; + } + + HASH_FIND(hh, dest->tag_id_map, item_src->key, item_src->key_len, item_dst); + if (item_dst != NULL && !item_dst->dying) { + dest->merge_fn(item_dst->exdata, item_src->exdata); + continue; + } + + if (dest->current_cell_num >= dest->max_cell_num) { + continue; // cannot add more cells + } + + if (item_dst == NULL) { + item_dst = calloc(1, sizeof(struct tag_exdata_item)); + item_dst->key = my_keydup(item_src->key, item_src->key_len); + item_dst->key_len = item_src->key_len; + item_dst->dying = false; + item_dst->exdata = dest->copy_fn(item_src->exdata); + HASH_ADD_KEYPTR(hh, dest->tag_id_map, item_dst->key, item_dst->key_len, item_dst); + dest->current_cell_num++; + } else { + assert(item_dst->dying); + item_dst->dying = false; + dest->merge_fn(item_dst->exdata, item_src->exdata); //item_dst->exdata should be empty, but just merge to it. + dest->current_cell_num++; + } + } + return 0; +} + +struct hash_table *hash_table_copy(const struct hash_table *src) { + struct hash_table *pthis = calloc(1, sizeof(struct hash_table)); + pthis->max_cell_num = src->max_cell_num; + pthis->current_cell_num = src->current_cell_num; + pthis->new_fn = src->new_fn; + pthis->free_fn = src->free_fn; + pthis->merge_fn = src->merge_fn; + pthis->reset_fn = src->reset_fn; + pthis->copy_fn = src->copy_fn; + + struct tag_exdata_item *item, *tmp; + HASH_ITER(hh, src->tag_id_map, item, tmp) { + if (item->dying) { + continue; + } + struct tag_exdata_item *new_item = calloc(1, sizeof(struct tag_exdata_item)); + new_item->key = my_keydup(item->key, item->key_len); + new_item->key_len = item->key_len; + new_item->exdata = pthis->copy_fn(item->exdata); + new_item->dying = false; + HASH_ADD_KEYPTR(hh, pthis->tag_id_map, new_item->key, new_item->key_len, new_item); + } + return pthis; +} diff --git a/src/cells/hash_table.h b/src/cells/hash_table.h new file mode 100644 index 0000000..59fc8e8 --- /dev/null +++ b/src/cells/hash_table.h @@ -0,0 +1,30 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +#include "exdata.h" + +struct hash_table; + +struct hash_table *hash_table_new(int max_query_num); +void hash_table_set_exdata_schema(struct hash_table *pthis, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn); +void hash_table_free(struct hash_table *pthis); +void hash_table_reset(struct hash_table *pthis); +int hash_table_merge(struct hash_table *dest, struct hash_table *src); +struct hash_table *hash_table_copy(const struct hash_table *src); + +// int hash_table_add(struct hash_table *pthis, const char *key, size_t key_len, int count, void *arg); +int hash_table_add(struct hash_table *pthis, const char *key, size_t key_len, void *arg); + +// void *hash_table_get0_exdata(struct hash_table *pthis, const char *key, size_t key_len); +void *hash_table_get0_exdata(struct hash_table *pthis, const char *key, size_t key_len); +int hash_table_get_count(const struct hash_table *pthis); +size_t hash_table_list(const struct hash_table *pthis, void **exdatas, size_t n_exdatas); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/cells/heavy_keeper.c b/src/cells/heavy_keeper.c new file mode 100644 index 0000000..b606a67 --- /dev/null +++ b/src/cells/heavy_keeper.c @@ -0,0 +1,822 @@ +#include "heavy_keeper.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "minheap/heap.h" +#include "mpack/mpack.h" +#include "xxhash/xxhash.h" +// XXHASH is faster +#define HASH_FUNCTION(keyptr, keylen, hashv) \ + do { \ + hashv = XXH3_64bits(keyptr, keylen); \ + } while (0) + +#include "uthash.h" + +#include "exdata.h" + +#define FP_HASH_KEY 0 +#define NOT_FIND (-1) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) + +struct entry_data { // the value constitute of a sorted set entry + char *key; + size_t key_len; + + void *exdata; +}; + +struct sorted_set { + heap *heap; + struct hash_node *hash_tbl; + + int n_living_entry; + + exdata_new_cb new_fn; + exdata_free_cb free_fn; + exdata_merge_cb merge_fn; + exdata_reset_cb reset_fn; + exdata_copy_cb copy_fn; +}; + +struct hash_node { + const char *key; // value is equal to entry_data::key(point to the same memory) + size_t key_len; + heap_entry *val; + UT_hash_handle hh; +}; + +struct Bucket { + uint64_t finger_print; + long long count; // the actual count, sum of all uuid_hash_node->count +}; + +// Parameters used in algorithm +struct heavy_keeper_options{ + int r; // the size of the array. Default value: 4 + // Set it by how accurate you want. Value of 4 guarantees an accuracy more than 90% and around 97% in all tests. + // Not too big because it have an impact on both time and memory efficiency. + int w; // M2, the maximum number of buckets every array keeps. Default value: k*log(k) and no less than 100. + // Basically, as long as big enough, it won't affect the accuracy significantly. + double b; // b, bigger variance of flow size is(elephant flows take more ratio), smaller it should be. + // Must bigger than 1. Better not bigger than 1.3, otherwise some elephant flow will be missed. +}; + +struct heavy_keeper { + int K; + struct sorted_set *top_K_heap; + struct heavy_keeper_options params; + struct Bucket *sketch; + + unsigned int rand_state; + + exdata_new_cb new_fn; + exdata_free_cb free_fn; + exdata_merge_cb merge_fn; + exdata_reset_cb reset_fn; + exdata_copy_cb copy_fn; +}; + +static void *default_new_fn(void *arg) { + return NULL; +} + +static void default_free_fn(void *exdata) { + return; +} + +static void default_merge_fn(void *dest, void *src) { + return; +} + +static void default_reset_fn(void *exdata) { + return; +} + +static void *default_copy_fn(void *exdata) { + return exdata; +} + +struct entry_data *entry_data_construct(const char *key, size_t key_len, void *exdata) +{ + struct entry_data *entry_data = (struct entry_data *)malloc(sizeof(struct entry_data)); + + entry_data->key = (char *)malloc(key_len); + memcpy(entry_data->key, key, key_len); + entry_data->key_len = key_len; + entry_data->exdata = exdata; + return entry_data; +} + +void entry_data_destroy(struct entry_data *entry_data, exdata_free_cb free_fn) +{ + if (entry_data == NULL) { + return; + } + free(entry_data->key); + free_fn(entry_data->exdata); + free(entry_data); +} + +static inline long long sorted_set_entry_get_score(const heap_entry *entry) +{ + long long score = *(long long *)entry->key; + if (score == 0) { + return 0; + } + return score - 1; // sorted set will let the count start from 1, 0 for dying entry. +} + +struct entry_data *sorted_set_entry_get_data(const heap_entry *entry) +{ + return entry->value; +} + +/* + dying: To reduce the time of HASH_ADD, and to support merely recording a key without any value, give a dying status. +*/ +static inline bool sorted_set_entry_dying(const heap_entry *entry) +{ + long long score = *(long long *)entry->key; + return score == 0; +} + +static inline long long safe_add(long long a, long long b) +{ + if (INT64_MAX - a < b) { + return INT64_MAX; + } + return a + b; +} + +// cppcheck-suppress [constParameterCallback, unmatchedSuppression] +static bool cmp_entry_cb(void *aa, void *bb) +{ + heap_entry *a = (heap_entry *)aa; + heap_entry *b = (heap_entry *)bb; + long long score_a = *(long long *)a->key; + long long score_b = *(long long *)b->key; + + if (score_a < score_b) { + return true; + } + return false; +} + +static int entry_get_index_cb(void *a) +{ + return ((heap_entry *)a)->index; +} + +void entry_set_index_cb(int index, void *a) +{ + ((heap_entry *)a)->index = index; +} + +struct sorted_set *sorted_set_new(int set_size) +{ + struct sorted_set *ret = (struct sorted_set *)malloc(sizeof(struct sorted_set)); + ret->hash_tbl = NULL; + ret->n_living_entry = 0; + heap *h = (heap *)malloc(sizeof(heap)); + init_heap(h, set_size, cmp_entry_cb, entry_get_index_cb, entry_set_index_cb); + + ret->heap = h; + + ret->new_fn = default_new_fn; + ret->free_fn = default_free_fn; + ret->merge_fn = default_merge_fn; + ret->reset_fn = default_reset_fn; + ret->copy_fn = default_copy_fn; + + return ret; +} + +void sorted_set_schema_set(struct sorted_set *ss, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn) +{ + ss->new_fn = new_fn; + ss->free_fn = free_fn; + ss->merge_fn = merge_fn; + ss->reset_fn = reset_fn; + ss->copy_fn = copy_fn; +} + +void sorted_set_free(struct sorted_set *ss) +{ + struct hash_node *tbl = ss->hash_tbl; + struct hash_node *h_node, *tmp; + HASH_ITER(hh, tbl, h_node, tmp) { + HASH_DEL(tbl, h_node); + free(h_node); + } + + heap *heap = ss->heap; + heap_entry *node; + for (int i = 0; i < heap->cur_size; i++) { + node = (heap_entry *)heap->nodes[i]; + entry_data_destroy(node->value, ss->free_fn); + free(node->key); + free(node); + } + free(heap->nodes); + free(heap); + + free(ss); +} + +heap_entry *sorted_set_find_entry(const struct sorted_set *ss, const char *key, size_t key_len) +{ + struct hash_node *hash_tbl = ss->hash_tbl; + struct hash_node *s = NULL; + HASH_FIND(hh, hash_tbl, key, key_len, s); + + if (s == NULL) { + return NULL; + } + return (heap_entry *)s->val; +} + +static inline void sorted_set_entry_set_score(struct sorted_set *ss, heap_entry *entry, long long score) +{ + *(long long *)(entry->key) = score; + + adjust_heap_node(ss->heap, entry); +} + +int sorted_set_pop(struct sorted_set *ss) +{ + struct hash_node *hash_tbl = ss->hash_tbl; + heap_entry *entry = (heap_entry *)pop_heap(ss->heap); + if (entry == NULL) { + return -1; + } + struct entry_data *tmp_data = sorted_set_entry_get_data(entry); + + struct hash_node *s = NULL; + HASH_FIND(hh, hash_tbl, tmp_data->key, tmp_data->key_len, s); + assert(s!=NULL); + + HASH_DEL(hash_tbl, s); + free(s); + ss->hash_tbl = hash_tbl; + + int ret; + if (sorted_set_entry_dying(entry)) { + ret = 0; + } else { + ss->n_living_entry--; + ret = 1; + } + + entry_data_destroy(tmp_data, ss->free_fn); + free(entry->key); + free(entry); + + return ret; +} + +static inline bool sorted_set_check_is_full(const struct sorted_set *ss) +{ + return ss->heap->cur_size >= ss->heap->max_size; +} + +long long sorted_set_get_min_score(const struct sorted_set *ss) +{ + heap *heap = ss->heap; + if (heap->cur_size == 0) { + return NOT_FIND; + } + const heap_entry *ret = (heap_entry *)(heap->nodes[0]); + + long long score = *(long long *)ret->key; + if (score == 0) { + return NOT_FIND; + } + return score - 1; // sorted set will let the score start from 1, 0 for dying entry. +} + +void sorted_set_insert_to_available_heap(struct sorted_set *ss, const char *key, size_t key_len, long long cnt, void *exdata) +{ + cnt = safe_add(cnt, 1); // sorted set will let the score start from 1, 0 for dying entry. + long long *tmp_cnt = (long long*)malloc(sizeof(long long)); + *tmp_cnt = cnt; + struct entry_data *tmp_data = entry_data_construct(key, key_len, exdata); + heap_entry *node = (heap_entry *)malloc(sizeof(heap_entry)); + node->key = tmp_cnt; + node->value = tmp_data; + + push_heap(ss->heap, (void *)node); + + struct hash_node *hash_tbl = ss->hash_tbl; + struct hash_node *s = (struct hash_node *)malloc(sizeof(struct hash_node)); + s->key = sorted_set_entry_get_data(node)->key; + s->key_len = key_len; + s->val = node; + HASH_ADD_KEYPTR(hh, hash_tbl, s->key, key_len, s); + ss->hash_tbl = hash_tbl; + + ss->n_living_entry++; +} + +int sorted_set_insert(struct sorted_set *ss, const char *key, size_t key_len, long long cnt, void *args) +{ + // if there is a dying record, reborn it to use. + heap_entry *entry = sorted_set_find_entry(ss, key, key_len); + if (entry != NULL) { + if (!sorted_set_entry_dying(entry)) { + assert(0); + return -1; + } + sorted_set_entry_set_score(ss, entry, safe_add(cnt, 1)); // sorted set will let the score start from 1, 0 for dying entry. + + ss->n_living_entry++; + return 1; + } + + if (sorted_set_check_is_full(ss)) { + long long tmp_mincnt = sorted_set_get_min_score(ss); + if (tmp_mincnt != NOT_FIND && cnt <= tmp_mincnt) { // even if all cells in sorted set are dying, the sorted set can still be a full one, in which case, the min score is invalid. + return 0; + } + sorted_set_pop(ss); + } + sorted_set_insert_to_available_heap(ss, key, key_len, cnt, ss->new_fn(args)); + return 1; +} + +static inline int sorted_set_cardinality(const struct sorted_set *ss) +{ + return ss->n_living_entry; +} + +long long sorted_set_get_score(const struct sorted_set *ss, const char *key, size_t key_len) +{ + if (sorted_set_cardinality(ss) == 0) { + return NOT_FIND; + } + const heap_entry *entry = sorted_set_find_entry(ss, key, key_len); + if (entry == NULL) { + return NOT_FIND; + } + if (sorted_set_entry_dying(entry)) { + return NOT_FIND; + } + + return sorted_set_entry_get_score(entry); +} + +int sorted_set_incrby(struct sorted_set *ss, const char *key, size_t key_len, long long score) +{ + heap_entry *entry = sorted_set_find_entry(ss, key, key_len); + if (entry == NULL) { + return -1; + } + long long cnt_old; + if (sorted_set_entry_dying(entry) == false) { + cnt_old = sorted_set_entry_get_score(entry); + cnt_old += 1; // sorted set will let the score start from 1, 0 for dying entry. + } else { + cnt_old = 0; + } + sorted_set_entry_set_score(ss, entry, safe_add(score, cnt_old)); + return 0; +} + +typedef struct { + long long key; + struct entry_data *val; +} tmp_heap_node; + +int cmp_tmp_heap_node(const void *a, const void *b) +{ + const tmp_heap_node *aa = (tmp_heap_node *)a; + const tmp_heap_node *bb = (tmp_heap_node *)b; + + if (aa->key < bb->key) { + return 1; + } else if (aa->key > bb->key) { + return -1; + } else { + return 0; + } +} + +void sorted_set_dump(const struct sorted_set *ss, char **key_out, size_t *key_len_out, void **exdata_out) +{ + struct minheap *h = ss->heap; + tmp_heap_node *tmp_nodes = (tmp_heap_node *)malloc(sizeof(tmp_heap_node) * h->cur_size); + size_t n_living_entry = 0; + for (int i = 0; i < h->cur_size; i++) { + const heap_entry *entry = (heap_entry *)h->nodes[i]; + if (sorted_set_entry_dying(entry)) { + continue; + } + tmp_nodes[n_living_entry].key = sorted_set_entry_get_score(entry); + tmp_nodes[n_living_entry].val = sorted_set_entry_get_data(entry); + n_living_entry++; + } + + assert(n_living_entry == ss->n_living_entry); + qsort(tmp_nodes, n_living_entry, sizeof(tmp_heap_node), cmp_tmp_heap_node); + for (int i = 0; i < n_living_entry; i++) { + key_out[i] = tmp_nodes[i].val->key; + key_len_out[i] = tmp_nodes[i].val->key_len; + exdata_out[i] = tmp_nodes[i].val->exdata; + } + free(tmp_nodes); +} + +struct sorted_set *sorted_set_copy(const struct sorted_set *ss) +{ + struct sorted_set *ret = sorted_set_new(ss->heap->max_size); + sorted_set_schema_set(ret, ss->new_fn, ss->free_fn, ss->merge_fn, ss->reset_fn, ss->copy_fn); + + for (int i = 0; i < ss->heap->cur_size; i++) { + const heap_entry *entry = (heap_entry *)ss->heap->nodes[i]; + if (sorted_set_entry_dying(entry)) { + continue; + } + const struct entry_data *data = sorted_set_entry_get_data(entry); + sorted_set_insert_to_available_heap(ret, data->key, data->key_len, sorted_set_entry_get_score(entry), ss->copy_fn(data->exdata)); + } + + return ret; +} + +// set all the entry to dying status. They will be the first to be popped. +void sorted_set_reset(struct sorted_set *ss) +{ + heap *heap = ss->heap; + heap_entry *entry; + for (int i = 0; i < heap->cur_size; i++) { + entry = (heap_entry *)heap->nodes[i]; + *(long long *)entry->key = 0; + + ss->reset_fn(sorted_set_entry_get_data(entry)->exdata); + } + + ss->n_living_entry = 0; +} + +/* -------------------------------------------------------------------------- */ +/* heavy keeper */ +/* -------------------------------------------------------------------------- */ + +struct Bucket *new_sketch(struct heavy_keeper_options *params) { + size_t array_len = (size_t)params->r * (size_t)params->w; + + struct Bucket *ret = (struct Bucket *)calloc(array_len, sizeof(struct Bucket)); + + return ret; +} + +void params_set_to_default(struct heavy_keeper_options *p, int K) { + if (K > 5000) { // don't let the sketch too large when K gets insanely large + K = 5000; + } + double log_ret = log((double)K) / 2.3; // 2.3: log_e(10), log_ret = log_10(K) + + if (log_ret < 3) { + p->r = 3; + } else { + p->r = (int)(log_ret); + } + p->b = 1.17; // by test, 1.17 is the best + p->w = (int)(log_ret * K * 2); + if (p->w < 150) { + p->w = 150; // determined through test, too small max_bucket_num will let accuracy decrease severely. + } else if (p->w > 600) { + p->w = p->w / 4 + 450; + } +} + +struct heavy_keeper *heavy_keeper_new(int max_query_num) { + struct heavy_keeper *hk = (struct heavy_keeper *)malloc(sizeof(struct heavy_keeper)); + hk->K = max_query_num; + hk->rand_state = 0; + + hk->top_K_heap = sorted_set_new(max_query_num); + + params_set_to_default(&(hk->params), max_query_num); + + hk->sketch = new_sketch(&(hk->params)); + + hk->new_fn = default_new_fn; + hk->free_fn = default_free_fn; + hk->merge_fn = default_merge_fn; + hk->reset_fn = default_reset_fn; + + return hk; +} + +void heavy_keeper_free(struct heavy_keeper *hk) { + sorted_set_free(hk->top_K_heap); + free(hk->sketch); + + free(hk); +} + +void heavy_keeper_reset(struct heavy_keeper *hk) { + sorted_set_reset(hk->top_K_heap); + memset(hk->sketch, 0, sizeof(struct Bucket) * (size_t)hk->params.r * (size_t)hk->params.w); +} + +const int DECAY_POW_TABLE[128] = { // 1.17 ^ exp * RAND_MAX, exp is in [0,127] +2147483647,1835456109,1568765905,1340825560,1146004752,979491241,837172001,715531625,611565491,522705548,446756879,381843486,326361954,278941841,238411830,203770795,174163072,148857327,127228484,108742294,92942132, +79437720,67895487,58030331,49598573,42391943,36232430,30967889,26468281,22622462,19335438,16526015,14124799,12072478,10318357,8819109,7537700,6442479,5506392,4706318,4022494,3438029,2938486,2511527,2146604, +1834704,1568123,1340276,1145535,979090,836829,715239,611315,522491,446574,381687,326228,278828,238314,203687,174092,148796,127176,108698,92904,79405,67868,58007,49578,42375,36218,30955,26457,22613,19328,16519, +14119,12068,10314,8815,7535,6440,5504,4704,4021,3437,2937,2510,2146,1834,1567,1340,1145,979,836,715,611,522,446,382,326,279,238,204,174,149,127,109,93,79,68,58,50,42,36,31,26,23,19,17,14,12,10,9,8,6,6,5, +}; +bool if_need_to_decay(struct heavy_keeper *hk, const struct Bucket *bucket, long long count) { + if (count == 0) { + return false; + } + if (bucket->count < count) { // the exp is 0, so the decay rate is 1 + return true; + } + + long long exp = bucket->count / count; + if (exp > 127) { // decay_rate too small, almost no chance to decay + return false; + } + + // double decay_rate = pow(hk->params.b, -exp); + // p->b = 1.17 is fixed, search table to get result directly. + int decay_rate = DECAY_POW_TABLE[exp]; + + if (rand_r(&(hk->rand_state)) < decay_rate) { + return true; + } + return false; +} + +static inline uint64_t cal_hash_val_with_seed(const char *key, size_t key_len, unsigned int seed) { + return XXH3_64bits_withSeed(key, key_len, seed); +} + +/* +1 for newly add something. 0 for not add. -1 for unexpected cases. +*/ +int heavy_keeper_add(struct heavy_keeper *heavy_keeper, const char *key, size_t key_len, long long count, void *arg) { + assert(count >= 0); + if (count == 0) { + if (sorted_set_cardinality(heavy_keeper->top_K_heap) < heavy_keeper->K) { + const struct heap_entry *entry = sorted_set_find_entry(heavy_keeper->top_K_heap, key, key_len); + + if (entry != NULL && !sorted_set_entry_dying(entry)) { + return 0; + } + + sorted_set_insert(heavy_keeper->top_K_heap, key, key_len, count, arg); + return 1; + } + return 0; + } + + struct sorted_set *summary = heavy_keeper->top_K_heap; + + long long old_cnt = sorted_set_get_score(summary, key, key_len); + bool not_in_sorted_set = (old_cnt == NOT_FIND); + long long maxv = 0; + uint64_t fp = cal_hash_val_with_seed(key, key_len, FP_HASH_KEY); + uint64_t h1 = fp; + uint64_t h2 = cal_hash_val_with_seed(key, key_len, FP_HASH_KEY+1); + + for (uint64_t j = 0; j < heavy_keeper->params.r; j++) { + uint64_t hashv = h1 + j * h2; // use `double hashing` strategy + struct Bucket *bucket = &(heavy_keeper->sketch[j * heavy_keeper->params.w + (hashv % heavy_keeper->params.w)]); + + if (bucket->finger_print == fp) { + // If a key is not in the min-heap, then the estimated key size should be no larger than nmin. + // or if the min-heap is not full(min_value == NOT_FIND), every key should be taken into account, so of course it should be added. + // in neither case, bucket->count > nMin && not_in_sorted_set happen. + // The keys whose counts are both larger than nmin and not in min-heap must have the same xxhash value, and its FP stored in bucket represents another field, + // In this case, the sketch won't be updated. This key is expected to be taken into account in another array, + // where its FP is different from the one it should collided with, so that element keys won't be missed. + if (not_in_sorted_set) { + long long min_value = sorted_set_get_min_score(summary); + if (min_value != NOT_FIND && bucket->count > min_value) { + continue; + } + } + bucket->count = safe_add(bucket->count, count); + maxv = MAX(maxv, bucket->count); + } else { + if (!if_need_to_decay(heavy_keeper, bucket, count)) { + continue; + } + + if (bucket->count < count) { + bucket->finger_print = fp; + bucket->count = count; + + maxv = MAX(maxv, count); + } else { + bucket->count -= count; + } + } + } + + if (not_in_sorted_set) { + if (sorted_set_cardinality(summary) != heavy_keeper->K) { + sorted_set_insert(summary, key, key_len, maxv, arg); + return 1; + } + long long min_value = sorted_set_get_min_score(summary); + if (maxv > min_value || min_value == NOT_FIND) { + sorted_set_insert(summary, key, key_len, maxv, arg); + return 1; + } + return 0; + } else { + if (maxv > old_cnt) { + sorted_set_incrby(summary, key, key_len, maxv - old_cnt); + } + return 1; // no popped, but the exdata definitely exists in the sorted set + } +} + +int heavy_keeper_set_exdata_schema(struct heavy_keeper *hk, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn) { + sorted_set_schema_set(hk->top_K_heap, new_fn, free_fn, merge_fn, reset_fn, copy_fn); + hk->new_fn = new_fn; + hk->free_fn = free_fn; + hk->merge_fn = merge_fn; + hk->reset_fn = reset_fn; + hk->copy_fn = copy_fn; + + return 0; +} + +void *heavy_keeper_get0_exdata(const struct heavy_keeper *hk, const char *key, size_t key_len) { + const heap_entry *entry = sorted_set_find_entry(hk->top_K_heap, key, key_len); + if (entry == NULL || sorted_set_entry_dying(entry)) { + return NULL; + } + return sorted_set_entry_get_data(entry)->exdata; +} + +int heavy_keeper_get_count(const struct heavy_keeper *hk) { + return sorted_set_cardinality(hk->top_K_heap); +} + +size_t heavy_keeper_list(const struct heavy_keeper *hk, void **exdatas, size_t n_exdatas) { + size_t actual_len = sorted_set_cardinality(hk->top_K_heap); + if (actual_len == 0) { + return 0; + } + + char **keys_dummy = (char **)malloc(sizeof(char *) * actual_len); + size_t *key_lens_dummy = (size_t *)malloc(sizeof(size_t) * actual_len); + if (n_exdatas < actual_len) { + void **exdatas_ret = (void **)malloc(sizeof(void *) * actual_len); + sorted_set_dump(hk->top_K_heap, keys_dummy, key_lens_dummy, exdatas_ret); + memcpy(exdatas, exdatas_ret, sizeof(void *) * n_exdatas); + free(exdatas_ret); + } else { + sorted_set_dump(hk->top_K_heap, keys_dummy, key_lens_dummy, exdatas); + } + + free(keys_dummy); + free(key_lens_dummy); + + return actual_len < n_exdatas ? actual_len : n_exdatas; +} + +static void heavy_keeper_merge_sketch(struct heavy_keeper *dest, const struct heavy_keeper *src) { + int w = dest->params.w; + int d = dest->params.r; + //idx + for (int array_id = 0; array_id < d; array_id++) { + for (int bucket_id = 0; bucket_id < w; bucket_id++) { + struct Bucket *bucket_dest = &(dest->sketch[array_id * w + bucket_id]); + const struct Bucket *bucket_src = &(src->sketch[array_id * w + bucket_id]); + + if (bucket_dest->finger_print == bucket_src->finger_print) { + bucket_dest->count = safe_add(bucket_dest->count, bucket_src->count); + } else { + if (bucket_dest->count < bucket_src->count) { + bucket_dest->count = bucket_src->count; + bucket_dest->finger_print = bucket_src->finger_print; + } + } + } + } +} + +long long find_count_in_sketch(struct heavy_keeper *hk, const char *key, size_t key_len) { + struct Bucket *bucket; + uint64_t fp = cal_hash_val_with_seed(key, key_len, FP_HASH_KEY); + uint64_t h1 = fp; + uint64_t h2 = cal_hash_val_with_seed(key, key_len, FP_HASH_KEY+1); + + long long maxv = 0; + for (uint64_t array_id = 0; array_id < hk->params.r; array_id++) { + uint64_t hash = h1 + array_id * h2; + bucket = &(hk->sketch[array_id * hk->params.w + (hash % hk->params.w)]); + + if (bucket->finger_print == fp) { + maxv = MAX(maxv, bucket->count); + } + } + + return maxv; +} + +void heavy_keeper_merge(struct heavy_keeper *dest, const struct heavy_keeper *src) { + assert(dest->K == src->K); + + heavy_keeper_merge_sketch(dest, src); + + struct sorted_set *new_rec = sorted_set_new(dest->K); // merging result + sorted_set_schema_set(new_rec, dest->new_fn, dest->free_fn, dest->merge_fn, dest->reset_fn, dest->copy_fn); + const struct sorted_set *ss_dest = dest->top_K_heap; // original ss in dest + const struct sorted_set *ss_src = src->top_K_heap; // the ss to be merged + int size_dest = sorted_set_cardinality(ss_dest); + int size_src = sorted_set_cardinality(ss_src); + int max_size = size_dest > size_src ? size_dest : size_src; + + void **exdatas_dst = (void **)calloc(size_dest, sizeof(void *)); + char **key_arr = (char **)malloc(sizeof(char *) * max_size); + size_t *key_lens = (size_t *)malloc(sizeof(size_t) * max_size); + sorted_set_dump(ss_dest, key_arr, key_lens, exdatas_dst); + + + /* ------------------------------ merge dest ------------------------------ */ + for (int i = 0; i < size_dest; i++) { + long long maxv = find_count_in_sketch(dest, key_arr[i], key_lens[i]); + sorted_set_insert_to_available_heap(new_rec, key_arr[i], key_lens[i], maxv, dest->copy_fn(exdatas_dst[i])); + } + + /* ------------------------------ merge src ------------------------------ */ + void **exdatas_src = (void **)calloc(size_src, sizeof(void *)); + sorted_set_dump(ss_src, key_arr, key_lens, exdatas_src); + + for (int i = 0; i < size_src; i++) { + const heap_entry *entry = sorted_set_find_entry(new_rec, key_arr[i], key_lens[i]); + if (entry != NULL) { // the key is in both dest and src, so has been processed in the previous loop. The reason why no need to sum up result is that merged sketch already keeps its summed up count + void *exdata_new = sorted_set_entry_get_data(entry)->exdata; + void *exdata_src = exdatas_src[i]; + dest->merge_fn(exdata_new, exdata_src); + + continue; + } + + long long cnt = find_count_in_sketch(dest, key_arr[i], key_lens[i]);// the cnt is the estimated count in the merged sketch, since the dest heavy keeper has been merged + if (sorted_set_check_is_full(new_rec)) { + long long mincnt_new = sorted_set_get_min_score(new_rec); + if (cnt > mincnt_new) { + sorted_set_pop(new_rec); + sorted_set_insert_to_available_heap(new_rec, key_arr[i], key_lens[i], cnt, dest->copy_fn(exdatas_src[i])); + } + } else { + sorted_set_insert_to_available_heap(new_rec, key_arr[i], key_lens[i], cnt, dest->copy_fn(exdatas_src[i])); + } + } + + free(key_arr); + free(key_lens); + free(exdatas_dst); + free(exdatas_src); + sorted_set_free(dest->top_K_heap); + dest->top_K_heap = new_rec; +} + +struct heavy_keeper *heavy_keeper_copy(const struct heavy_keeper *src) { + struct heavy_keeper *ret = (struct heavy_keeper *)malloc(sizeof(struct heavy_keeper)); + ret->K = src->K; + ret->rand_state = 0; + + ret->top_K_heap = sorted_set_copy(src->top_K_heap); + + ret->params = src->params; + ret->sketch = (struct Bucket *)malloc(sizeof(struct Bucket) * (size_t)ret->params.r * (size_t)ret->params.w); + memcpy(ret->sketch, src->sketch, sizeof(struct Bucket) * (size_t)ret->params.r * (size_t)ret->params.w); + + ret->new_fn = src->new_fn; + ret->free_fn = src->free_fn; + ret->merge_fn = src->merge_fn; + ret->reset_fn = src->reset_fn; + ret->copy_fn = src->copy_fn; + + return ret; +} + +void heavy_keeper_one_point_query(const struct heavy_keeper *hk, const char *key, size_t key_len, long long *count_out, void **exdata_out) { + *count_out = 0; + *exdata_out = NULL; + + const heap_entry *entry = sorted_set_find_entry(hk->top_K_heap, key, key_len); + if (entry == NULL) { + return; + } + *count_out = sorted_set_entry_get_score(entry); + *exdata_out = sorted_set_entry_get_data(entry)->exdata; +} \ No newline at end of file diff --git a/src/cells/heavy_keeper.h b/src/cells/heavy_keeper.h new file mode 100644 index 0000000..3b09598 --- /dev/null +++ b/src/cells/heavy_keeper.h @@ -0,0 +1,48 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +#include "exdata.h" + + +struct heavy_keeper; + +struct heavy_keeper *heavy_keeper_new(int max_query_num); +/** + * @brief free a heavy keeper. + * @param hk the pointer to the heavy keeper. + */ +void heavy_keeper_free(struct heavy_keeper *hk); + +/* + * @brief clear a heavy keeper. It will clear all the data in the heavy keeper. as for every exdata, use the reset function `exdata_reset_cb` to reset it. + * @param hk the pointer to the heavy keeper. +*/ +void heavy_keeper_reset(struct heavy_keeper *hk); + +int heavy_keeper_add(struct heavy_keeper *hk, const char *key, size_t key_len, long long count, void *arg); + +int heavy_keeper_set_exdata_schema(struct heavy_keeper *hk, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn); + +void *heavy_keeper_get0_exdata(const struct heavy_keeper *hk, const char *key, size_t key_len); + +// get the number of cells in the heavy keeper +int heavy_keeper_get_count(const struct heavy_keeper *hk); + +size_t heavy_keeper_list(const struct heavy_keeper *hk, void **exdatas, size_t n_exdatas); + +void heavy_keeper_merge(struct heavy_keeper *dest, const struct heavy_keeper *src); + +struct heavy_keeper *heavy_keeper_copy(const struct heavy_keeper *src); + +// for test +void heavy_keeper_one_point_query(const struct heavy_keeper *hk, const char *key, size_t key_len, long long *count_out, void **exdata_out); + + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/cells/spread_sketch.c b/src/cells/spread_sketch.c new file mode 100644 index 0000000..e79815b --- /dev/null +++ b/src/cells/spread_sketch.c @@ -0,0 +1,366 @@ +#include +#include +#include +#include +#include +#include + +#include "xxhash/xxhash.h" +#include "uthash.h" + +#include "spread_sketch.h" +#include "exdata.h" + +// todo:把primary metric 记到sketch 里,且使用特殊的st Hyperloglog + +struct entry { + int ref_count; + void *exdata; + bool dying; + char *key; + size_t key_len; + UT_hash_handle hh; +}; + +struct spread_sketch_scheme { + exdata_new_cb new_fn; + exdata_free_cb free_fn; + exdata_merge_cb merge_fn; + exdata_reset_cb reset_fn; + exdata_copy_cb copy_fn; +}; + +struct entry_table { + struct entry *entry; + + struct spread_sketch_scheme scheme; +}; + +struct bucket { + struct entry *content; + uint32_t level; +}; + +struct spread_sketch { + int depth; + int width; + + struct spread_sketch_scheme scheme; + + struct bucket *buckets; + struct entry_table *table; + + uint32_t *min_level_per_row; // TODO: 先看看性能吧, 之后再写。用来记录每行最小的level,从而跳过行数。对于64位的level,维持一个计数,额外使用64 r的空间,当一个最小位数的level 计数到0时,更新最小level。 + // TODO: 对比heavy keeper,不仅仅是跳过的问题,heavykeeper 无论什么情况,在输入0的时候都不会走sketch 更新。 + // 或者简单记录用掉的bucket 数量也挺好。 +}; + +static void *default_new_fn(void *arg) { + return NULL; +} +static void default_free_fn(void *exdata) { + return; +} +static void default_merge_fn(void *dest, void *src) { + return; +} +static void default_reset_fn(void *exdata) { + return; +} +static void *default_copy_fn(void *exdata) { + return exdata; +} +static inline bool key_equal(const char *key1, size_t key1_len, const char *key2, size_t key2_len) { + if (key1_len != key2_len) { + return false; + } + return memcmp(key1, key2, key1_len) == 0; +} +static inline char *key_dup(const char *key, size_t key_len) { + char *ret = malloc(key_len+1); + memcpy(ret, key, key_len); + ret[key_len] = '\0'; + return ret; +} + +struct entry *smart_ptr_table_get(struct entry_table *table, const char *key, size_t key_len, void *arg) { + struct entry *ret; + HASH_FIND(hh, table->entry, key, key_len, ret); + + if (ret != NULL) { + ret->dying = false; + ret->ref_count++; + } else { + ret = malloc(sizeof(struct entry)); + ret->dying = false; + ret->ref_count = 1; + ret->key = key_dup(key, key_len); + ret->key_len = key_len; + if (arg == NULL) { + ret->exdata = NULL; + } else { + ret->exdata = table->scheme.new_fn(arg); + } + HASH_ADD_KEYPTR(hh, table->entry, ret->key, ret->key_len, ret); + } + + return ret; +} + +int smart_ptr_table_release(struct entry_table *table, const char *key, size_t key_len) { + struct entry *ret; + HASH_FIND(hh, table->entry, key, key_len, ret); + if (ret == NULL) { + return -1; + } + + ret->ref_count--; + if (ret->ref_count == 0) { + // printf("release %s\n", key); + HASH_DEL(table->entry, ret); + table->scheme.free_fn(ret->exdata); + free(ret->key); + free(ret); + } + + return 0; +} + +void smart_ptr_table_free(struct entry_table *table) { + struct entry *current, *tmp; + HASH_ITER(hh, table->entry, current, tmp) { + HASH_DEL(table->entry, current); + table->scheme.free_fn(current->exdata); + free(current->key); + free(current); + } + free(table); +} + +struct entry_table *smart_ptr_table_new() { + struct entry_table *table = malloc(sizeof(struct entry_table)); + table->entry = NULL; + + table->scheme.new_fn = default_new_fn; + table->scheme.free_fn = default_free_fn; + table->scheme.merge_fn = default_merge_fn; + table->scheme.reset_fn = default_reset_fn; + table->scheme.copy_fn = default_copy_fn; + + return table; +} + +void get_parameter_recommendation(int max_super_spreader_number, int *depth_out, int *width_out) +{ + int logk = max_super_spreader_number >= 3200 ? 4 : 3; // lg3200 = 3.51,round up to 4 + *depth_out = logk; + + int w; + if (max_super_spreader_number <= 100) { + w = max_super_spreader_number * 3 /2; // * 1.5, when the number is small, we need more width + } else { + w = max_super_spreader_number + 50; // + 50: 100*1.5-100 = 50, make w=f(k) continuous + } + if (w < 40) { + w = 40; + } + *width_out = w; +} + +struct spread_sketch *spread_sketch_new(int expected_query_num) { + struct spread_sketch *pthis = malloc(sizeof(struct spread_sketch)); + get_parameter_recommendation(expected_query_num, &pthis->depth, &pthis->width); + + pthis->buckets = calloc(pthis->depth * pthis->width, sizeof(struct bucket)); + pthis->scheme.new_fn = default_new_fn; + pthis->scheme.free_fn = default_free_fn; + pthis->scheme.merge_fn = default_merge_fn; + pthis->scheme.reset_fn = default_reset_fn; + pthis->scheme.copy_fn = default_copy_fn; + pthis->table = smart_ptr_table_new(); + pthis->table->scheme = pthis->scheme; + + return pthis; +} + +// return 0 if not added, return 1 if added +int spread_sketch_add(struct spread_sketch *ss, const char *key, size_t key_length, uint64_t item_hash, void *arg) { + // uint64_t hash_identifier = XXH3_64bits_withSeed(identifier, identifier_length, 171); + uint32_t level = (uint32_t)__builtin_clzll(item_hash) + 1; + // printf("spread_sketch_add key %s, level %u\n", key, level); + + // https://www.eecs.harvard.edu/~michaelm/postscripts/tr-02-05.pdf + // A technique from the hashing literature is to use two hash functions h1(x) and h2(x) to simulate additional hash functions of the form gi(x) = h1(x) + ih2(x) + // Assuming that the 128-bit xxhash function is perfect, we can view it as a combination of two 64-bit hash functions. + uint64_t hash_x_tmp = XXH3_64bits_withSeed(key, key_length, 171); + uint32_t hash_x1 = (uint32_t) (hash_x_tmp >> 32); + uint32_t hash_x2 = (uint32_t) hash_x_tmp; + + bool in_sketch = false; + for (int i = 0; i < ss->depth; i++) { + uint32_t hash_x = hash_x1 + i * hash_x2; + int bucket_idx = (hash_x % ss->width) + i * ss->width; + struct bucket *bucket = &ss->buckets[bucket_idx]; + + if (bucket->content != NULL && key_equal(bucket->content->key, bucket->content->key_len, key, key_length)) { + bucket->content->dying = false; + + if (bucket->level < level) { + bucket->level = level; + } + in_sketch = true; + } else { + uint32_t old_level = bucket->content == NULL ? 0: bucket->level; + + if (level > old_level) { + // printf("update key %s to %s, and level %u to %u, in bucket (r,w)=(%d,%u)\n", bucket->content == NULL ? "NULL": bucket->content->key, key, old_level, level, i, hash_x % ss->width); + const struct entry *content_old = bucket->content; + if (content_old != NULL) { + smart_ptr_table_release(ss->table, content_old->key, content_old->key_len); + } + struct entry *content_new = smart_ptr_table_get(ss->table, key, key_length, arg); + bucket->content = content_new; + bucket->level = level; + + in_sketch = true; + } + } + } + + return in_sketch ? 1 : 0; +} + +void spread_sketch_free(struct spread_sketch *ss) { + smart_ptr_table_free(ss->table); + free(ss->buckets); + free(ss); +} + +void spread_sketch_merge(struct spread_sketch *dst, const struct spread_sketch *src) +{ + assert(dst->depth == src->depth && dst->width == src->width); + + for (int i = 0; i < dst->depth * dst->width; i++) { + const struct bucket *bucket_src = &src->buckets[i]; + struct bucket *bucket_dst = &dst->buckets[i]; + + if (bucket_src->content == NULL || bucket_src->content->dying) { + continue; + } + if (bucket_dst->content == NULL) { + bucket_dst->content = smart_ptr_table_get(dst->table, bucket_src->content->key, bucket_src->content->key_len, NULL); + bucket_dst->level = bucket_src->level; + continue; + } + bucket_dst->content->dying = false; + + if (key_equal(bucket_src->content->key, bucket_src->content->key_len, bucket_dst->content->key, bucket_dst->content->key_len)) { + if (bucket_src->level > bucket_dst->level) { + bucket_dst->level = bucket_src->level; + } + } else { + if (bucket_src->level > bucket_dst->level) { + smart_ptr_table_release(dst->table, bucket_dst->content->key, bucket_dst->content->key_len); + bucket_dst->content = smart_ptr_table_get(dst->table, bucket_src->content->key, bucket_src->content->key_len, NULL); + bucket_dst->level = bucket_src->level; + } + } + } + + const struct spread_sketch_scheme *scheme = &dst->table->scheme; + + struct entry *content_dest, *content_src, *tmp; + HASH_ITER(hh, dst->table->entry, content_dest, tmp) { + HASH_FIND(hh, src->table->entry, content_dest->key, content_dest->key_len, content_src); + if (content_src == NULL || content_src->dying) { + continue; + } + + if (content_dest->exdata == NULL) { + content_dest->exdata = scheme->copy_fn(content_src->exdata); + } else { + scheme->merge_fn(content_dest->exdata, content_src->exdata); + } + } +} + +void *spread_sketch_get0_exdata(const struct spread_sketch *ss, const char *key, size_t key_len) { + struct entry *content; + HASH_FIND(hh, ss->table->entry, key, key_len, content); + if (content == NULL || content->dying) { + return NULL; + } + return content->exdata; +} + +void spread_sketch_reset(struct spread_sketch *ss) { + for (int i = 0; i < ss->depth * ss->width; i++) { + struct bucket *bucket = &ss->buckets[i]; + bucket->level = 0; + } + + struct entry *content, *tmp; + HASH_ITER(hh, ss->table->entry, content, tmp) { + ss->scheme.reset_fn(content->exdata); + content->dying = true; + } +} + +void spread_sketch_set_exdata_schema(struct spread_sketch *ss, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn) { + ss->scheme.new_fn = new_fn; + ss->scheme.free_fn = free_fn; + ss->scheme.merge_fn = merge_fn; + ss->scheme.reset_fn = reset_fn; + ss->scheme.copy_fn = copy_fn; + + ss->table->scheme = ss->scheme; +} + +int spread_sketch_get_count(const struct spread_sketch *ss) { + int cnt = 0; + struct entry *content, *tmp; + HASH_ITER(hh, ss->table->entry, content, tmp) { + if (!content->dying) { + cnt++; + } + } + + return cnt; +} + +size_t spread_sketch_list(const struct spread_sketch *ss, void **exdatas, size_t n_exdatas) { + size_t count = 0; + struct entry *content, *tmp; + HASH_ITER(hh, ss->table->entry, content, tmp) { + if (content->dying) { + continue; + } + if (count >= n_exdatas) { + break; + } + exdatas[count] = content->exdata; + count++; + } + return count; +} + +struct spread_sketch *spread_sketch_copy(const struct spread_sketch *src) { + struct spread_sketch *dst = malloc(sizeof(struct spread_sketch)); + memcpy(dst, src, sizeof(struct spread_sketch)); + + 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++) { + if (src->buckets[i].content == NULL || src->buckets[i].content->dying) { + continue; + } + dst->buckets[i].content = smart_ptr_table_get(dst->table, src->buckets[i].content->key, src->buckets[i].content->key_len, NULL); + dst->buckets[i].level = src->buckets[i].level; + if (dst->buckets[i].content->exdata == NULL) { + dst->buckets[i].content->exdata = src->scheme.copy_fn(src->buckets[i].content->exdata); + } + } + return dst; +} diff --git a/src/cells/spread_sketch.h b/src/cells/spread_sketch.h new file mode 100644 index 0000000..9717238 --- /dev/null +++ b/src/cells/spread_sketch.h @@ -0,0 +1,41 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +#include "exdata.h" + +#define DUMMY_ITEM_HASH (1ULL<<63) // level(left most zeros) = 0 + +struct spread_sketch; + +// spread sketch alway store values more than expected_query_num,expected_query_num is a hint to set spread sketch parameters properly +struct spread_sketch *spread_sketch_new(int expected_query_num); + +void spread_sketch_free(struct spread_sketch *ss); + +void spread_sketch_reset(struct spread_sketch *ss); + +int spread_sketch_add(struct spread_sketch *ss, const char *key, size_t key_length, uint64_t item_hash, void *arg); +void spread_sketch_set_exdata_schema(struct spread_sketch *ss, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn); + +void *spread_sketch_get0_exdata(const struct spread_sketch *ss, const char *key, size_t key_len); + +// get the number of cells in the heavy keeper +int spread_sketch_get_count(const struct spread_sketch *ss); + +size_t spread_sketch_list(const struct spread_sketch *ss, void **exdatas, size_t n_exdatas); + +void spread_sketch_merge(struct spread_sketch *dest, const struct spread_sketch *src); + +struct spread_sketch *spread_sketch_copy(const struct spread_sketch *src); + +// for test +// void spread_sketch_one_point_query(const struct spread_sketch *ss, const char *key, size_t key_len, int *level_out, void **exdata_out); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/cube.c b/src/cube.c index 6d620c2..5bdbea7 100644 --- a/src/cube.c +++ b/src/cube.c @@ -13,7 +13,7 @@ #include "metric_manifest.h" #include "metric.h" #include "heavy_keeper.h" -#include "tag_map.h" +#include "hash_table.h" #include "spread_sketch.h" #define DEFAULT_N_METRIC 32 @@ -42,8 +42,8 @@ struct cell { struct cube { enum sampling_mode sampling_mode; union { - struct heavy_keeper *heavykeeper; // todo: 这两个改了 - struct hash_table *table; // todo: + struct heavy_keeper *heavykeeper; + struct hash_table *table; struct spread_sketch *spread_sketch; }; size_t max_n_cell; @@ -54,7 +54,7 @@ struct cube { int primary_metric_id; char *serialized_dimensions; // the key of cube is serialized cube dimensions - size_t serialized_dimensions_len; // todo: 重命名 + size_t serialized_dimensions_len; int id; UT_hash_handle hh; }; @@ -68,13 +68,13 @@ static struct field *field_array_duplicate(const struct field *fields_src, size_ ret[i].type = fields_src[i].type; switch (fields_src[i].type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: ret[i].value_longlong = fields_src[i].value_longlong; break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: ret[i].value_str = strdup(fields_src[i].value_str); break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: ret[i].value_double = fields_src[i].value_double; break; default: @@ -90,7 +90,7 @@ static void fieldstat_free_tag_array(struct field *fields, size_t n_tags) for (size_t i = 0; i < n_tags; i++) { struct field *field = &fields[i]; free((char *)field->key); - if (field->type == TAG_CSTRING) { + if (field->type == FIELD_VALUE_CSTRING) { free((char *)field->value_str); } } @@ -164,16 +164,16 @@ static int field_array_to_key_safe(const struct field fields[], size_t n_tags, c key_len = strlen(field->key); switch(field->type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: val_len = sizeof(long long); val_position = (void *)&field->value_longlong; break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: val_len = sizeof(double); val_position = (void *)&field->value_double; break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: val_len = strlen(field->value_str); val_position = (void *)field->value_str; break; @@ -221,16 +221,16 @@ static void field_array_to_key_endeavor(const struct field fields[], size_t n_ta key_len = strlen(field->key); switch(field->type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: val_len = sizeof(long long); val_position = (void *)&field->value_longlong; break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: val_len = sizeof(double); val_position = (void *)&field->value_double; break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: val_len = strlen(field->value_str); val_position = (void *)field->value_str; break; @@ -484,7 +484,7 @@ void cell_free(struct cell *pthis) { free(pthis->slots); for (size_t i = 0; i < pthis->cell_dimensions.n_field; i++) { free((char *)pthis->cell_dimensions.field[i].key); - if (pthis->cell_dimensions.field[i].type == TAG_CSTRING) { + if (pthis->cell_dimensions.field[i].type == FIELD_VALUE_CSTRING) { free((char *)pthis->cell_dimensions.field[i].value_str); } } @@ -592,7 +592,7 @@ struct cube *cube_new(const struct field *dimensions, size_t n_dimensions, enum cube->table = hash_table_new(max_n_cell); hash_table_set_exdata_schema(cube->table, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); break; - case SAMPLING_MODE_SPREADSKETCH: + case SAMPLING_MODE_TOP_CARDINALITY: cube->spread_sketch = spread_sketch_new(max_n_cell); spread_sketch_set_exdata_schema(cube->spread_sketch, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); break; @@ -613,7 +613,7 @@ void cube_free(struct cube *cube) { case SAMPLING_MODE_COMPREHENSIVE: hash_table_free(cube->table); break; - case SAMPLING_MODE_SPREADSKETCH: + case SAMPLING_MODE_TOP_CARDINALITY: spread_sketch_free(cube->spread_sketch); break; default: @@ -642,7 +642,7 @@ void cube_reset(struct cube *cube) { case SAMPLING_MODE_COMPREHENSIVE: hash_table_reset(cube->table); break; - case SAMPLING_MODE_SPREADSKETCH: + case SAMPLING_MODE_TOP_CARDINALITY: spread_sketch_reset(cube->spread_sketch); break; default: @@ -658,7 +658,7 @@ int cube_set_primary_metric(struct cube *cube, int metric_id) { } if (cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->sampling_mode == SAMPLING_MODE_TOPK && manifest->type != METRIC_TYPE_COUNTER) || - (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && manifest->type != METRIC_TYPE_HLL)) { + (cube->sampling_mode == SAMPLING_MODE_TOP_CARDINALITY && manifest->type != METRIC_TYPE_HLL)) { return FS_ERR_INVALID_PARAM; } cube->primary_metric_id = metric_id; @@ -761,9 +761,8 @@ struct cell *get_cell_in_spread_sketch_cube(struct cube *cube, const struct fiel args.n_dimensions = n_dimension; struct cell *cell_data = NULL; - assert(cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH); + assert(cube->sampling_mode == SAMPLING_MODE_TOP_CARDINALITY); - // todo: spread sketch 现在支持dummy 的方式是让他们也走sketch,可以用“满行”来减少这种计算,但确实加入level 低的内容,会走相同的流程,不像heavy keeper 一样就简单的查哈希表。 if (cube->primary_metric_id != metric_id) { cell_data = spread_sketch_get0_exdata(cube->spread_sketch, key, key_len); if (cell_data == NULL) { @@ -894,7 +893,7 @@ int cube_histogram_record(struct cube *cube, int metric_id, const struct field * case SAMPLING_MODE_TOPK: { cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} - case SAMPLING_MODE_SPREADSKETCH: { + case SAMPLING_MODE_TOP_CARDINALITY: { cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} default: @@ -923,7 +922,7 @@ int cube_hll_add(struct cube *cube, int metric_id, const struct field *dimension } uint64_t hash = 0; // just any value, if we do not need to update the primary metric of spread sketch cube, hash value is not used - if (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && cube->primary_metric_id == metric_id) { + if (cube->sampling_mode == SAMPLING_MODE_TOP_CARDINALITY && cube->primary_metric_id == metric_id) { hash = XXH3_64bits(key, key_len); } struct cell *cell_data = NULL; @@ -934,7 +933,7 @@ int cube_hll_add(struct cube *cube, int metric_id, const struct field *dimension case SAMPLING_MODE_TOPK: { cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} - case SAMPLING_MODE_SPREADSKETCH: { + case SAMPLING_MODE_TOP_CARDINALITY: { cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, hash, metric_id); break;} default: @@ -956,7 +955,7 @@ uint64_t field_array_to_hash(const struct field *field, size_t n_dimensions) { for (int i = 0; i < n_dimensions; i++) { XXH3_64bits_update(&state, field[i].key, strlen(field[i].key)); - if (field[i].type != TAG_CSTRING) { + if (field[i].type != FIELD_VALUE_CSTRING) { XXH3_64bits_update(&state, &field[i].value_longlong, sizeof(long long)); } else { XXH3_64bits_update(&state, field[i].value_str, strlen(field[i].value_str)); @@ -975,7 +974,7 @@ int cube_hll_add_field(struct cube *cube, int metric_id, const struct field *dim } uint64_t hash = 0; // just any value, if we do not need to update the primary metric of spread sketch cube, hash value is not used - if (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && cube->primary_metric_id == metric_id) { + if (cube->sampling_mode == SAMPLING_MODE_TOP_CARDINALITY && cube->primary_metric_id == metric_id) { hash = field_array_to_hash(tags_key, n_tag_key); } struct cell *cell_data = NULL; @@ -986,7 +985,7 @@ int cube_hll_add_field(struct cube *cube, int metric_id, const struct field *dim case SAMPLING_MODE_TOPK: { cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} - case SAMPLING_MODE_SPREADSKETCH: { + case SAMPLING_MODE_TOP_CARDINALITY: { cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, hash, metric_id); break;} default: @@ -1008,7 +1007,7 @@ int cube_hll_add_field(struct cube *cube, int metric_id, const struct field *dim int cube_counter_incrby(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, long long increment) { assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->sampling_mode == SAMPLING_MODE_TOPK && (cube->primary_metric_id != metric_id || increment >= 0)) || - (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && cube->primary_metric_id != metric_id) + (cube->sampling_mode == SAMPLING_MODE_TOP_CARDINALITY && cube->primary_metric_id != metric_id) ); const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); @@ -1024,7 +1023,7 @@ int cube_counter_incrby(struct cube *cube, int metric_id, const struct field *di case SAMPLING_MODE_TOPK: { cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, increment, metric_id); break;} - case SAMPLING_MODE_SPREADSKETCH: { + case SAMPLING_MODE_TOP_CARDINALITY: { cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} default: @@ -1058,7 +1057,7 @@ int cube_counter_set(struct cube *cube, int metric_id, const struct field *dimen case SAMPLING_MODE_TOPK: { cell_data = get_cell_in_topk_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} - case SAMPLING_MODE_SPREADSKETCH: { + case SAMPLING_MODE_TOP_CARDINALITY: { cell_data = get_cell_in_spread_sketch_cube(cube, dimensions, n_dimensions, 0, metric_id); break;} default: @@ -1087,7 +1086,7 @@ struct cube *cube_copy(const struct cube *cube) case SAMPLING_MODE_COMPREHENSIVE: cube_dup->table = hash_table_copy(cube->table); break; - case SAMPLING_MODE_SPREADSKETCH: + case SAMPLING_MODE_TOP_CARDINALITY: cube_dup->spread_sketch = spread_sketch_copy(cube->spread_sketch); break; default: @@ -1131,7 +1130,7 @@ int cube_merge(struct cube *dest, const struct cube *src) case SAMPLING_MODE_COMPREHENSIVE: hash_table_merge(dest->table, src->table); break; - case SAMPLING_MODE_SPREADSKETCH: + case SAMPLING_MODE_TOP_CARDINALITY: spread_sketch_merge(dest->spread_sketch, src->spread_sketch); break; default: @@ -1156,7 +1155,7 @@ struct cube *cube_fork(const struct cube *cube) { ret->table = hash_table_new(cube->max_n_cell); hash_table_set_exdata_schema(ret->table, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); break; - case SAMPLING_MODE_SPREADSKETCH: + case SAMPLING_MODE_TOP_CARDINALITY: ret->spread_sketch = spread_sketch_new(cube->max_n_cell); spread_sketch_set_exdata_schema(ret->spread_sketch, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); break; @@ -1196,7 +1195,7 @@ void cube_get_cells(const struct cube *cube, struct field_list **cell_dimensions case SAMPLING_MODE_TOPK: n_cell_tmp = heavy_keeper_get_count(cube->heavykeeper); break; - case SAMPLING_MODE_SPREADSKETCH: + case SAMPLING_MODE_TOP_CARDINALITY: n_cell_tmp = spread_sketch_get_count(cube->spread_sketch); break; default: @@ -1217,7 +1216,7 @@ void cube_get_cells(const struct cube *cube, struct field_list **cell_dimensions case SAMPLING_MODE_TOPK: heavy_keeper_list(cube->heavykeeper, (void **)cell_datas, n_cell_tmp); break; - case SAMPLING_MODE_SPREADSKETCH: + case SAMPLING_MODE_TOP_CARDINALITY: spread_sketch_list(cube->spread_sketch, (void **)cell_datas, n_cell_tmp); break; default: @@ -1225,7 +1224,7 @@ void cube_get_cells(const struct cube *cube, struct field_list **cell_dimensions } // spread sketch often stores more than max_n_cell. So sort out the top max_n_cell cells. - if (cube->sampling_mode == SAMPLING_MODE_SPREADSKETCH && n_cell_tmp > cube->max_n_cell) { + if (cube->sampling_mode == SAMPLING_MODE_TOP_CARDINALITY && n_cell_tmp > cube->max_n_cell) { struct tmp_sorted_data_spread_sketch_cell *tmp_sorted_data = (struct tmp_sorted_data_spread_sketch_cell *)malloc(sizeof(struct tmp_sorted_data_spread_sketch_cell) * n_cell_tmp); for (int i = 0; i < n_cell_tmp; i++) { tmp_sorted_data[i].data = cell_datas[i]; @@ -1274,7 +1273,7 @@ const struct cell *get_cell_by_tag_list(const struct cube *cube, const struct fi case SAMPLING_MODE_COMPREHENSIVE: ret = hash_table_get0_exdata(cube->table, tag_in_string, tag_len); break; - case SAMPLING_MODE_SPREADSKETCH: + case SAMPLING_MODE_TOP_CARDINALITY: ret = spread_sketch_get0_exdata(cube->spread_sketch, tag_in_string, tag_len); break; default: @@ -1383,7 +1382,7 @@ int cube_get_cell_count(const struct cube *cube) { return hash_table_get_count(cube->table); case SAMPLING_MODE_TOPK: return heavy_keeper_get_count(cube->heavykeeper); - case SAMPLING_MODE_SPREADSKETCH: + case SAMPLING_MODE_TOP_CARDINALITY: return spread_sketch_get_count(cube->spread_sketch); default: assert(0); diff --git a/src/exporter/cjson_exporter.c b/src/exporter/cjson_exporter.c index 3fecf40..bbe6fd3 100644 --- a/src/exporter/cjson_exporter.c +++ b/src/exporter/cjson_exporter.c @@ -116,7 +116,7 @@ struct couple_export_table { void kv_pair_free(struct export_kv_pair *pair) { - if (pair->type == TAG_CSTRING) { + if (pair->type == FIELD_VALUE_CSTRING) { free((char *)pair->value_str); } free((char *)pair->key); @@ -128,13 +128,13 @@ void kv_pair_fill_with_tags(struct export_kv_pair *dest, const struct field *src dest->key = strdup(src->key); dest->type = src->type; switch (src->type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: dest->value_longlong = src->value_longlong; break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: dest->value_double = src->value_double; break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: dest->value_str = strdup(src->value_str); break; default: @@ -229,17 +229,17 @@ bool fieldstat_tag_list_cmp(const struct field_list *a, const struct field_list } switch (a->field[i].type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: if (a->field[i].value_longlong != b->field[i].value_longlong) { return false; } break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: if (a->field[i].value_double != b->field[i].value_double) { return false; } break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: if (strcmp(a->field[i].value_str, b->field[i].value_str) != 0) { return false; } @@ -262,13 +262,13 @@ struct field_list *my_copy_fs_tag_list(const struct field_list *src) dest->field[i].type = src->field[i].type; switch (src->field[i].type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: dest->field[i].value_longlong = src->field[i].value_longlong; break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: dest->field[i].value_double = src->field[i].value_double; break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: dest->field[i].value_str = strdup(src->field[i].value_str); break; default: @@ -342,7 +342,7 @@ void write_delta_to_json(struct fieldstat_json_exporter *exporter, struct cellwi tag_json = "\a\t\a"; // just a dummy string } for (int j = 0; j < tag_field_pair->n_metric; j++) { - if (tag_field_pair->metric_pairs[j]->type != TAG_INTEGER) { // only counter type need to write delta + if (tag_field_pair->metric_pairs[j]->type != FIELD_VALUE_INTEGER) { // only counter type need to write delta continue; } const char *metric_name = tag_field_pair->metric_pairs[j]->key; @@ -535,7 +535,7 @@ struct export_kv_pair *cell_query_with_iter(const struct cell_iter *iter, int me } ret = malloc(sizeof(struct export_kv_pair)); ret->key = strdup(fieldstat_get_metric_name(iter->instance, cube_id, metric_id)); - ret->type = TAG_INTEGER; + ret->type = FIELD_VALUE_INTEGER; ret->value_longlong = value; return ret; } @@ -548,7 +548,7 @@ struct export_kv_pair *cell_query_with_iter(const struct cell_iter *iter, int me } ret = malloc(sizeof(struct export_kv_pair)); ret->key = strdup(fieldstat_get_metric_name(iter->instance, cube_id, metric_id)); - ret->type = TAG_CSTRING; + ret->type = FIELD_VALUE_CSTRING; ret->value_str = value; return ret; } @@ -560,13 +560,13 @@ void kv_pair_write_to_json(const struct export_kv_pair *pairs, struct json_write { switch (pairs->type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: json_writer_longlong_field(writer, pairs->key, pairs->value_longlong); break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: json_writer_double_field(writer, pairs->key, pairs->value_double); break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: json_writer_str_field(writer, pairs->key, pairs->value_str, strlen(pairs->value_str)); break; default: @@ -588,13 +588,13 @@ void tag_list_append_to_tag_object(const struct field_list *tag_list, struct jso pairs.type = tag_list->field[i].type; switch (pairs.type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: pairs.value_longlong = tag_list->field[i].value_longlong; break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: pairs.value_double = tag_list->field[i].value_double; break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: pairs.value_str = (char *)tag_list->field[i].value_str; break; default: @@ -627,7 +627,7 @@ void kv_pair_free_list(struct export_kv_pair *pairs, size_t len) { for (int i = 0; i < len; i++) { struct export_kv_pair *pair = &pairs[i]; - if (pair->type == TAG_CSTRING) { + if (pair->type == FIELD_VALUE_CSTRING) { free(pair->value_str); } free(pair->key); @@ -992,13 +992,13 @@ void fieldstat_json_exporter_set_global_tag(struct fieldstat_json_exporter *expo field->type = tag_list[i].type; switch (field->type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: field->value_longlong = tag_list[i].value_longlong; break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: field->value_str = strdup(tag_list[i].value_str); break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: field->value_double = tag_list[i].value_double; break; diff --git a/src/exporter/fieldstat_exporter.py b/src/exporter/fieldstat_exporter.py index c9eb523..aad7969 100644 --- a/src/exporter/fieldstat_exporter.py +++ b/src/exporter/fieldstat_exporter.py @@ -25,11 +25,11 @@ class FieldstatAPI: libfieldstat.fieldstat_histogram_free.argtypes = [ctypes.c_void_p] - libfieldstat.fieldstat_histogram_value_at_percentile.argtypes = [ctypes.c_void_p, ctypes.c_double] - libfieldstat.fieldstat_histogram_value_at_percentile.restype = ctypes.c_longlong + libfieldstat.fieldstat_histogram_value_at_percentile_api.argtypes = [ctypes.c_void_p, ctypes.c_double] + libfieldstat.fieldstat_histogram_value_at_percentile_api.restype = ctypes.c_longlong - libfieldstat.fieldstat_histogram_count_le_value.argtypes = [ctypes.c_void_p, ctypes.c_longlong] - libfieldstat.fieldstat_histogram_count_le_value.restype = ctypes.c_longlong + libfieldstat.fieldstat_histogram_count_le_value_api.argtypes = [ctypes.c_void_p, ctypes.c_longlong] + libfieldstat.fieldstat_histogram_count_le_value_api.restype = ctypes.c_longlong libfieldstat.fieldstat_histogram_value_total_count.argtypes = [ctypes.c_void_p] libfieldstat.fieldstat_histogram_value_total_count.restype = ctypes.c_longlong @@ -134,7 +134,7 @@ class PrometheusExporter: metrics = "" for i in self.hist_bins: - value = FieldstatAPI.libfieldstat.fieldstat_histogram_count_le_value(c_hist, int(i)) + value = FieldstatAPI.libfieldstat.fieldstat_histogram_count_le_value_api(c_hist, int(i)) metric = name + "_bucket" + "{" + tags + ",le=\"{:.2f}\"".format(i) + "}" + ' ' + str(value) + '\n' metrics += metric self.n_lines += 1 @@ -144,7 +144,7 @@ class PrometheusExporter: def __build_summary_format(self, name, tags, c_hist): metrics = "" for i in self.hist_bins: - value = FieldstatAPI.libfieldstat.fieldstat_histogram_value_at_percentile(c_hist, float(i * 100)) + value = FieldstatAPI.libfieldstat.fieldstat_histogram_value_at_percentile_api(c_hist, float(i * 100)) metric = name + "{" + tags + ",quantile=\"{:.2f}%\"".format(i * 100) + "}" + ' ' + str(value) + '\n' metrics += metric self.n_lines += 1 @@ -365,10 +365,10 @@ class HistogramTable: row_values = [] for i in self.bins: if self.format == "summary": - value = FieldstatAPI.libfieldstat.fieldstat_histogram_value_at_percentile(c_hist, float(i * 100)) + value = FieldstatAPI.libfieldstat.fieldstat_histogram_value_at_percentile_api(c_hist, float(i * 100)) row_values.append(str(value)) if self.format == "histogram": - value = FieldstatAPI.libfieldstat.fieldstat_histogram_count_le_value(c_hist, int(i)) + value = FieldstatAPI.libfieldstat.fieldstat_histogram_count_le_value_api(c_hist, int(i)) row_values.append(str(value)) shared_values = self.__get_row_shared_values(c_hist) row_values += shared_values diff --git a/src/fieldstat.c b/src/fieldstat.c index 0e2fb81..12c482b 100644 --- a/src/fieldstat.c +++ b/src/fieldstat.c @@ -69,7 +69,7 @@ void fieldstat_free_tag_array(struct field *fields, size_t n_tags) for (size_t i = 0; i < n_tags; i++) { struct field *field = &fields[i]; free((char *)field->key); - if (field->type == TAG_CSTRING) { + if (field->type == FIELD_VALUE_CSTRING) { free((char *)field->value_str); } } @@ -142,7 +142,7 @@ int fieldstat_register_hll(struct fieldstat *instance, int cube_id, const char * } // cppcheck-suppress [constParameterPointer, unmatchedSuppression] -int fieldstat_register_hist(struct fieldstat *instance, int cube_id, const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures) +int fieldstat_register_histogram(struct fieldstat *instance, int cube_id, const char *metric_name, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures) { struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -200,7 +200,7 @@ int fieldstat_hll_add_field(struct fieldstat *instance, int cube_id, int metric_ } // cppcheck-suppress [constParameterPointer, unmatchedSuppression] -int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id, const struct field *cell_dimensions, size_t n_dimensions, long long value) +int fieldstat_histogram_record(struct fieldstat *instance, int cube_id, int metric_id, const struct field *cell_dimensions, size_t n_dimensions, long long value) { struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -277,7 +277,7 @@ int fieldstat_hll_get(const struct fieldstat *instance, int cube_id, const struc return ret; } -long long fieldstat_hist_value_at_percentile(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, double percentile) +long long fieldstat_histogram_value_at_percentile(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, double percentile) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -292,7 +292,7 @@ long long fieldstat_hist_value_at_percentile(const struct fieldstat *instance, i return value; } -long long fieldstat_hist_count_le_value(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, long long value) +long long fieldstat_histogram_count_le_value(const struct fieldstat *instance, int cube_id, const struct field_list *cell_dimensions, int metric_id, long long value) { const struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { diff --git a/src/fieldstat_easy.c b/src/fieldstat_easy.c index ef1a921..00a569a 100644 --- a/src/fieldstat_easy.c +++ b/src/fieldstat_easy.c @@ -218,17 +218,17 @@ int fieldstat_easy_register_histogram(struct fieldstat_easy *fse, const char *na pthread_spin_lock(&fse->fsu[i].lock); } - int ret = fieldstat_register_hist(fse->fsu[0].active, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); // try to register + int ret = fieldstat_register_histogram(fse->fsu[0].active, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); // try to register if (ret < 0) { for (int i = 0; i < fse->max_thread_num; i++) { pthread_spin_unlock(&fse->fsu[i].lock); } return ret; } - fieldstat_register_hist(fse->fsu[0].read_only, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); + fieldstat_register_histogram(fse->fsu[0].read_only, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); for (int i = 1; i < fse->max_thread_num; i++) { - fieldstat_register_hist(fse->fsu[i].active, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); - fieldstat_register_hist(fse->fsu[i].read_only, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); + fieldstat_register_histogram(fse->fsu[i].active, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); + fieldstat_register_histogram(fse->fsu[i].read_only, 0, name, lowest_trackable_value, highest_trackable_value, significant_figures); } for (int i = 0; i < fse->max_thread_num; i++) { @@ -354,7 +354,7 @@ int fieldstat_easy_histogram_record(struct fieldstat_easy *fse, int thread_id, i } pthread_spin_lock(&fse->fsu[thread_id].lock); - int ret = fieldstat_hist_record(fse->fsu[thread_id].active, 0, metric_id, dimensions, n_dimensions, value); + int ret = fieldstat_histogram_record(fse->fsu[thread_id].active, 0, metric_id, dimensions, n_dimensions, value); pthread_spin_unlock(&fse->fsu[thread_id].lock); return ret; diff --git a/src/metrics/python_api.c b/src/metrics/python_api.c index 8388a1c..6f25fdf 100644 --- a/src/metrics/python_api.c +++ b/src/metrics/python_api.c @@ -16,12 +16,12 @@ void *fieldstat_histogram_base64_decode(char *buf) return hdr; } -long long fieldstat_histogram_value_at_percentile(void* h, double percentile) +long long fieldstat_histogram_value_at_percentile_api(void* h, double percentile) { return hdr_value_at_percentile((const struct hdr_histogram *)h, percentile); } -long long fieldstat_histogram_count_le_value(void* h, long long value) +long long fieldstat_histogram_count_le_value_api(void* h, long long value) { return hdr_count_le_value((const struct hdr_histogram *)h, value); } diff --git a/src/tags/heavy_keeper.c b/src/tags/heavy_keeper.c deleted file mode 100644 index c257e1d..0000000 --- a/src/tags/heavy_keeper.c +++ /dev/null @@ -1,822 +0,0 @@ -#include "heavy_keeper.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "minheap/heap.h" -#include "mpack/mpack.h" -#include "xxhash/xxhash.h" -// XXHASH is faster -#define HASH_FUNCTION(keyptr, keylen, hashv) \ - do { \ - hashv = XXH3_64bits(keyptr, keylen); \ - } while (0) - -#include "uthash.h" - -#include "exdata.h" - -#define FP_HASH_KEY 0 -#define NOT_FIND (-1) -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -struct entry_data { // the value constitute of a sorted set entry - char *key; - size_t key_len; - - void *exdata; -}; - -struct sorted_set { - heap *heap; - struct hash_node *hash_tbl; - - int n_living_entry; - - exdata_new_cb new_fn; - exdata_free_cb free_fn; - exdata_merge_cb merge_fn; - exdata_reset_cb reset_fn; - exdata_copy_cb copy_fn; -}; - -struct hash_node { - const char *key; // value is equal to entry_data::key(point to the same memory) - size_t key_len; - heap_entry *val; - UT_hash_handle hh; -}; - -struct Bucket { - uint64_t finger_print; - long long count; // the actual count, sum of all uuid_hash_node->count -}; - -// Parameters used in algorithm -struct heavy_keeper_options{ - int r; // the size of the array. Default value: 4 - // Set it by how accurate you want. Value of 4 guarantees an accuracy more than 90% and around 97% in all tests. - // Not too big because it have an impact on both time and memory efficiency. - int w; // M2, the maximum number of buckets every array keeps. Default value: k*log(k) and no less than 100. - // Basically, as long as big enough, it won't affect the accuracy significantly. - double b; // b, bigger variance of flow size is(elephant flows take more ratio), smaller it should be. - // Must bigger than 1. Better not bigger than 1.3, otherwise some elephant flow will be missed. -}; - -struct heavy_keeper { - int K; - struct sorted_set *top_K_heap; - struct heavy_keeper_options params; - struct Bucket *sketch; - - unsigned int rand_state; - - exdata_new_cb new_fn; - exdata_free_cb free_fn; - exdata_merge_cb merge_fn; - exdata_reset_cb reset_fn; - exdata_copy_cb copy_fn; -}; - -static void *default_new_fn(void *arg) { - return NULL; -} - -static void default_free_fn(void *exdata) { - return; -} - -static void default_merge_fn(void *dest, void *src) { - return; -} - -static void default_reset_fn(void *exdata) { - return; -} - -static void *default_copy_fn(void *exdata) { - return exdata; -} - -struct entry_data *entry_data_construct(const char *key, size_t key_len, void *exdata) -{ - struct entry_data *entry_data = (struct entry_data *)malloc(sizeof(struct entry_data)); - - entry_data->key = (char *)malloc(key_len); - memcpy(entry_data->key, key, key_len); - entry_data->key_len = key_len; - entry_data->exdata = exdata; - return entry_data; -} - -void entry_data_destroy(struct entry_data *entry_data, exdata_free_cb free_fn) -{ - if (entry_data == NULL) { - return; - } - free(entry_data->key); - free_fn(entry_data->exdata); - free(entry_data); -} - -static inline long long sorted_set_entry_get_score(const heap_entry *entry) -{ - long long score = *(long long *)entry->key; - if (score == 0) { - return 0; - } - return score - 1; // sorted set will let the count start from 1, 0 for dying entry. -} - -struct entry_data *sorted_set_entry_get_data(const heap_entry *entry) -{ - return entry->value; -} - -/* - dying: To reduce the time of HASH_ADD, and to support merely recording a key without any value, give a dying status. -*/ -static inline bool sorted_set_entry_dying(const heap_entry *entry) -{ - long long score = *(long long *)entry->key; - return score == 0; -} - -static inline long long safe_add(long long a, long long b) -{ - if (INT64_MAX - a < b) { - return INT64_MAX; - } - return a + b; -} - -// cppcheck-suppress [constParameterCallback, unmatchedSuppression] -static bool cmp_entry_cb(void *aa, void *bb) -{ - heap_entry *a = (heap_entry *)aa; - heap_entry *b = (heap_entry *)bb; - long long score_a = *(long long *)a->key; - long long score_b = *(long long *)b->key; - - if (score_a < score_b) { - return true; - } - return false; -} - -static int entry_get_index_cb(void *a) -{ - return ((heap_entry *)a)->index; -} - -void entry_set_index_cb(int index, void *a) -{ - ((heap_entry *)a)->index = index; -} - -struct sorted_set *sorted_set_new(int set_size) -{ - struct sorted_set *ret = (struct sorted_set *)malloc(sizeof(struct sorted_set)); - ret->hash_tbl = NULL; - ret->n_living_entry = 0; - heap *h = (heap *)malloc(sizeof(heap)); - init_heap(h, set_size, cmp_entry_cb, entry_get_index_cb, entry_set_index_cb); - - ret->heap = h; - - ret->new_fn = default_new_fn; - ret->free_fn = default_free_fn; - ret->merge_fn = default_merge_fn; - ret->reset_fn = default_reset_fn; - ret->copy_fn = default_copy_fn; - - return ret; -} - -void sorted_set_schema_set(struct sorted_set *ss, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn) -{ - ss->new_fn = new_fn; - ss->free_fn = free_fn; - ss->merge_fn = merge_fn; - ss->reset_fn = reset_fn; - ss->copy_fn = copy_fn; -} - -void sorted_set_free(struct sorted_set *ss) -{ - struct hash_node *tbl = ss->hash_tbl; - struct hash_node *h_node, *tmp; - HASH_ITER(hh, tbl, h_node, tmp) { - HASH_DEL(tbl, h_node); - free(h_node); - } - - heap *heap = ss->heap; - heap_entry *node; - for (int i = 0; i < heap->cur_size; i++) { - node = (heap_entry *)heap->nodes[i]; - entry_data_destroy(node->value, ss->free_fn); - free(node->key); - free(node); - } - free(heap->nodes); - free(heap); - - free(ss); -} - -heap_entry *sorted_set_find_entry(const struct sorted_set *ss, const char *key, size_t key_len) -{ - struct hash_node *hash_tbl = ss->hash_tbl; - struct hash_node *s = NULL; - HASH_FIND(hh, hash_tbl, key, key_len, s); - - if (s == NULL) { - return NULL; - } - return (heap_entry *)s->val; -} - -static inline void sorted_set_entry_set_score(struct sorted_set *ss, heap_entry *entry, long long score) -{ - *(long long *)(entry->key) = score; - - adjust_heap_node(ss->heap, entry); -} - -int sorted_set_pop(struct sorted_set *ss) -{ - struct hash_node *hash_tbl = ss->hash_tbl; - heap_entry *entry = (heap_entry *)pop_heap(ss->heap); - if (entry == NULL) { - return -1; - } - struct entry_data *tmp_data = sorted_set_entry_get_data(entry); - - struct hash_node *s = NULL; - HASH_FIND(hh, hash_tbl, tmp_data->key, tmp_data->key_len, s); - assert(s!=NULL); - - HASH_DEL(hash_tbl, s); - free(s); - ss->hash_tbl = hash_tbl; - - int ret; - if (sorted_set_entry_dying(entry)) { - ret = 0; - } else { - ss->n_living_entry--; - ret = 1; - } - - entry_data_destroy(tmp_data, ss->free_fn); - free(entry->key); - free(entry); - - return ret; -} - -static inline bool sorted_set_check_is_full(const struct sorted_set *ss) -{ - return ss->heap->cur_size >= ss->heap->max_size; -} - -long long sorted_set_get_min_score(const struct sorted_set *ss) -{ - heap *heap = ss->heap; - if (heap->cur_size == 0) { - return NOT_FIND; - } - const heap_entry *ret = (heap_entry *)(heap->nodes[0]); - - long long score = *(long long *)ret->key; - if (score == 0) { - return NOT_FIND; - } - return score - 1; // sorted set will let the score start from 1, 0 for dying entry. -} - -void sorted_set_insert_to_available_heap(struct sorted_set *ss, const char *key, size_t key_len, long long cnt, void *exdata) -{ - cnt = safe_add(cnt, 1); // sorted set will let the score start from 1, 0 for dying entry. - long long *tmp_cnt = (long long*)malloc(sizeof(long long)); - *tmp_cnt = cnt; - struct entry_data *tmp_data = entry_data_construct(key, key_len, exdata); - heap_entry *node = (heap_entry *)malloc(sizeof(heap_entry)); - node->key = tmp_cnt; - node->value = tmp_data; - - push_heap(ss->heap, (void *)node); - - struct hash_node *hash_tbl = ss->hash_tbl; - struct hash_node *s = (struct hash_node *)malloc(sizeof(struct hash_node)); - s->key = sorted_set_entry_get_data(node)->key; - s->key_len = key_len; - s->val = node; - HASH_ADD_KEYPTR(hh, hash_tbl, s->key, key_len, s); - ss->hash_tbl = hash_tbl; - - ss->n_living_entry++; -} - -int sorted_set_insert(struct sorted_set *ss, const char *key, size_t key_len, long long cnt, void *args) -{ - // if there is a dying record, reborn it to use. - heap_entry *entry = sorted_set_find_entry(ss, key, key_len); - if (entry != NULL) { - if (!sorted_set_entry_dying(entry)) { - assert(0); - return -1; - } - sorted_set_entry_set_score(ss, entry, safe_add(cnt, 1)); // sorted set will let the score start from 1, 0 for dying entry. - - ss->n_living_entry++; - return 1; - } - - if (sorted_set_check_is_full(ss)) { - long long tmp_mincnt = sorted_set_get_min_score(ss); - if (tmp_mincnt != NOT_FIND && cnt <= tmp_mincnt) { // even if all cells in sorted set are dying, the sorted set can still be a full one, in which case, the min score is invalid. - return 0; - } - sorted_set_pop(ss); - } - sorted_set_insert_to_available_heap(ss, key, key_len, cnt, ss->new_fn(args)); - return 1; -} - -static inline int sorted_set_cardinality(const struct sorted_set *ss) -{ - return ss->n_living_entry; -} - -long long sorted_set_get_score(const struct sorted_set *ss, const char *key, size_t key_len) -{ - if (sorted_set_cardinality(ss) == 0) { - return NOT_FIND; - } - const heap_entry *entry = sorted_set_find_entry(ss, key, key_len); - if (entry == NULL) { - return NOT_FIND; - } - if (sorted_set_entry_dying(entry)) { - return NOT_FIND; - } - - return sorted_set_entry_get_score(entry); -} - -int sorted_set_incrby(struct sorted_set *ss, const char *key, size_t key_len, long long score) -{ - heap_entry *entry = sorted_set_find_entry(ss, key, key_len); - if (entry == NULL) { - return -1; - } - long long cnt_old; - if (sorted_set_entry_dying(entry) == false) { - cnt_old = sorted_set_entry_get_score(entry); - cnt_old += 1; // sorted set will let the score start from 1, 0 for dying entry. - } else { - cnt_old = 0; - } - sorted_set_entry_set_score(ss, entry, safe_add(score, cnt_old)); - return 0; -} - -typedef struct { - long long key; - struct entry_data *val; -} tmp_heap_node; - -int cmp_tmp_heap_node(const void *a, const void *b) -{ - const tmp_heap_node *aa = (tmp_heap_node *)a; - const tmp_heap_node *bb = (tmp_heap_node *)b; - - if (aa->key < bb->key) { - return 1; - } else if (aa->key > bb->key) { - return -1; - } else { - return 0; - } -} - -void sorted_set_dump(const struct sorted_set *ss, char **key_out, size_t *key_len_out, void **exdata_out) -{ - struct minheap *h = ss->heap; - tmp_heap_node *tmp_nodes = (tmp_heap_node *)malloc(sizeof(tmp_heap_node) * h->cur_size); - size_t n_living_entry = 0; - for (int i = 0; i < h->cur_size; i++) { - const heap_entry *entry = (heap_entry *)h->nodes[i]; - if (sorted_set_entry_dying(entry)) { - continue; - } - tmp_nodes[n_living_entry].key = sorted_set_entry_get_score(entry); - tmp_nodes[n_living_entry].val = sorted_set_entry_get_data(entry); - n_living_entry++; - } - - assert(n_living_entry == ss->n_living_entry); - qsort(tmp_nodes, n_living_entry, sizeof(tmp_heap_node), cmp_tmp_heap_node); - for (int i = 0; i < n_living_entry; i++) { - key_out[i] = tmp_nodes[i].val->key; - key_len_out[i] = tmp_nodes[i].val->key_len; - exdata_out[i] = tmp_nodes[i].val->exdata; - } - free(tmp_nodes); -} - -struct sorted_set *sorted_set_copy(const struct sorted_set *ss) -{ - struct sorted_set *ret = sorted_set_new(ss->heap->max_size); - sorted_set_schema_set(ret, ss->new_fn, ss->free_fn, ss->merge_fn, ss->reset_fn, ss->copy_fn); - - for (int i = 0; i < ss->heap->cur_size; i++) { - const heap_entry *entry = (heap_entry *)ss->heap->nodes[i]; - if (sorted_set_entry_dying(entry)) { - continue; - } - const struct entry_data *data = sorted_set_entry_get_data(entry); - sorted_set_insert_to_available_heap(ret, data->key, data->key_len, sorted_set_entry_get_score(entry), ss->copy_fn(data->exdata)); - } - - return ret; -} - -// set all the entry to dying status. They will be the first to be popped. -void sorted_set_reset(struct sorted_set *ss) -{ - heap *heap = ss->heap; - heap_entry *entry; - for (int i = 0; i < heap->cur_size; i++) { - entry = (heap_entry *)heap->nodes[i]; - *(long long *)entry->key = 0; - - ss->reset_fn(sorted_set_entry_get_data(entry)->exdata); - } - - ss->n_living_entry = 0; -} - -/* -------------------------------------------------------------------------- */ -/* heavy keeper */ -/* -------------------------------------------------------------------------- */ - -struct Bucket *new_sketch(struct heavy_keeper_options *params) { - size_t array_len = (size_t)params->r * (size_t)params->w; - - struct Bucket *ret = (struct Bucket *)calloc(array_len, sizeof(struct Bucket)); - - return ret; -} - -void params_set_to_default(struct heavy_keeper_options *p, int K) { - if (K > 5000) { // don't let the sketch too large when K gets insanely large - K = 5000; - } - double log_ret = log((double)K) / 2.3; // 2.3: log_e(10), log_ret = log_10(K) - - if (log_ret < 3) { - p->r = 3; - } else { - p->r = (int)(log_ret); - } - p->b = 1.17; // by test, 1.17 is the best - p->w = (int)(log_ret * K * 2); - if (p->w < 150) { - p->w = 150; // determined through test, too small max_bucket_num will let accuracy decrease severely. - } else if (p->w > 600) { - p->w = p->w / 4 + 450; - } -} - -struct heavy_keeper *heavy_keeper_new(int max_query_num) { - struct heavy_keeper *hk = (struct heavy_keeper *)malloc(sizeof(struct heavy_keeper)); - hk->K = max_query_num; - hk->rand_state = 0; - - hk->top_K_heap = sorted_set_new(max_query_num); - - params_set_to_default(&(hk->params), max_query_num); - - hk->sketch = new_sketch(&(hk->params)); - - hk->new_fn = default_new_fn; - hk->free_fn = default_free_fn; - hk->merge_fn = default_merge_fn; - hk->reset_fn = default_reset_fn; - - return hk; -} - -void heavy_keeper_free(struct heavy_keeper *hk) { - sorted_set_free(hk->top_K_heap); - free(hk->sketch); - - free(hk); -} - -void heavy_keeper_reset(struct heavy_keeper *hk) { - sorted_set_reset(hk->top_K_heap); - memset(hk->sketch, 0, sizeof(struct Bucket) * (size_t)hk->params.r * (size_t)hk->params.w); -} - -const int DECAY_POW_TABLE[128] = { // 1.17 ^ exp * RAND_MAX, exp is in [0,127] -2147483647,1835456109,1568765905,1340825560,1146004752,979491241,837172001,715531625,611565491,522705548,446756879,381843486,326361954,278941841,238411830,203770795,174163072,148857327,127228484,108742294,92942132, -79437720,67895487,58030331,49598573,42391943,36232430,30967889,26468281,22622462,19335438,16526015,14124799,12072478,10318357,8819109,7537700,6442479,5506392,4706318,4022494,3438029,2938486,2511527,2146604, -1834704,1568123,1340276,1145535,979090,836829,715239,611315,522491,446574,381687,326228,278828,238314,203687,174092,148796,127176,108698,92904,79405,67868,58007,49578,42375,36218,30955,26457,22613,19328,16519, -14119,12068,10314,8815,7535,6440,5504,4704,4021,3437,2937,2510,2146,1834,1567,1340,1145,979,836,715,611,522,446,382,326,279,238,204,174,149,127,109,93,79,68,58,50,42,36,31,26,23,19,17,14,12,10,9,8,6,6,5, -}; -bool if_need_to_decay(struct heavy_keeper *hk, const struct Bucket *bucket, long long count) { - if (count == 0) { - return false; - } - if (bucket->count < count) { // the exp is 0, so the decay rate is 1 - return true; - } - - long long exp = bucket->count / count; - if (exp > 127) { // decay_rate too small, almost no chance to decay - return false; - } - - // double decay_rate = pow(hk->params.b, -exp); - // p->b = 1.17 is fixed, search table to get result directly. - int decay_rate = DECAY_POW_TABLE[exp]; - - if (rand_r(&(hk->rand_state)) < decay_rate) { - return true; - } - return false; -} - -static inline uint64_t cal_hash_val_with_seed(const char *key, size_t key_len, unsigned int seed) { - return XXH3_64bits_withSeed(key, key_len, seed); -} - -/* -1 for newly add something. 0 for not add. -1 for unexpected cases. -*/ -int heavy_keeper_add(struct heavy_keeper *heavy_keeper, const char *key, size_t key_len, long long count, void *arg) { - assert(count >= 0); - if (count == 0) { - if (sorted_set_cardinality(heavy_keeper->top_K_heap) < heavy_keeper->K) { - const struct heap_entry *entry = sorted_set_find_entry(heavy_keeper->top_K_heap, key, key_len); - - if (entry != NULL && !sorted_set_entry_dying(entry)) { - return 0; - } - - sorted_set_insert(heavy_keeper->top_K_heap, key, key_len, count, arg); - return 1; - } - return 0; - } - - struct sorted_set *summary = heavy_keeper->top_K_heap; - - long long old_cnt = sorted_set_get_score(summary, key, key_len); // todo: 改成 score - bool not_in_sorted_set = (old_cnt == NOT_FIND); - long long maxv = 0; - uint64_t fp = cal_hash_val_with_seed(key, key_len, FP_HASH_KEY); - uint64_t h1 = fp; - uint64_t h2 = cal_hash_val_with_seed(key, key_len, FP_HASH_KEY+1); - - for (uint64_t j = 0; j < heavy_keeper->params.r; j++) { - uint64_t hashv = h1 + j * h2; // use `double hashing` strategy - struct Bucket *bucket = &(heavy_keeper->sketch[j * heavy_keeper->params.w + (hashv % heavy_keeper->params.w)]); - - if (bucket->finger_print == fp) { - // If a key is not in the min-heap, then the estimated key size should be no larger than nmin. - // or if the min-heap is not full(min_value == NOT_FIND), every key should be taken into account, so of course it should be added. - // in neither case, bucket->count > nMin && not_in_sorted_set happen. - // The keys whose counts are both larger than nmin and not in min-heap must have the same xxhash value, and its FP stored in bucket represents another field, - // In this case, the sketch won't be updated. This key is expected to be taken into account in another array, - // where its FP is different from the one it should collided with, so that element keys won't be missed. - if (not_in_sorted_set) { - long long min_value = sorted_set_get_min_score(summary); - if (min_value != NOT_FIND && bucket->count > min_value) { - continue; - } - } - bucket->count = safe_add(bucket->count, count); - maxv = MAX(maxv, bucket->count); - } else { - if (!if_need_to_decay(heavy_keeper, bucket, count)) { - continue; - } - - if (bucket->count < count) { - bucket->finger_print = fp; - bucket->count = count; - - maxv = MAX(maxv, count); - } else { - bucket->count -= count; - } - } - } - - if (not_in_sorted_set) { - if (sorted_set_cardinality(summary) != heavy_keeper->K) { - sorted_set_insert(summary, key, key_len, maxv, arg); - return 1; - } - long long min_value = sorted_set_get_min_score(summary); - if (maxv > min_value || min_value == NOT_FIND) { - sorted_set_insert(summary, key, key_len, maxv, arg); - return 1; - } - return 0; - } else { - if (maxv > old_cnt) { - sorted_set_incrby(summary, key, key_len, maxv - old_cnt); - } - return 1; // no popped, but the exdata definitely exists in the sorted set - } -} - -int heavy_keeper_set_exdata_schema(struct heavy_keeper *hk, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn) { - sorted_set_schema_set(hk->top_K_heap, new_fn, free_fn, merge_fn, reset_fn, copy_fn); - hk->new_fn = new_fn; - hk->free_fn = free_fn; - hk->merge_fn = merge_fn; - hk->reset_fn = reset_fn; - hk->copy_fn = copy_fn; - - return 0; -} - -void *heavy_keeper_get0_exdata(const struct heavy_keeper *hk, const char *key, size_t key_len) { - const heap_entry *entry = sorted_set_find_entry(hk->top_K_heap, key, key_len); - if (entry == NULL || sorted_set_entry_dying(entry)) { - return NULL; - } - return sorted_set_entry_get_data(entry)->exdata; -} - -int heavy_keeper_get_count(const struct heavy_keeper *hk) { - return sorted_set_cardinality(hk->top_K_heap); -} - -size_t heavy_keeper_list(const struct heavy_keeper *hk, void **exdatas, size_t n_exdatas) { - size_t actual_len = sorted_set_cardinality(hk->top_K_heap); - if (actual_len == 0) { - return 0; - } - - char **keys_dummy = (char **)malloc(sizeof(char *) * actual_len); - size_t *key_lens_dummy = (size_t *)malloc(sizeof(size_t) * actual_len); - if (n_exdatas < actual_len) { - void **exdatas_ret = (void **)malloc(sizeof(void *) * actual_len); - sorted_set_dump(hk->top_K_heap, keys_dummy, key_lens_dummy, exdatas_ret); - memcpy(exdatas, exdatas_ret, sizeof(void *) * n_exdatas); - free(exdatas_ret); - } else { - sorted_set_dump(hk->top_K_heap, keys_dummy, key_lens_dummy, exdatas); - } - - free(keys_dummy); - free(key_lens_dummy); - - return actual_len < n_exdatas ? actual_len : n_exdatas; -} - -static void heavy_keeper_merge_sketch(struct heavy_keeper *dest, const struct heavy_keeper *src) { - int w = dest->params.w; - int d = dest->params.r; - //idx - for (int array_id = 0; array_id < d; array_id++) { - for (int bucket_id = 0; bucket_id < w; bucket_id++) { - struct Bucket *bucket_dest = &(dest->sketch[array_id * w + bucket_id]); - const struct Bucket *bucket_src = &(src->sketch[array_id * w + bucket_id]); - - if (bucket_dest->finger_print == bucket_src->finger_print) { - bucket_dest->count = safe_add(bucket_dest->count, bucket_src->count); - } else { - if (bucket_dest->count < bucket_src->count) { - bucket_dest->count = bucket_src->count; - bucket_dest->finger_print = bucket_src->finger_print; - } - } - } - } -} - -long long find_count_in_sketch(struct heavy_keeper *hk, const char *key, size_t key_len) { - struct Bucket *bucket; - uint64_t fp = cal_hash_val_with_seed(key, key_len, FP_HASH_KEY); - uint64_t h1 = fp; - uint64_t h2 = cal_hash_val_with_seed(key, key_len, FP_HASH_KEY+1); - - long long maxv = 0; - for (uint64_t array_id = 0; array_id < hk->params.r; array_id++) { - uint64_t hash = h1 + array_id * h2; - bucket = &(hk->sketch[array_id * hk->params.w + (hash % hk->params.w)]); - - if (bucket->finger_print == fp) { - maxv = MAX(maxv, bucket->count); - } - } - - return maxv; -} - -void heavy_keeper_merge(struct heavy_keeper *dest, const struct heavy_keeper *src) { - assert(dest->K == src->K); - - heavy_keeper_merge_sketch(dest, src); - - struct sorted_set *new_rec = sorted_set_new(dest->K); // merging result - sorted_set_schema_set(new_rec, dest->new_fn, dest->free_fn, dest->merge_fn, dest->reset_fn, dest->copy_fn); - const struct sorted_set *ss_dest = dest->top_K_heap; // original ss in dest - const struct sorted_set *ss_src = src->top_K_heap; // the ss to be merged - int size_dest = sorted_set_cardinality(ss_dest); - int size_src = sorted_set_cardinality(ss_src); - int max_size = size_dest > size_src ? size_dest : size_src; - - void **exdatas_dst = (void **)calloc(size_dest, sizeof(void *)); - char **key_arr = (char **)malloc(sizeof(char *) * max_size); - size_t *key_lens = (size_t *)malloc(sizeof(size_t) * max_size); - sorted_set_dump(ss_dest, key_arr, key_lens, exdatas_dst); - - - /* ------------------------------ merge dest ------------------------------ */ - for (int i = 0; i < size_dest; i++) { - long long maxv = find_count_in_sketch(dest, key_arr[i], key_lens[i]); - sorted_set_insert_to_available_heap(new_rec, key_arr[i], key_lens[i], maxv, dest->copy_fn(exdatas_dst[i])); - } - - /* ------------------------------ merge src ------------------------------ */ - void **exdatas_src = (void **)calloc(size_src, sizeof(void *)); - sorted_set_dump(ss_src, key_arr, key_lens, exdatas_src); - - for (int i = 0; i < size_src; i++) { - const heap_entry *entry = sorted_set_find_entry(new_rec, key_arr[i], key_lens[i]); - if (entry != NULL) { // the key is in both dest and src, so has been processed in the previous loop. The reason why no need to sum up result is that merged sketch already keeps its summed up count - void *exdata_new = sorted_set_entry_get_data(entry)->exdata; - void *exdata_src = exdatas_src[i]; - dest->merge_fn(exdata_new, exdata_src); - - continue; - } - - long long cnt = find_count_in_sketch(dest, key_arr[i], key_lens[i]);// the cnt is the estimated count in the merged sketch, since the dest heavy keeper has been merged - if (sorted_set_check_is_full(new_rec)) { - long long mincnt_new = sorted_set_get_min_score(new_rec); - if (cnt > mincnt_new) { - sorted_set_pop(new_rec); - sorted_set_insert_to_available_heap(new_rec, key_arr[i], key_lens[i], cnt, dest->copy_fn(exdatas_src[i])); - } - } else { - sorted_set_insert_to_available_heap(new_rec, key_arr[i], key_lens[i], cnt, dest->copy_fn(exdatas_src[i])); - } - } - - free(key_arr); - free(key_lens); - free(exdatas_dst); - free(exdatas_src); - sorted_set_free(dest->top_K_heap); - dest->top_K_heap = new_rec; -} - -struct heavy_keeper *heavy_keeper_copy(const struct heavy_keeper *src) { - struct heavy_keeper *ret = (struct heavy_keeper *)malloc(sizeof(struct heavy_keeper)); - ret->K = src->K; - ret->rand_state = 0; - - ret->top_K_heap = sorted_set_copy(src->top_K_heap); - - ret->params = src->params; - ret->sketch = (struct Bucket *)malloc(sizeof(struct Bucket) * (size_t)ret->params.r * (size_t)ret->params.w); - memcpy(ret->sketch, src->sketch, sizeof(struct Bucket) * (size_t)ret->params.r * (size_t)ret->params.w); - - ret->new_fn = src->new_fn; - ret->free_fn = src->free_fn; - ret->merge_fn = src->merge_fn; - ret->reset_fn = src->reset_fn; - ret->copy_fn = src->copy_fn; - - return ret; -} - -void heavy_keeper_one_point_query(const struct heavy_keeper *hk, const char *key, size_t key_len, long long *count_out, void **exdata_out) { - *count_out = 0; - *exdata_out = NULL; - - const heap_entry *entry = sorted_set_find_entry(hk->top_K_heap, key, key_len); - if (entry == NULL) { - return; - } - *count_out = sorted_set_entry_get_score(entry); - *exdata_out = sorted_set_entry_get_data(entry)->exdata; -} \ No newline at end of file diff --git a/src/tags/heavy_keeper.h b/src/tags/heavy_keeper.h deleted file mode 100644 index 3b09598..0000000 --- a/src/tags/heavy_keeper.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -#include "exdata.h" - - -struct heavy_keeper; - -struct heavy_keeper *heavy_keeper_new(int max_query_num); -/** - * @brief free a heavy keeper. - * @param hk the pointer to the heavy keeper. - */ -void heavy_keeper_free(struct heavy_keeper *hk); - -/* - * @brief clear a heavy keeper. It will clear all the data in the heavy keeper. as for every exdata, use the reset function `exdata_reset_cb` to reset it. - * @param hk the pointer to the heavy keeper. -*/ -void heavy_keeper_reset(struct heavy_keeper *hk); - -int heavy_keeper_add(struct heavy_keeper *hk, const char *key, size_t key_len, long long count, void *arg); - -int heavy_keeper_set_exdata_schema(struct heavy_keeper *hk, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn); - -void *heavy_keeper_get0_exdata(const struct heavy_keeper *hk, const char *key, size_t key_len); - -// get the number of cells in the heavy keeper -int heavy_keeper_get_count(const struct heavy_keeper *hk); - -size_t heavy_keeper_list(const struct heavy_keeper *hk, void **exdatas, size_t n_exdatas); - -void heavy_keeper_merge(struct heavy_keeper *dest, const struct heavy_keeper *src); - -struct heavy_keeper *heavy_keeper_copy(const struct heavy_keeper *src); - -// for test -void heavy_keeper_one_point_query(const struct heavy_keeper *hk, const char *key, size_t key_len, long long *count_out, void **exdata_out); - - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/src/tags/spread_sketch.c b/src/tags/spread_sketch.c deleted file mode 100644 index 0d39d16..0000000 --- a/src/tags/spread_sketch.c +++ /dev/null @@ -1,365 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "xxhash/xxhash.h" -#include "uthash.h" - -#include "spread_sketch.h" -#include "exdata.h" - -// todo:把primary metric 记到sketch 里,且使用特殊的st Hyperloglog - -struct entry { - int ref_count; - void *exdata; - bool dying; - char *key; - size_t key_len; - UT_hash_handle hh; -}; - -struct spread_sketch_scheme { - exdata_new_cb new_fn; - exdata_free_cb free_fn; - exdata_merge_cb merge_fn; - exdata_reset_cb reset_fn; - exdata_copy_cb copy_fn; -}; - -struct entry_table { - struct entry *entry; - - struct spread_sketch_scheme scheme; -}; - -struct bucket { - struct entry *content; - uint32_t level; -}; - -struct spread_sketch { - int depth; - int width; - - struct spread_sketch_scheme scheme; - - struct bucket *buckets; - struct entry_table *table; - - uint32_t *min_level_per_row; // TODO: 先看看性能吧, 之后再写。用来记录每行最小的level,从而跳过行数。对于64位的level,维持一个计数,额外使用64 r的空间,当一个最小位数的level 计数到0时,更新最小level。 - // TODO: 对比heavy keeper,不仅仅是跳过的问题,heavykeeper 无论什么情况,在输入0的时候都不会走sketch 更新。 -}; - -static void *default_new_fn(void *arg) { - return NULL; -} -static void default_free_fn(void *exdata) { - return; -} -static void default_merge_fn(void *dest, void *src) { - return; -} -static void default_reset_fn(void *exdata) { - return; -} -static void *default_copy_fn(void *exdata) { - return exdata; -} -static inline bool key_equal(const char *key1, size_t key1_len, const char *key2, size_t key2_len) { - if (key1_len != key2_len) { - return false; - } - return memcmp(key1, key2, key1_len) == 0; -} -static inline char *key_dup(const char *key, size_t key_len) { - char *ret = malloc(key_len+1); - memcpy(ret, key, key_len); - ret[key_len] = '\0'; - return ret; -} - -struct entry *smart_ptr_table_get(struct entry_table *table, const char *key, size_t key_len, void *arg) { - struct entry *ret; - HASH_FIND(hh, table->entry, key, key_len, ret); - - if (ret != NULL) { - ret->dying = false; - ret->ref_count++; - } else { - ret = malloc(sizeof(struct entry)); - ret->dying = false; - ret->ref_count = 1; - ret->key = key_dup(key, key_len); - ret->key_len = key_len; - if (arg == NULL) { - ret->exdata = NULL; - } else { - ret->exdata = table->scheme.new_fn(arg); - } - HASH_ADD_KEYPTR(hh, table->entry, ret->key, ret->key_len, ret); - } - - return ret; -} - -int smart_ptr_table_release(struct entry_table *table, const char *key, size_t key_len) { - struct entry *ret; - HASH_FIND(hh, table->entry, key, key_len, ret); - if (ret == NULL) { - return -1; - } - - ret->ref_count--; - if (ret->ref_count == 0) { - // printf("release %s\n", key); - HASH_DEL(table->entry, ret); - table->scheme.free_fn(ret->exdata); - free(ret->key); - free(ret); - } - - return 0; -} - -void smart_ptr_table_free(struct entry_table *table) { - struct entry *current, *tmp; - HASH_ITER(hh, table->entry, current, tmp) { - HASH_DEL(table->entry, current); - table->scheme.free_fn(current->exdata); - free(current->key); - free(current); - } - free(table); -} - -struct entry_table *smart_ptr_table_new() { - struct entry_table *table = malloc(sizeof(struct entry_table)); - table->entry = NULL; - - table->scheme.new_fn = default_new_fn; - table->scheme.free_fn = default_free_fn; - table->scheme.merge_fn = default_merge_fn; - table->scheme.reset_fn = default_reset_fn; - table->scheme.copy_fn = default_copy_fn; - - return table; -} - -void get_parameter_recommendation(int max_super_spreader_number, int *depth_out, int *width_out) -{ - int logk = max_super_spreader_number >= 3200 ? 4 : 3; // lg3200 = 3.51,round up to 4 - *depth_out = logk; - - int w; - if (max_super_spreader_number <= 100) { - w = max_super_spreader_number * 3 /2; // * 1.5, when the number is small, we need more width - } else { - w = max_super_spreader_number + 50; // + 50: 100*1.5-100 = 50, make w=f(k) continuous - } - if (w < 40) { - w = 40; - } - *width_out = w; -} - -struct spread_sketch *spread_sketch_new(int expected_query_num) { - struct spread_sketch *pthis = malloc(sizeof(struct spread_sketch)); - get_parameter_recommendation(expected_query_num, &pthis->depth, &pthis->width); - - pthis->buckets = calloc(pthis->depth * pthis->width, sizeof(struct bucket)); - pthis->scheme.new_fn = default_new_fn; - pthis->scheme.free_fn = default_free_fn; - pthis->scheme.merge_fn = default_merge_fn; - pthis->scheme.reset_fn = default_reset_fn; - pthis->scheme.copy_fn = default_copy_fn; - pthis->table = smart_ptr_table_new(); - pthis->table->scheme = pthis->scheme; - - return pthis; -} - -// return 0 if not added, return 1 if added -int spread_sketch_add(struct spread_sketch *ss, const char *key, size_t key_length, uint64_t item_hash, void *arg) { - // uint64_t hash_identifier = XXH3_64bits_withSeed(identifier, identifier_length, 171); - uint32_t level = (uint32_t)__builtin_clzll(item_hash) + 1; - // printf("spread_sketch_add key %s, level %u\n", key, level); - - // https://www.eecs.harvard.edu/~michaelm/postscripts/tr-02-05.pdf - // A technique from the hashing literature is to use two hash functions h1(x) and h2(x) to simulate additional hash functions of the form gi(x) = h1(x) + ih2(x) - // Assuming that the 128-bit xxhash function is perfect, we can view it as a combination of two 64-bit hash functions. - uint64_t hash_x_tmp = XXH3_64bits_withSeed(key, key_length, 171); - uint32_t hash_x1 = (uint32_t) (hash_x_tmp >> 32); - uint32_t hash_x2 = (uint32_t) hash_x_tmp; - - bool in_sketch = false; - for (int i = 0; i < ss->depth; i++) { - uint32_t hash_x = hash_x1 + i * hash_x2; - int bucket_idx = (hash_x % ss->width) + i * ss->width; - struct bucket *bucket = &ss->buckets[bucket_idx]; - - if (bucket->content != NULL && key_equal(bucket->content->key, bucket->content->key_len, key, key_length)) { - bucket->content->dying = false; - - if (bucket->level < level) { - bucket->level = level; - } - in_sketch = true; - } else { - uint32_t old_level = bucket->content == NULL ? 0: bucket->level; - - if (level > old_level) { - // printf("update key %s to %s, and level %u to %u, in bucket (r,w)=(%d,%u)\n", bucket->content == NULL ? "NULL": bucket->content->key, key, old_level, level, i, hash_x % ss->width); - const struct entry *content_old = bucket->content; - if (content_old != NULL) { - smart_ptr_table_release(ss->table, content_old->key, content_old->key_len); - } - struct entry *content_new = smart_ptr_table_get(ss->table, key, key_length, arg); - bucket->content = content_new; - bucket->level = level; - - in_sketch = true; - } - } - } - - return in_sketch ? 1 : 0; -} - -void spread_sketch_free(struct spread_sketch *ss) { - smart_ptr_table_free(ss->table); - free(ss->buckets); - free(ss); -} - -void spread_sketch_merge(struct spread_sketch *dst, const struct spread_sketch *src) -{ - assert(dst->depth == src->depth && dst->width == src->width); - - for (int i = 0; i < dst->depth * dst->width; i++) { - const struct bucket *bucket_src = &src->buckets[i]; - struct bucket *bucket_dst = &dst->buckets[i]; - - if (bucket_src->content == NULL || bucket_src->content->dying) { - continue; - } - if (bucket_dst->content == NULL) { - bucket_dst->content = smart_ptr_table_get(dst->table, bucket_src->content->key, bucket_src->content->key_len, NULL); - bucket_dst->level = bucket_src->level; - continue; - } - bucket_dst->content->dying = false; - - if (key_equal(bucket_src->content->key, bucket_src->content->key_len, bucket_dst->content->key, bucket_dst->content->key_len)) { - if (bucket_src->level > bucket_dst->level) { - bucket_dst->level = bucket_src->level; - } - } else { - if (bucket_src->level > bucket_dst->level) { - smart_ptr_table_release(dst->table, bucket_dst->content->key, bucket_dst->content->key_len); - bucket_dst->content = smart_ptr_table_get(dst->table, bucket_src->content->key, bucket_src->content->key_len, NULL); - bucket_dst->level = bucket_src->level; - } - } - } - - const struct spread_sketch_scheme *scheme = &dst->table->scheme; - - struct entry *content_dest, *content_src, *tmp; - HASH_ITER(hh, dst->table->entry, content_dest, tmp) { - HASH_FIND(hh, src->table->entry, content_dest->key, content_dest->key_len, content_src); - if (content_src == NULL || content_src->dying) { - continue; - } - - if (content_dest->exdata == NULL) { - content_dest->exdata = scheme->copy_fn(content_src->exdata); - } else { - scheme->merge_fn(content_dest->exdata, content_src->exdata); - } - } -} - -void *spread_sketch_get0_exdata(const struct spread_sketch *ss, const char *key, size_t key_len) { - struct entry *content; - HASH_FIND(hh, ss->table->entry, key, key_len, content); - if (content == NULL || content->dying) { - return NULL; - } - return content->exdata; -} - -void spread_sketch_reset(struct spread_sketch *ss) { - for (int i = 0; i < ss->depth * ss->width; i++) { - struct bucket *bucket = &ss->buckets[i]; - bucket->level = 0; - } - - struct entry *content, *tmp; - HASH_ITER(hh, ss->table->entry, content, tmp) { - ss->scheme.reset_fn(content->exdata); - content->dying = true; - } -} - -void spread_sketch_set_exdata_schema(struct spread_sketch *ss, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn) { - ss->scheme.new_fn = new_fn; - ss->scheme.free_fn = free_fn; - ss->scheme.merge_fn = merge_fn; - ss->scheme.reset_fn = reset_fn; - ss->scheme.copy_fn = copy_fn; - - ss->table->scheme = ss->scheme; -} - -int spread_sketch_get_count(const struct spread_sketch *ss) { - int cnt = 0; - struct entry *content, *tmp; - HASH_ITER(hh, ss->table->entry, content, tmp) { - if (!content->dying) { - cnt++; - } - } - - return cnt; -} - -size_t spread_sketch_list(const struct spread_sketch *ss, void **exdatas, size_t n_exdatas) { - size_t count = 0; - struct entry *content, *tmp; - HASH_ITER(hh, ss->table->entry, content, tmp) { - if (content->dying) { - continue; - } - if (count >= n_exdatas) { - break; - } - exdatas[count] = content->exdata; - count++; - } - return count; -} - -struct spread_sketch *spread_sketch_copy(const struct spread_sketch *src) { - struct spread_sketch *dst = malloc(sizeof(struct spread_sketch)); - memcpy(dst, src, sizeof(struct spread_sketch)); - - 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++) { - if (src->buckets[i].content == NULL || src->buckets[i].content->dying) { - continue; - } - dst->buckets[i].content = smart_ptr_table_get(dst->table, src->buckets[i].content->key, src->buckets[i].content->key_len, NULL); - dst->buckets[i].level = src->buckets[i].level; - if (dst->buckets[i].content->exdata == NULL) { - dst->buckets[i].content->exdata = src->scheme.copy_fn(src->buckets[i].content->exdata); - } - } - return dst; -} diff --git a/src/tags/spread_sketch.h b/src/tags/spread_sketch.h deleted file mode 100644 index 9717238..0000000 --- a/src/tags/spread_sketch.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -#include "exdata.h" - -#define DUMMY_ITEM_HASH (1ULL<<63) // level(left most zeros) = 0 - -struct spread_sketch; - -// spread sketch alway store values more than expected_query_num,expected_query_num is a hint to set spread sketch parameters properly -struct spread_sketch *spread_sketch_new(int expected_query_num); - -void spread_sketch_free(struct spread_sketch *ss); - -void spread_sketch_reset(struct spread_sketch *ss); - -int spread_sketch_add(struct spread_sketch *ss, const char *key, size_t key_length, uint64_t item_hash, void *arg); -void spread_sketch_set_exdata_schema(struct spread_sketch *ss, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn); - -void *spread_sketch_get0_exdata(const struct spread_sketch *ss, const char *key, size_t key_len); - -// get the number of cells in the heavy keeper -int spread_sketch_get_count(const struct spread_sketch *ss); - -size_t spread_sketch_list(const struct spread_sketch *ss, void **exdatas, size_t n_exdatas); - -void spread_sketch_merge(struct spread_sketch *dest, const struct spread_sketch *src); - -struct spread_sketch *spread_sketch_copy(const struct spread_sketch *src); - -// for test -// void spread_sketch_one_point_query(const struct spread_sketch *ss, const char *key, size_t key_len, int *level_out, void **exdata_out); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/src/tags/tag_map.c b/src/tags/tag_map.c deleted file mode 100644 index 6dad5e1..0000000 --- a/src/tags/tag_map.c +++ /dev/null @@ -1,230 +0,0 @@ -#include "tag_map.h" - -#include -#include -#include -#include - -#include "uthash.h" - -#include "fieldstat.h" -#include "exdata.h" - -struct tag_exdata_item { - char *key; - size_t key_len; - void *exdata; - bool dying; - UT_hash_handle hh; -}; - -struct hash_table { // todo: 文件改名字 - struct tag_exdata_item *tag_id_map; - int current_cell_num; - int max_cell_num; - - exdata_new_cb new_fn; - exdata_free_cb free_fn; - exdata_merge_cb merge_fn; - exdata_reset_cb reset_fn; - exdata_copy_cb copy_fn; -}; -static void *default_new_fn(void *arg) { - return NULL; -} - -static void default_free_fn(void *exdata) { - return; -} - -static void default_merge_fn(void *dest, void *src) { - return; -} - -static void default_reset_fn(void *exdata) { - return; -} - -static void *default_copy_fn(void *exdata) { - return exdata; -} - - -struct hash_table *hash_table_new(int max_query_num) { - struct hash_table *pthis = calloc(1, sizeof(struct hash_table)); - - pthis->max_cell_num = max_query_num; - - pthis->new_fn = default_new_fn; - pthis->free_fn = default_free_fn; - pthis->merge_fn = default_merge_fn; - pthis->reset_fn = default_reset_fn; - pthis->copy_fn = default_copy_fn; - return pthis; -} - -void hash_table_free(struct hash_table *pthis) { - struct tag_exdata_item *item, *tmp; - HASH_ITER(hh, pthis->tag_id_map, item, tmp) { - HASH_DEL(pthis->tag_id_map, item); - free(item->key); - pthis->free_fn(item->exdata); - free(item); - } - free(pthis); -} - -void hash_table_reset(struct hash_table *pthis) { - struct tag_exdata_item *node, *tmp; - HASH_ITER(hh, pthis->tag_id_map, node, tmp) { - if (!node->dying) { - node->dying = true; - pthis->reset_fn(node->exdata); - continue; - } - HASH_DEL(pthis->tag_id_map, node); - free(node->key); - pthis->free_fn(node->exdata); - free(node); - } - - pthis->current_cell_num = 0; -} - -static char *my_keydup(const char *key, size_t key_len) { - char *ret = calloc(1, key_len + 1); - memcpy(ret, key, key_len); - return ret; -} - -int hash_table_add(struct hash_table *pthis, const char *key, size_t key_len, void *arg) { - struct tag_exdata_item *item; - HASH_FIND(hh, pthis->tag_id_map, key, key_len, item); - if (item != NULL && !item->dying) { - return 1; - } - - if (pthis->current_cell_num >= pthis->max_cell_num) { - return 0; - } - - if (item != NULL) { - assert(item->dying); - item->dying = false; - pthis->current_cell_num++; - return 1; - } - - item = calloc(1, sizeof(struct tag_exdata_item)); - item->key = my_keydup(key, key_len); - item->key_len = key_len; - item->exdata = pthis->new_fn(arg); - item->dying = false; - HASH_ADD_KEYPTR(hh, pthis->tag_id_map, item->key, key_len, item); - - pthis->current_cell_num++; - return 1; -} - -void hash_table_set_exdata_schema(struct hash_table *pthis, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn) { - pthis->new_fn = new_fn; - pthis->free_fn = free_fn; - pthis->merge_fn = merge_fn; - pthis->reset_fn = reset_fn; - pthis->copy_fn = copy_fn; -} - -void *hash_table_get0_exdata(struct hash_table *pthis, const char *key, size_t key_len) { - struct tag_exdata_item *item; - HASH_FIND(hh, pthis->tag_id_map, key, key_len, item); - if (item == NULL || item->dying) { - return NULL; - } - return item->exdata; -} - -int hash_table_get_count(const struct hash_table *pthis) { - return pthis->current_cell_num; -} - -size_t hash_table_list(const struct hash_table *pthis, void **exdatas, size_t n_exdatas) { - size_t actual_len = pthis->current_cell_num; - if (actual_len == 0) { - return 0; - } - - struct tag_exdata_item *item, *tmp; - size_t i = 0; - HASH_ITER(hh, pthis->tag_id_map, item, tmp) { - if (item->dying) { - continue; - } - if (i >= n_exdatas) { - break; - } - exdatas[i] = item->exdata; - i++; - } - return actual_len < n_exdatas ? actual_len : n_exdatas; -} - -int hash_table_merge(struct hash_table *dest, struct hash_table *src) { - struct tag_exdata_item *item_src, *tmp; - struct tag_exdata_item *item_dst; - HASH_ITER(hh, src->tag_id_map, item_src, tmp) { - if (item_src->dying) { - continue; - } - - HASH_FIND(hh, dest->tag_id_map, item_src->key, item_src->key_len, item_dst); - if (item_dst != NULL && !item_dst->dying) { - dest->merge_fn(item_dst->exdata, item_src->exdata); - continue; - } - - if (dest->current_cell_num >= dest->max_cell_num) { - continue; // cannot add more cells - } - - if (item_dst == NULL) { - item_dst = calloc(1, sizeof(struct tag_exdata_item)); - item_dst->key = my_keydup(item_src->key, item_src->key_len); - item_dst->key_len = item_src->key_len; - item_dst->dying = false; - item_dst->exdata = dest->copy_fn(item_src->exdata); - HASH_ADD_KEYPTR(hh, dest->tag_id_map, item_dst->key, item_dst->key_len, item_dst); - dest->current_cell_num++; - } else { - assert(item_dst->dying); - item_dst->dying = false; - dest->merge_fn(item_dst->exdata, item_src->exdata); //item_dst->exdata should be empty, but just merge to it. - dest->current_cell_num++; - } - } - return 0; -} - -struct hash_table *hash_table_copy(const struct hash_table *src) { - struct hash_table *pthis = calloc(1, sizeof(struct hash_table)); - pthis->max_cell_num = src->max_cell_num; - pthis->current_cell_num = src->current_cell_num; - pthis->new_fn = src->new_fn; - pthis->free_fn = src->free_fn; - pthis->merge_fn = src->merge_fn; - pthis->reset_fn = src->reset_fn; - pthis->copy_fn = src->copy_fn; - - struct tag_exdata_item *item, *tmp; - HASH_ITER(hh, src->tag_id_map, item, tmp) { - if (item->dying) { - continue; - } - struct tag_exdata_item *new_item = calloc(1, sizeof(struct tag_exdata_item)); - new_item->key = my_keydup(item->key, item->key_len); - new_item->key_len = item->key_len; - new_item->exdata = pthis->copy_fn(item->exdata); - new_item->dying = false; - HASH_ADD_KEYPTR(hh, pthis->tag_id_map, new_item->key, new_item->key_len, new_item); - } - return pthis; -} diff --git a/src/tags/tag_map.h b/src/tags/tag_map.h deleted file mode 100644 index 59fc8e8..0000000 --- a/src/tags/tag_map.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -#include "exdata.h" - -struct hash_table; - -struct hash_table *hash_table_new(int max_query_num); -void hash_table_set_exdata_schema(struct hash_table *pthis, exdata_new_cb new_fn, exdata_free_cb free_fn, exdata_merge_cb merge_fn, exdata_reset_cb reset_fn, exdata_copy_cb copy_fn); -void hash_table_free(struct hash_table *pthis); -void hash_table_reset(struct hash_table *pthis); -int hash_table_merge(struct hash_table *dest, struct hash_table *src); -struct hash_table *hash_table_copy(const struct hash_table *src); - -// int hash_table_add(struct hash_table *pthis, const char *key, size_t key_len, int count, void *arg); -int hash_table_add(struct hash_table *pthis, const char *key, size_t key_len, void *arg); - -// void *hash_table_get0_exdata(struct hash_table *pthis, const char *key, size_t key_len); -void *hash_table_get0_exdata(struct hash_table *pthis, const char *key, size_t key_len); -int hash_table_get_count(const struct hash_table *pthis); -size_t hash_table_list(const struct hash_table *pthis, void **exdatas, size_t n_exdatas); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ced6420..a6c1403 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,7 +16,7 @@ set(DEBUG_FLAGS "-O3") include_directories(${PROJECT_SOURCE_DIR}/test) include_directories(${PROJECT_SOURCE_DIR}/test/deps) include_directories(${PROJECT_SOURCE_DIR}/src) -include_directories(${PROJECT_SOURCE_DIR}/src/tags) +include_directories(${PROJECT_SOURCE_DIR}/src/cells) include_directories(${PROJECT_SOURCE_DIR}/src/metrics) include_directories(${PROJECT_SOURCE_DIR}/include/fieldstat) diff --git a/test/profiling/CMakeLists.txt b/test/profiling/CMakeLists.txt index 5c8e99c..f06242f 100644 --- a/test/profiling/CMakeLists.txt +++ b/test/profiling/CMakeLists.txt @@ -16,7 +16,7 @@ include_directories(${PROJECT_SOURCE_DIR}/src/utils) file(GLOB SRC "${PROJECT_SOURCE_DIR}/src/*.c" "${PROJECT_SOURCE_DIR}/src/metrics/*.c" - "${PROJECT_SOURCE_DIR}/src/tags/*.c" + "${PROJECT_SOURCE_DIR}/src/cells/*.c" "${PROJECT_SOURCE_DIR}/src/exporter/*.c" "${PROJECT_SOURCE_DIR}/src/utils/*.c" "${PROJECT_SOURCE_DIR}/vendors/cjson/*.c" diff --git a/test/profiling/main.c b/test/profiling/main.c index 5838f20..3af2b1a 100644 --- a/test/profiling/main.c +++ b/test/profiling/main.c @@ -11,23 +11,23 @@ // #define ADD_OPER_NUM 1 #define MAX_STRING_KEY_LEN 10 -const struct field TEST_TAG_INT = {"INT key_", TAG_INTEGER, {.value_longlong = 100}}; +const struct field TEST_TAG_INT = {"INT key_", FIELD_VALUE_INTEGER, {.value_longlong = 100}}; int main () { printf("Start profiling...\n"); clock_t start, end; // struct field TAG[4] = { - // {"INT key_", TAG_INTEGER, {.value_longlong = 100}}, - // {"STRING key_", TAG_CSTRING, {.value_str = "10012312312312"}}, - // {"STRING key_", TAG_CSTRING, {.value_str = "100adsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"}}, - // {"FLOAT key_", TAG_INTEGER, {.value_double = 100.0}}, + // {"INT key_", FIELD_VALUE_INTEGER, {.value_longlong = 100}}, + // {"STRING key_", FIELD_VALUE_CSTRING, {.value_str = "10012312312312"}}, + // {"STRING key_", FIELD_VALUE_CSTRING, {.value_str = "100adsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"}}, + // {"FLOAT key_", FIELD_VALUE_INTEGER, {.value_double = 100.0}}, // }; struct field TAG[4] = { - {"object_id", TAG_INTEGER, {.value_longlong = 20}}, - {"item_id", TAG_INTEGER, {.value_longlong = 16916397}}, - {"chart_id", TAG_INTEGER, {.value_longlong = 1}}, - {"version", TAG_INTEGER, {.value_longlong = 1}}, + {"object_id", FIELD_VALUE_INTEGER, {.value_longlong = 20}}, + {"item_id", FIELD_VALUE_INTEGER, {.value_longlong = 16916397}}, + {"chart_id", FIELD_VALUE_INTEGER, {.value_longlong = 1}}, + {"version", FIELD_VALUE_INTEGER, {.value_longlong = 1}}, }; struct fieldstat *instance = fieldstat_new(); diff --git a/test/test_easy_fs.cpp b/test/test_easy_fs.cpp index e723828..790f0fd 100644 --- a/test/test_easy_fs.cpp +++ b/test/test_easy_fs.cpp @@ -123,7 +123,7 @@ TEST(test_easy_fieldstat, output_to_file) cJSON_Delete(root); // 4th interval: new data, output again - fieldstat_easy_counter_incrby(fse, 0, counter_id, &TEST_TAG_DOUBLE, 1, 10086); + fieldstat_easy_counter_incrby(fse, 0, counter_id, &TEST_FIELD_VALUE_DOUBLE, 1, 10086); sleep(2); printf("4th interval\n"); root = read_file(); @@ -183,7 +183,7 @@ TEST(test_easy_fieldstat, output_interval_ok) struct fieldstat_easy *fse = fieldstat_easy_new(10, NULL, NULL, 0); fieldstat_easy_register_histogram(fse, "metric histogram", 1, 10000, 3); // a pretty time consuming metric fieldstat_easy_histogram_record(fse, 0, 0, &TEST_TAG_INT, 1, 1); - fieldstat_easy_histogram_record(fse, 0, 0, &TEST_TAG_DOUBLE, 1, 10); + fieldstat_easy_histogram_record(fse, 0, 0, &TEST_FIELD_VALUE_DOUBLE, 1, 10); fieldstat_easy_histogram_record(fse, 0, 0, &TEST_TAG_STRING, 1, 110); fieldstat_easy_enable_auto_output(fse, FILENAME, 1); @@ -200,7 +200,7 @@ TEST(test_easy_fieldstat, ensure_data_racing_of_two_output_and_of_incyby) struct field global_tags[1]; struct field tmptag; tmptag.key = "app id"; - tmptag.type = TAG_INTEGER; + tmptag.type = FIELD_VALUE_INTEGER; tmptag.value_longlong = 1; global_tags[0] = tmptag; diff --git a/test/test_empty_tags.cpp b/test/test_empty_tags.cpp index 1d1484a..967f8c0 100644 --- a/test/test_empty_tags.cpp +++ b/test/test_empty_tags.cpp @@ -97,7 +97,7 @@ TEST(test_empty_tag, merge_topk) TEST(test_empty_tag, merge_spreadsketch) { struct fieldstat *instance_src = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance_src, NULL, 0, SAMPLING_MODE_SPREADSKETCH, 1); + int cube_id = fieldstat_create_cube(instance_src, NULL, 0, SAMPLING_MODE_TOP_CARDINALITY, 1); int metric_id = fieldstat_register_hll(instance_src, cube_id, "metric", 4); fieldstat_hll_add(instance_src, cube_id, metric_id, NULL, 0, "1", 1); struct fieldstat *instance_dst = fieldstat_new(); diff --git a/test/test_exporter_json.cpp b/test/test_exporter_json.cpp index 54ea3df..8e96e04 100644 --- a/test/test_exporter_json.cpp +++ b/test/test_exporter_json.cpp @@ -23,22 +23,22 @@ struct hdr_histogram *g_histogram_standard; #define TEST_TOPK_STANDARD_K 5 #define TEST_METRIC_NUM 2 -const struct field TEST_TAG_GLOBAL1 = {"test_tag_global 1", .type = TAG_INTEGER, {.value_longlong = 1}}; -const struct field TEST_TAG_GLOBAL2 = {"test_tag_global 2", .type = TAG_DOUBLE, {.value_double = 2.2}}; -const struct field TEST_TAG_GLOBAL3 = {"test_tag_global 3", .type = TAG_CSTRING, {.value_str = "string3"}}; +const struct field TEST_TAG_GLOBAL1 = {"test_tag_global 1", .type = FIELD_VALUE_INTEGER, {.value_longlong = 1}}; +const struct field TEST_TAG_GLOBAL2 = {"test_tag_global 2", .type = FIELD_VALUE_DOUBLE, {.value_double = 2.2}}; +const struct field TEST_TAG_GLOBAL3 = {"test_tag_global 3", .type = FIELD_VALUE_CSTRING, {.value_str = "string3"}}; const struct field TEST_TAG_GLOBAL[3] = {TEST_TAG_GLOBAL1, TEST_TAG_GLOBAL2, TEST_TAG_GLOBAL3}; -const struct field TEST_TAG_SHARED1_1 = {"test_tag_shared 1", .type = TAG_INTEGER, {.value_longlong = 3}}; -const struct field TEST_TAG_SHARED1_2 = {"test_tag_shared 2", .type = TAG_DOUBLE, {.value_double = 0.2}}; -const struct field TEST_TAG_SHARED1_3 = {"test_tag_shared 3", .type = TAG_CSTRING, {.value_str = "1string"}}; +const struct field TEST_TAG_SHARED1_1 = {"test_tag_shared 1", .type = FIELD_VALUE_INTEGER, {.value_longlong = 3}}; +const struct field TEST_TAG_SHARED1_2 = {"test_tag_shared 2", .type = FIELD_VALUE_DOUBLE, {.value_double = 0.2}}; +const struct field TEST_TAG_SHARED1_3 = {"test_tag_shared 3", .type = FIELD_VALUE_CSTRING, {.value_str = "1string"}}; const struct field TEST_TAG_SHARED1[3] = {TEST_TAG_SHARED1_1, TEST_TAG_SHARED1_2, TEST_TAG_SHARED1_3}; -const struct field TEST_TAG_SHARED2_1 = {"test_tag_shared 11", .type = TAG_INTEGER, {.value_longlong = 4}}; -const struct field TEST_TAG_SHARED2_2 = {"test_tag_shared 22", .type = TAG_DOUBLE, {.value_double = 0.3}}; -const struct field TEST_TAG_SHARED2_3 = {"test_tag_shared 33", .type = TAG_CSTRING, {.value_str = "2string"}}; +const struct field TEST_TAG_SHARED2_1 = {"test_tag_shared 11", .type = FIELD_VALUE_INTEGER, {.value_longlong = 4}}; +const struct field TEST_TAG_SHARED2_2 = {"test_tag_shared 22", .type = FIELD_VALUE_DOUBLE, {.value_double = 0.3}}; +const struct field TEST_TAG_SHARED2_3 = {"test_tag_shared 33", .type = FIELD_VALUE_CSTRING, {.value_str = "2string"}}; const struct field TEST_TAG_SHARED2[3] = {TEST_TAG_SHARED2_1, TEST_TAG_SHARED2_2, TEST_TAG_SHARED2_3}; -const struct field TEST_TAG_SHARED3_1 = {"test_tag_shared 3", .type = TAG_INTEGER, {.value_longlong = 5}}; +const struct field TEST_TAG_SHARED3_1 = {"test_tag_shared 3", .type = FIELD_VALUE_INTEGER, {.value_longlong = 5}}; const struct field TEST_TAG_SHARED3[1] = {TEST_TAG_SHARED3_1}; void test_check_if_tag_list_is_in_json(cJSON *tag_obj, const Fieldstat_tag_list_wrapper *benchmark) @@ -49,7 +49,7 @@ void test_check_if_tag_list_is_in_json(cJSON *tag_obj, const Fieldstat_tag_list_ if (tag_val->type == cJSON_String) { EXPECT_STREQ(tag_val->valuestring, benchmark->get_tag()[tag_id].value_str); } else { - if (benchmark->get_tag()[tag_id].type == TAG_INTEGER) { + if (benchmark->get_tag()[tag_id].type == FIELD_VALUE_INTEGER) { EXPECT_EQ(tag_val->valueint, benchmark->get_tag()[tag_id].value_longlong); } else { EXPECT_NEAR(tag_val->valuedouble, benchmark->get_tag()[tag_id].value_double, 0.0001); @@ -189,7 +189,7 @@ TEST(export_test, cjson_export_with_fixed_tag_and_many_metrics_on_one_cube_of_co int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, tag_list_num); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); int id_gauge = fieldstat_register_hll(instance, cube_id, "gauge", g_hll_standard->cfg.precision); - int id_histogram = fieldstat_register_hist(instance, cube_id, "histogram", + int id_histogram = fieldstat_register_histogram(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); Fieldstat_tag_list_wrapper *fields[tag_list_num]; @@ -202,7 +202,7 @@ TEST(export_test, cjson_export_with_fixed_tag_and_many_metrics_on_one_cube_of_co fieldstat_counter_incrby(instance, cube_id, id_counter, tag_tmp, tag_count, 1); for (size_t i = 0; i < OPER_NUM; i++){ fieldstat_hll_add(instance, cube_id, id_gauge, tag_tmp, tag_count, g_hll_standard_oper[i].c_str(), g_hll_standard_oper[i].length()); - fieldstat_hist_record(instance, cube_id, id_histogram, tag_tmp, tag_count, g_histogram_standard_oper[i]); + fieldstat_histogram_record(instance, cube_id, id_histogram, tag_tmp, tag_count, g_histogram_standard_oper[i]); } } @@ -289,7 +289,7 @@ extern "C" { TEST(export_test, cjson_export_on_one_cube_of_spreadsketch_sampling) { int K = 10; struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, K); + int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, K); int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 7); int metric_count = fieldstat_register_counter(instance, cube_id, "oper cnt"); SpreadSketchZipfGenerator flow_generator(1.0, K * 10); @@ -349,7 +349,7 @@ TEST(export_test, only_registered_but_not_added_export_null_with_global_tag) int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_register_hll(instance, cube_id, "gauge", g_hll_standard->cfg.precision); - fieldstat_register_hist(instance, cube_id, "histogram", + fieldstat_register_histogram(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); // add global field @@ -367,7 +367,7 @@ TEST(export_test, skip_two_empty_cube_and_export_last_one_with_global_tag) int cube_id_3 = fieldstat_create_cube(instance, TEST_TAG_SHARED3, 1, SAMPLING_MODE_COMPREHENSIVE, 3); (void)fieldstat_register_counter(instance, cube_id_3, "counter"); (void)fieldstat_register_hll(instance, cube_id_3, "gauge", g_hll_standard->cfg.precision); - int id_histogram = fieldstat_register_hist(instance, cube_id_3, "histogram", + int id_histogram = fieldstat_register_histogram(instance, cube_id_3, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); const int tag_num = 1; @@ -375,7 +375,7 @@ TEST(export_test, skip_two_empty_cube_and_export_last_one_with_global_tag) fill_random_tag(fields, tag_num); const Fieldstat_tag_list_wrapper *the_tag = fields[0]; for (size_t i = 0; i < OPER_NUM; i++){ - fieldstat_hist_record(instance, cube_id_3, id_histogram, the_tag->get_tag(), the_tag->get_tag_count(), g_histogram_standard_oper[i]); + fieldstat_histogram_record(instance, cube_id_3, id_histogram, the_tag->get_tag(), the_tag->get_tag_count(), g_histogram_standard_oper[i]); } // export test @@ -530,10 +530,10 @@ TEST(export_test, enable_delta_and_export_twice_with_new_metric_and_omit_histogr struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); - int id_histogram = fieldstat_register_hist(instance, cube_id, "histogram", + int id_histogram = fieldstat_register_histogram(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); fieldstat_counter_incrby(instance, cube_id, id_counter, &TEST_TAG_INT, 1, 1); - fieldstat_hist_record(instance, cube_id, id_histogram, &TEST_TAG_INT, 1, 123); + fieldstat_histogram_record(instance, cube_id, id_histogram, &TEST_TAG_INT, 1, 123); // export test struct fieldstat_json_exporter *fieldstat_json_exporter = fieldstat_json_exporter_new(); @@ -612,10 +612,10 @@ TEST(export_test, enable_delta_and_export_three_times_skipping_cube_with_no_coun struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); - int id_histogram = fieldstat_register_hist(instance, cube_id, "histogram", + int id_histogram = fieldstat_register_histogram(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); fieldstat_counter_incrby(instance, cube_id, id_counter, &TEST_TAG_INT, 1, 1); - fieldstat_hist_record(instance, cube_id, id_histogram, &TEST_TAG_STRING, 1, 123); + fieldstat_histogram_record(instance, cube_id, id_histogram, &TEST_TAG_STRING, 1, 123); /* -------------------------- export test, 1st time ------------------------- */ struct fieldstat_json_exporter *fieldstat_json_exporter = fieldstat_json_exporter_new(); @@ -671,7 +671,7 @@ TEST(export_test, enable_delta_and_export_three_times_skipping_cube_with_no_coun /* -------------------------------- 3rd time -------------------------------- */ // add some new recs fieldstat_counter_incrby(instance, cube_id, id_counter, &TEST_TAG_INT, 1, 10); - fieldstat_hist_record(instance, cube_id, id_histogram, &TEST_TAG_STRING, 1, 1234); + fieldstat_histogram_record(instance, cube_id, id_histogram, &TEST_TAG_STRING, 1, 1234); json_string = fieldstat_json_exporter_export(fieldstat_json_exporter, instance, &TEST_TIMEVAL); root_arr = cJSON_Parse(json_string); free(json_string); @@ -727,7 +727,7 @@ TEST(export_test, enable_delta_and_export_instance_with_many_cells_with_global_t int cube_id2 = fieldstat_create_cube(instance, TEST_TAG_SHARED3, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int id_counter2 = fieldstat_register_counter(instance, cube_id2, "counter"); fieldstat_counter_incrby(instance, cube_id2, id_counter2, &TEST_TAG_INT, 1, 21); - fieldstat_counter_incrby(instance, cube_id2, id_counter2, &TEST_TAG_DOUBLE, 1, 22); + fieldstat_counter_incrby(instance, cube_id2, id_counter2, &TEST_FIELD_VALUE_DOUBLE, 1, 22); // export test struct fieldstat_json_exporter *fieldstat_json_exporter = fieldstat_json_exporter_new(); @@ -757,14 +757,14 @@ TEST(export_test, enable_delta_and_export_instance_with_many_cells_with_global_t test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 21, 21, root); /* ------------------------------ cube 1 cell 1 ----------------------------- */ root = cJSON_GetArrayItem(root_arr, 3); - tmp_tag_cell = (struct field_list){(struct field *)&TEST_TAG_DOUBLE, 1}; + tmp_tag_cell = (struct field_list){(struct field *)&TEST_FIELD_VALUE_DOUBLE, 1}; test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 22, 22, root); // new turn fieldstat_counter_incrby(instance, cube_id1, id_counter1, &TEST_TAG_INT, 1, 100); fieldstat_counter_incrby(instance, cube_id1, id_counter1, &TEST_TAG_STRING, 1, 200); fieldstat_counter_incrby(instance, cube_id2, id_counter1, &TEST_TAG_INT, 1, 300); - fieldstat_counter_incrby(instance, cube_id2, id_counter1, &TEST_TAG_DOUBLE, 1, 400); + fieldstat_counter_incrby(instance, cube_id2, id_counter1, &TEST_FIELD_VALUE_DOUBLE, 1, 400); cJSON_Delete(root_arr); @@ -793,7 +793,7 @@ TEST(export_test, enable_delta_and_export_instance_with_many_cells_with_global_t test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 321, 300, root); /* ------------------------------ cube 1 cell 1 ----------------------------- */ root = cJSON_GetArrayItem(root_arr, 3); - tmp_tag_cell = (struct field_list){(struct field *)&TEST_TAG_DOUBLE, 1}; + tmp_tag_cell = (struct field_list){(struct field *)&TEST_FIELD_VALUE_DOUBLE, 1}; test_check_delta_for_one_json(&tmp_tag_cell, &tmp_tag_shared, 422, 400, root); cJSON_Delete(root_arr); @@ -883,8 +883,8 @@ TEST(export_test, delta_with_two_instance_same_config) int cube_id = fieldstat_create_cube(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, 0, id_counter, &TEST_TAG_INT, 1, 123); - int id_hist = fieldstat_register_hist(instance, cube_id, "histogram", 1, 1000, 3); - fieldstat_hist_record(instance, cube_id, id_hist, &TEST_TAG_INT, 1, 5); + int id_hist = fieldstat_register_histogram(instance, cube_id, "histogram", 1, 1000, 3); + fieldstat_histogram_record(instance, cube_id, id_hist, &TEST_TAG_INT, 1, 5); struct fieldstat *acc = fieldstat_new(); fieldstat_merge(acc, instance); @@ -923,8 +923,8 @@ TEST(export_test, delta_with_two_instance_one_empty) int cube_id = fieldstat_create_cube(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, 0, id_counter, &TEST_TAG_INT, 1, 123); - int id_hist = fieldstat_register_hist(instance, cube_id, "histogram", 1, 1000, 3); - fieldstat_hist_record(instance, 0, id_hist, &TEST_TAG_INT, 1, 5); + int id_hist = fieldstat_register_histogram(instance, cube_id, "histogram", 1, 1000, 3); + fieldstat_histogram_record(instance, 0, id_hist, &TEST_TAG_INT, 1, 5); struct fieldstat *delta = fieldstat_fork(instance); @@ -964,7 +964,7 @@ TEST(export_test, delta_with_two_instance_different_cell) fieldstat_counter_incrby(instance, 0, id_counter, &TEST_TAG_INT, 1, 123); struct fieldstat *delta = fieldstat_fork(instance); - fieldstat_counter_incrby(delta, 0, id_counter, &TEST_TAG_DOUBLE, 1, 1); + fieldstat_counter_incrby(delta, 0, id_counter, &TEST_FIELD_VALUE_DOUBLE, 1, 1); fieldstat_merge(instance, delta); // export test diff --git a/test/test_fuzz_test.cpp b/test/test_fuzz_test.cpp index a97f416..3b91f68 100644 --- a/test/test_fuzz_test.cpp +++ b/test/test_fuzz_test.cpp @@ -347,7 +347,7 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ // init cube for (int i = 0; i < CUBE_NUM; i++) { shared_tags[i] = new Fieldstat_tag_list_wrapper("shared_tag", i); - int cube_id = fieldstat_create_cube(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_SPREADSKETCH, CELL_MAX); + int cube_id = fieldstat_create_cube(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_TOP_CARDINALITY, CELL_MAX); EXPECT_EQ(cube_id, i); fieldstat_register_hll(master, cube_id, "hll", 6); } @@ -379,7 +379,7 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ delete shared_tags[cube_id_to_change]; shared_tags[cube_id_to_change] = new_tag; fieldstat_destroy_cube(master, cube_id_to_change); - int cube_id_new = fieldstat_create_cube(master, new_tag->get_tag(), new_tag->get_tag_count(), SAMPLING_MODE_SPREADSKETCH, CELL_MAX); + int cube_id_new = fieldstat_create_cube(master, new_tag->get_tag(), new_tag->get_tag_count(), SAMPLING_MODE_TOP_CARDINALITY, CELL_MAX); fieldstat_register_hll(master, cube_id_new, "hll", 6); EXPECT_EQ(cube_id_new, cube_id_to_change); // should new the cube in the hole leaved by the destroyed cube // calibrate @@ -514,7 +514,7 @@ TEST(Fuzz_test, simple_one_for_perf) // init cube for (int i = 0; i < CUBE_NUM; i++) { shared_tags[i] = new Fieldstat_tag_list_wrapper("shared_tag", i); - int cube_id = fieldstat_create_cube(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_SPREADSKETCH, CELL_MAX); + int cube_id = fieldstat_create_cube(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_TOP_CARDINALITY, CELL_MAX); EXPECT_EQ(cube_id, i); fieldstat_register_counter(master, cube_id, "topk"); } diff --git a/test/test_merge.cpp b/test/test_merge.cpp index 80bca32..2fe730e 100644 --- a/test/test_merge.cpp +++ b/test/test_merge.cpp @@ -49,7 +49,7 @@ double merge_test_fieldstat_hll_get(const struct fieldstat *instance, int cube_i TEST(unit_test_merge, cube_shared_tag_mapping_with_new_cube) { struct fieldstat *instance = fieldstat_new(); - (void)fieldstat_create_cube(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + (void)fieldstat_create_cube(instance, &TEST_FIELD_VALUE_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int cube_id2 = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_counter(instance,cube_id2,"metric in cube 2"); fieldstat_counter_incrby(instance, cube_id2, metric_id, &TEST_TAG_STRING, 1, 1); @@ -168,7 +168,7 @@ TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_a fieldstat_reset(instance); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 2); // 2nd cell - fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, 3); // 3rd cell, exceeding the limit 2 + fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_FIELD_VALUE_DOUBLE, 1, 3); // 3rd cell, exceeding the limit 2 fieldstat_merge(instance_dest, instance); @@ -197,7 +197,7 @@ TEST(unit_test_merge, new_too_many_cells_on_multiple_metric_given_source_cube_re int metric_id3 = fieldstat_register_counter(instance, cube_id, "metric name3"); fieldstat_counter_incrby(instance, cube_id, metric_id3, &TEST_TAG_INT, 1, 2); // 2nd cell on metric name3, this is a metric dest dont have - fieldstat_counter_incrby(instance, cube_id, metric_id2, &TEST_TAG_DOUBLE, 1, 3); // 3nd cell on metric name2 + fieldstat_counter_incrby(instance, cube_id, metric_id2, &TEST_FIELD_VALUE_DOUBLE, 1, 3); // 3nd cell on metric name2 fieldstat_merge(instance_dest, instance); int *metric_ids = NULL; @@ -315,7 +315,7 @@ TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_a fieldstat_reset(instance); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 2); // 2nd cell - fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, 3); // 3rd cell,bigger than the others, so keep it + fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_FIELD_VALUE_DOUBLE, 1, 3); // 3rd cell,bigger than the others, so keep it fieldstat_merge(instance_dest, instance); @@ -494,7 +494,7 @@ TEST(unit_test_merge, primary_metric_id_different) TEST(unit_test_merge, new_cube_and_metric_to_empty_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_SPREADSKETCH, 10); + fieldstat_create_cube(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_TOP_CARDINALITY, 10); fieldstat_register_hll(instance, 0, "metric", 6); struct fieldstat *instance_dest = fieldstat_new(); @@ -513,7 +513,7 @@ TEST(unit_test_merge, new_cube_and_metric_to_empty_spreadsketch) { TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 10); + int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 10); int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 6); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -545,7 +545,7 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_spreadsketch) { TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 10); + int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 10); int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 6); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, "1", 1); struct fieldstat *instance_dest = fieldstat_new(); @@ -569,7 +569,7 @@ TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_spreadsket TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_and_get_different_cube_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 2); + int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 2); int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 6); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, "1", 1); struct fieldstat *instance_dest = fieldstat_new(); @@ -578,9 +578,9 @@ TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_a fieldstat_reset(instance); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_INT, 1, "21", 2); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_INT, 1, "22", 2); - fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, "31", 2); - fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, "32", 2); - fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, "33", 2); + fieldstat_hll_add(instance, cube_id, metric_id, &TEST_FIELD_VALUE_DOUBLE, 1, "31", 2); + fieldstat_hll_add(instance, cube_id, metric_id, &TEST_FIELD_VALUE_DOUBLE, 1, "32", 2); + fieldstat_hll_add(instance, cube_id, metric_id, &TEST_FIELD_VALUE_DOUBLE, 1, "33", 2); fieldstat_merge(instance_dest, instance); struct field_list *tag_list = NULL; @@ -589,7 +589,7 @@ TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_a EXPECT_EQ(n_cell, 2); EXPECT_NEAR(merge_test_fieldstat_hll_get(instance_dest, 0, 0, &tag_list[0]), 3, 0.3); EXPECT_NEAR(merge_test_fieldstat_hll_get(instance_dest, 0, 0, &tag_list[1]), 2, 0.3); - EXPECT_STREQ(tag_list[0].field[0].key, TEST_TAG_DOUBLE.key); + EXPECT_STREQ(tag_list[0].field[0].key, TEST_FIELD_VALUE_DOUBLE.key); EXPECT_STREQ(tag_list[1].field[0].key, TEST_TAG_INT.key); fieldstat_free(instance); @@ -601,7 +601,7 @@ TEST(unit_test_merge, gen_dest_full_all_src_inserted_given_src_flows_larger_spre int K = 100; SpreadSketchZipfGenerator flow_generator(1.0, K); // exactly the number of cells, so there will be almost all(in case of hash collision happen) cells added successfully struct fieldstat *instance_src = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance_src, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, K); + int cube_id = fieldstat_create_cube(instance_src, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, K); int metric_id = fieldstat_register_hll(instance_src, cube_id, "metric", 6); struct fieldstat *instance_dest = fieldstat_fork(instance_src); const char dest_key[] = "key of dest"; @@ -659,7 +659,7 @@ TEST(unit_test_merge, merge_accuracy_test_gen_dest_full_some_inserted_and_some_m int K = 10; SpreadSketchZipfGenerator flow_generator(1.0, K * 10); struct fieldstat *instance_src = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance_src, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, K); + int cube_id = fieldstat_create_cube(instance_src, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, K); int metric_id = fieldstat_register_hll(instance_src, cube_id, "metric", 6); struct fieldstat *instance_dest = fieldstat_fork(instance_src); diff --git a/test/test_metric_histogram.cpp b/test/test_metric_histogram.cpp index 84244bf..3a28aa3 100644 --- a/test/test_metric_histogram.cpp +++ b/test/test_metric_histogram.cpp @@ -12,7 +12,7 @@ struct fieldstat *test_init_standard_instance_one_cube_one_metric_one_cell_hdr() int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, 0); - int metric_id = fieldstat_register_hist(instance, cube_id, "czz_test hdr metric", 1, 600000, 3); + int metric_id = fieldstat_register_histogram(instance, cube_id, "czz_test hdr metric", 1, 600000, 3); EXPECT_EQ(metric_id, 0); return instance; @@ -52,13 +52,13 @@ TEST(metric_test_histogram, simple_register_and_query) { struct fieldstat *instance = test_init_standard_instance_one_cube_one_metric_one_cell_hdr(); - fieldstat_hist_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); - fieldstat_hist_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); - fieldstat_hist_record(instance, 0, 0, &TEST_TAG_STRING, 1, 123); + fieldstat_histogram_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); + fieldstat_histogram_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); + fieldstat_histogram_record(instance, 0, 0, &TEST_TAG_STRING, 1, 123); test_assert_standard_instance(instance); - EXPECT_EQ(fieldstat_hist_value_at_percentile(instance, 0, &TEST_TAG_LIST_STRING, 0, 50.0), 1234); - EXPECT_EQ(fieldstat_hist_count_le_value(instance, 0, &TEST_TAG_LIST_STRING, 0, 1000), 1); + EXPECT_EQ(fieldstat_histogram_value_at_percentile(instance, 0, &TEST_TAG_LIST_STRING, 0, 50.0), 1234); + EXPECT_EQ(fieldstat_histogram_count_le_value(instance, 0, &TEST_TAG_LIST_STRING, 0, 1000), 1); fieldstat_free(instance); } @@ -66,9 +66,9 @@ TEST(metric_test_histogram, simple_register_and_query) TEST(metric_test_histogram, merge) { struct fieldstat *instance = test_init_standard_instance_one_cube_one_metric_one_cell_hdr(); - fieldstat_hist_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); - fieldstat_hist_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); - fieldstat_hist_record(instance, 0, 0, &TEST_TAG_STRING, 1, 123); + fieldstat_histogram_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); + fieldstat_histogram_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); + fieldstat_histogram_record(instance, 0, 0, &TEST_TAG_STRING, 1, 123); struct fieldstat *instance_total = fieldstat_new(); fieldstat_merge(instance_total, instance); @@ -76,8 +76,8 @@ TEST(metric_test_histogram, merge) // query test_assert_standard_instance(instance_total); - EXPECT_EQ(fieldstat_hist_value_at_percentile(instance_total, 0, &TEST_TAG_LIST_STRING, 0, 50.0), 1234); - EXPECT_EQ(fieldstat_hist_count_le_value(instance, 0, &TEST_TAG_LIST_STRING, 0, 1000), 1); + EXPECT_EQ(fieldstat_histogram_value_at_percentile(instance_total, 0, &TEST_TAG_LIST_STRING, 0, 50.0), 1234); + EXPECT_EQ(fieldstat_histogram_count_le_value(instance, 0, &TEST_TAG_LIST_STRING, 0, 1000), 1); fieldstat_free(instance); fieldstat_free(instance_total); @@ -86,19 +86,19 @@ TEST(metric_test_histogram, merge) TEST(metric_test_histogram, merge_twice_with_reset) { struct fieldstat *instance = test_init_standard_instance_one_cube_one_metric_one_cell_hdr(); - fieldstat_hist_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); - fieldstat_hist_record(instance, 0, 0, &TEST_TAG_STRING, 1, 123); + fieldstat_histogram_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); + fieldstat_histogram_record(instance, 0, 0, &TEST_TAG_STRING, 1, 123); struct fieldstat *instance_total = fieldstat_new(); fieldstat_merge(instance_total, instance); fieldstat_reset(instance); - fieldstat_hist_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); + fieldstat_histogram_record(instance, 0, 0, &TEST_TAG_STRING, 1, 1234); fieldstat_merge(instance_total, instance); test_assert_standard_instance(instance_total); - EXPECT_EQ(fieldstat_hist_value_at_percentile(instance_total, 0, &TEST_TAG_LIST_STRING, 0, 50.0), 1234); - EXPECT_EQ(fieldstat_hist_count_le_value(instance_total, 0, &TEST_TAG_LIST_STRING, 0, 1000), 1); + EXPECT_EQ(fieldstat_histogram_value_at_percentile(instance_total, 0, &TEST_TAG_LIST_STRING, 0, 50.0), 1234); + EXPECT_EQ(fieldstat_histogram_count_le_value(instance_total, 0, &TEST_TAG_LIST_STRING, 0, 1000), 1); fieldstat_free(instance); fieldstat_free(instance_total); @@ -109,9 +109,9 @@ TEST(metric_test_histogram, add_with_wrong_cube_id_expecting_fail) struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int ret = fieldstat_hist_record(instance, cube_id + 1, 0, &TEST_TAG_INT, 1, 1); + int ret = fieldstat_histogram_record(instance, cube_id + 1, 0, &TEST_TAG_INT, 1, 1); EXPECT_EQ(ret, FS_ERR_INVALID_CUBE_ID); - ret = fieldstat_hist_record(instance, -1, 0, &TEST_TAG_INT, 1, 1); + ret = fieldstat_histogram_record(instance, -1, 0, &TEST_TAG_INT, 1, 1); EXPECT_EQ(ret, FS_ERR_INVALID_CUBE_ID); fieldstat_free(instance); @@ -121,11 +121,11 @@ TEST(metric_test_histogram, add_with_wrong_metric_id_expecting_fail) { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_hist(instance, cube_id, "czz_test", 1, 600000, 3); + int metric_id = fieldstat_register_histogram(instance, cube_id, "czz_test", 1, 600000, 3); - int ret = fieldstat_hist_record(instance, cube_id, metric_id + 1, &TEST_TAG_INT, 1, 1); + int ret = fieldstat_histogram_record(instance, cube_id, metric_id + 1, &TEST_TAG_INT, 1, 1); EXPECT_EQ(ret, FS_ERR_INVALID_METRIC_ID); - ret = fieldstat_hist_record(instance, cube_id, -1, &TEST_TAG_INT, 1, 1); + ret = fieldstat_histogram_record(instance, cube_id, -1, &TEST_TAG_INT, 1, 1); EXPECT_EQ(ret, FS_ERR_INVALID_METRIC_ID); fieldstat_free(instance); @@ -170,15 +170,15 @@ TEST(metric_test_histogram, can_add_0value) // histogram only allow min_val > 0, { struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int metric_id = fieldstat_register_hist(instance, cube_id, "czz_test", 1, 600000, 3); + int metric_id = fieldstat_register_histogram(instance, cube_id, "czz_test", 1, 600000, 3); - int ret = fieldstat_hist_record(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 0); + int ret = fieldstat_histogram_record(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 0); EXPECT_EQ(ret, 0); - ret = fieldstat_hist_record(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 0); + ret = fieldstat_histogram_record(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 0); EXPECT_EQ(ret, 0); - ret = fieldstat_hist_record(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 500); + ret = fieldstat_histogram_record(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 500); - EXPECT_EQ(fieldstat_hist_value_at_percentile(instance, cube_id, &TEST_TAG_LIST_INT, metric_id, 60.0), 0); + EXPECT_EQ(fieldstat_histogram_value_at_percentile(instance, cube_id, &TEST_TAG_LIST_INT, metric_id, 60.0), 0); fieldstat_free(instance); } diff --git a/test/test_metric_hll.cpp b/test/test_metric_hll.cpp index 66ef404..c96613c 100644 --- a/test/test_metric_hll.cpp +++ b/test/test_metric_hll.cpp @@ -74,7 +74,7 @@ TEST(metric_test_hll, add_with_tags) { struct fieldstat *instance = test_init_standard_instance_one_cube_one_metric_one_cell_hll(); fieldstat_hll_add_field(instance, 0, 0, &TEST_TAG_INT, 1, &TEST_TAG_INT, 1); - fieldstat_hll_add_field(instance, 0, 0, &TEST_TAG_INT, 1, &TEST_TAG_DOUBLE, 1); + fieldstat_hll_add_field(instance, 0, 0, &TEST_TAG_INT, 1, &TEST_FIELD_VALUE_DOUBLE, 1); fieldstat_hll_add_field(instance, 0, 0, &TEST_TAG_INT, 1, &TEST_TAG_STRING, 1); test_assert_standard_instance(instance); @@ -226,7 +226,7 @@ TEST(metric_test_hll, spread_sketch_add_and_test_accuracy) { struct fieldstat *instance = fieldstat_new(); int K = 10; - fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_SPREADSKETCH, K); + fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_TOP_CARDINALITY, K); fieldstat_register_hll(instance, 0, "testss", 6); int n_flows = 100000; diff --git a/test/test_performance.cpp b/test/test_performance.cpp index 2a8a8e9..3a9ef83 100644 --- a/test/test_performance.cpp +++ b/test/test_performance.cpp @@ -76,10 +76,10 @@ TEST(test_performance, merge_performance_one_instance_comprehensive_hll_empty_de TEST(test_performance, merge_performance_one_instance_comprehensive_histogram_empty_dest) { auto metric_add_func = [](struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, int n_field) { - fieldstat_hist_record(instance, cube_id, metric_id, fields, n_field, 1234); + fieldstat_histogram_record(instance, cube_id, metric_id, fields, n_field, 1234); }; auto metric_register_func = [](struct fieldstat *instance) { - return fieldstat_register_hist(instance, 0, "histogram metric", 1, 100000, 1); + return fieldstat_register_histogram(instance, 0, "histogram metric", 1, 100000, 1); }; double elapsed = perform_merge_test(metric_add_func, metric_register_func, SAMPLING_MODE_COMPREHENSIVE, true); @@ -132,10 +132,10 @@ TEST(test_performance, merge_performance_one_instance_comprehensive_hll_full_des TEST(test_performance, merge_performance_one_instance_comprehensive_histogram_full_dest) { auto metric_add_func = [](struct fieldstat *instance, int cube_id, int metric_id, const struct field *fields, int n_field) { - fieldstat_hist_record(instance, cube_id, metric_id, fields, n_field, 1234); + fieldstat_histogram_record(instance, cube_id, metric_id, fields, n_field, 1234); }; auto metric_register_func = [](struct fieldstat *instance) { - return fieldstat_register_hist(instance, 0, "histogram metric", 1, 100000, 1); + return fieldstat_register_histogram(instance, 0, "histogram metric", 1, 100000, 1); }; double elapsed = perform_merge_test(metric_add_func, metric_register_func, SAMPLING_MODE_COMPREHENSIVE, false); @@ -268,7 +268,7 @@ TEST(test_performance, performance_test_add_cells_histogram_record) { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_hist(instance, 0, "test", 1, 100000, 3); + fieldstat_register_histogram(instance, 0, "test", 1, 100000, 3); size_t test_num = 100000; long long vals[test_num]; for (size_t i = 0; i < test_num; i++) { @@ -276,7 +276,7 @@ TEST(test_performance, performance_test_add_cells_histogram_record) } clock_t start = clock(); for (size_t i = 0; i < test_num; i++) { - fieldstat_hist_record(instance, 0, 0, &TEST_TAG_INT, 1, vals[i]); + fieldstat_histogram_record(instance, 0, 0, &TEST_TAG_INT, 1, vals[i]); } clock_t end = clock(); double seconds = (double)(end - start) / test_num; @@ -347,7 +347,7 @@ TEST(test_performance, performance_test_add_cells_histogram_record_5tags) { struct fieldstat *instance = fieldstat_new(); fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_register_hist(instance, 0, "test", 1, 100000, 3); + fieldstat_register_histogram(instance, 0, "test", 1, 100000, 3); size_t test_num = 100000; long long vals[test_num]; for (size_t i = 0; i < test_num; i++) { @@ -357,12 +357,12 @@ TEST(test_performance, performance_test_add_cells_histogram_record_5tags) struct field fields[5]; fields[0] = TEST_TAG_INT; fields[1] = TEST_TAG_STRING; - fields[2] = TEST_TAG_DOUBLE; + fields[2] = TEST_FIELD_VALUE_DOUBLE; fields[3] = TEST_TAG_INT; fields[4] = TEST_TAG_INT; clock_t start = clock(); for (size_t i = 0; i < test_num; i++) { - fieldstat_hist_record(instance, 0, 0, fields, 5, vals[i]); + fieldstat_histogram_record(instance, 0, 0, fields, 5, vals[i]); } clock_t end = clock(); double seconds = (double)(end - start) / test_num; @@ -385,7 +385,7 @@ TEST(test_performance, performance_test_add_cells_hll_add_5tags) struct field fields[5]; fields[0] = TEST_TAG_INT; fields[1] = TEST_TAG_STRING; - fields[2] = TEST_TAG_DOUBLE; + fields[2] = TEST_FIELD_VALUE_DOUBLE; fields[3] = TEST_TAG_INT; fields[4] = TEST_TAG_INT; clock_t start = clock(); diff --git a/test/test_register_and_reset.cpp b/test/test_register_and_reset.cpp index 36902e1..79134e1 100644 --- a/test/test_register_and_reset.cpp +++ b/test/test_register_and_reset.cpp @@ -51,12 +51,12 @@ TEST(test_register, delete_topk_cube_with_cells_and_metrics) TEST(test_register, delete_spreadsketch_cube_with_cells_and_metrics) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 10); + int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 10); int metric_id1 = fieldstat_register_counter(instance, cube_id, "counter"); int metric_primary = fieldstat_register_hll(instance, cube_id, "hll_primary", 5); fieldstat_cube_set_primary_metric(instance, cube_id, metric_primary); fieldstat_counter_incrby(instance, cube_id, metric_id1, &TEST_TAG_INT, 1, 1); - fieldstat_hll_add_field(instance, cube_id, metric_primary, &TEST_TAG_INT, 1, &TEST_TAG_DOUBLE, 1); + fieldstat_hll_add_field(instance, cube_id, metric_primary, &TEST_TAG_INT, 1, &TEST_FIELD_VALUE_DOUBLE, 1); fieldstat_destroy_cube(instance, cube_id); struct field_list *tag_list = fieldstat_cube_get_tags(instance, cube_id); @@ -118,7 +118,7 @@ TEST(test_register, reset_and_try_to_query_cell_topk) TEST(test_register, reset_and_try_to_query_cell_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 10); + int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 10); int metric_id = fieldstat_register_hll(instance, cube_id, "hll", 5); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_INT, 1, "12abc", 5); @@ -140,7 +140,7 @@ TEST(test_register, reset_and_new_cell_comprehensive) int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 2); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); - fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, 1); + fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_FIELD_VALUE_DOUBLE, 1, 1); int ret = fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, 1); EXPECT_EQ(ret, FS_ERR_TOO_MANY_CELLS); @@ -157,11 +157,11 @@ TEST(test_register, reset_and_new_cell_topk) int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 1); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 100);//100: bigger value - int ret = fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, 1); + int ret = fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_FIELD_VALUE_DOUBLE, 1, 1); EXPECT_EQ(ret, FS_ERR_TOO_MANY_CELLS); fieldstat_reset(instance); - ret = fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, 1); + ret = fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_FIELD_VALUE_DOUBLE, 1, 1); EXPECT_EQ(ret, FS_OK); fieldstat_free(instance); @@ -170,7 +170,7 @@ TEST(test_register, reset_and_new_cell_topk) TEST(test_register, reset_and_new_cell_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, 1); + int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 1); int metric_id = fieldstat_register_hll(instance, cube_id, "hll", 5); // spread sketch will store more data than expected cell number 1. So loop for many cells first to trigger the error struct field test_tag_long = TEST_TAG_INT; @@ -178,11 +178,11 @@ TEST(test_register, reset_and_new_cell_spreadsketch) test_tag_long.value_longlong = i; fieldstat_hll_add(instance, cube_id, metric_id, &test_tag_long, 1, "12abc", 5); } - int ret = fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, "12abc", 5); + int ret = fieldstat_hll_add(instance, cube_id, metric_id, &TEST_FIELD_VALUE_DOUBLE, 1, "12abc", 5); EXPECT_EQ(ret, FS_ERR_TOO_MANY_CELLS); fieldstat_reset(instance); - ret = fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, "12abc", 5); + ret = fieldstat_hll_add(instance, cube_id, metric_id, &TEST_FIELD_VALUE_DOUBLE, 1, "12abc", 5); EXPECT_EQ(ret, FS_OK); fieldstat_free(instance); @@ -251,7 +251,7 @@ TEST(test_register, ensure_recovery_more_faster_topk) { TEST(test_register, ensure_recovery_more_faster_spreadsketch) { struct fieldstat *instance = fieldstat_new(); int cell_num = 1000; - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_SPREADSKETCH, cell_num); + int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, cell_num); int metric_id = fieldstat_register_hll(instance, cube_id, "counter", 6); struct field test_tag_long = TEST_TAG_INT; @@ -385,8 +385,8 @@ TEST(test_register, fork_registered_info_with_cube_and_metric) int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); int metric_id2 = fieldstat_register_counter(instance, cube_id, "counter2"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); - int cube_id_del = fieldstat_create_cube(instance, &TEST_TAG_DOUBLE_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_create_cube(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id_del = fieldstat_create_cube(instance, &TEST_FIELD_VALUE_DOUBLE_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + fieldstat_create_cube(instance, &TEST_FIELD_VALUE_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_destroy_cube(instance, cube_id_del); struct fieldstat *dup = fieldstat_fork(instance); @@ -405,7 +405,7 @@ TEST(test_register, fork_registered_info_with_cube_and_metric) EXPECT_EQ(n_cell, 0); tag_list = fieldstat_cube_get_tags(dup, cube_ids[1]); - EXPECT_STREQ(tag_list->field[0].key, TEST_TAG_DOUBLE.key); + EXPECT_STREQ(tag_list->field[0].key, TEST_FIELD_VALUE_DOUBLE.key); fieldstat_tag_list_arr_free(tag_list, 1); @@ -424,7 +424,7 @@ TEST(test_register, unregister_cube_on_wrong_instance) struct fieldstat *instance_dst = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int cube_id2 = fieldstat_create_cube(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id2 = fieldstat_create_cube(instance, &TEST_FIELD_VALUE_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); int metric_id2 = fieldstat_register_counter(instance, cube_id2, "counter2"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); @@ -459,7 +459,7 @@ TEST(test_register, register_many_cells_on_unlimited_sized_cube) struct fieldstat *instance = fieldstat_new(); int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 0); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); - struct field test_tag = {"abc", TAG_INTEGER, {.value_longlong = 0}}; + struct field test_tag = {"abc", FIELD_VALUE_INTEGER, {.value_longlong = 0}}; for (int i = 0; i < 10000; i++) { test_tag.value_longlong = i; fieldstat_counter_incrby(instance, cube_id, metric_id, &test_tag, 1, 1); @@ -490,7 +490,7 @@ TEST(test_register, find_cube) { int find_cube_id = fieldstat_find_cube(instance, &TEST_SHARED_TAG, 1); EXPECT_EQ(cube_id, find_cube_id); - int find_cube_id2 = fieldstat_find_cube(instance, &TEST_TAG_DOUBLE, 1); + int find_cube_id2 = fieldstat_find_cube(instance, &TEST_FIELD_VALUE_DOUBLE, 1); EXPECT_EQ(find_cube_id2, FS_ERR_INVALID_KEY); fieldstat_free(instance); diff --git a/test/test_write_json_file.cpp b/test/test_write_json_file.cpp index 1c6a969..ff3dedf 100644 --- a/test/test_write_json_file.cpp +++ b/test/test_write_json_file.cpp @@ -28,17 +28,17 @@ extern "C" { struct field cell_tags[2]; global_tags[0].key = "rule_id"; - global_tags[0].type = TAG_INTEGER; + global_tags[0].type = FIELD_VALUE_INTEGER; global_tags[0].value_longlong = 1; global_tags[1].key = "action"; - global_tags[1].type = TAG_CSTRING; + global_tags[1].type = FIELD_VALUE_CSTRING; global_tags[1].value_str = "deny"; cell_tags[0].key = "thread_id"; - cell_tags[0].type = TAG_INTEGER; + cell_tags[0].type = FIELD_VALUE_INTEGER; cell_tags[0].value_longlong = 1; cell_tags[1].key = "hit_rate"; - cell_tags[1].type = TAG_DOUBLE; + cell_tags[1].type = FIELD_VALUE_DOUBLE; cell_tags[1].value_double = 1.1; const char *hist_names[] = {"list_num", "max_wt_ms", "ivt_nx_itv_ms", @@ -62,7 +62,7 @@ static void write_hll(struct fieldstat *instance) { struct field shared_tags[1]; shared_tags[0].key = "rule_id"; - shared_tags[0].type = TAG_INTEGER; + shared_tags[0].type = FIELD_VALUE_INTEGER; shared_tags[0].value_longlong = 1; const char *hll_name[] = {"external_ip", "internal_ip", "acc_ip"}; @@ -89,17 +89,17 @@ void write_histogram(struct fieldstat *instance) { struct field cell_tags[2]; shared_tags[0].key = "rule_id"; - shared_tags[0].type = TAG_INTEGER; + shared_tags[0].type = FIELD_VALUE_INTEGER; shared_tags[0].value_longlong = 1; shared_tags[1].key = "action"; - shared_tags[1].type = TAG_CSTRING; + shared_tags[1].type = FIELD_VALUE_CSTRING; shared_tags[1].value_str = "deny"; cell_tags[0].key = "thread_id"; - cell_tags[0].type = TAG_INTEGER; + cell_tags[0].type = FIELD_VALUE_INTEGER; cell_tags[0].value_longlong = 1; cell_tags[1].key = "hit_rate"; - cell_tags[1].type = TAG_DOUBLE; + cell_tags[1].type = FIELD_VALUE_DOUBLE; cell_tags[1].value_double = 1.1; const char *hist_names[] = {"list_num", "max_wt_ms", "ivt_nx_itv_ms", @@ -112,11 +112,11 @@ void write_histogram(struct fieldstat *instance) { for(unsigned int i = 0; i < sizeof(hist_names)/sizeof(hist_names[0]); i++) { - int hist_id = fieldstat_register_hist(instance, cube_id, hist_names[i], 1, 600000, 3); + int hist_id = fieldstat_register_histogram(instance, cube_id, hist_names[i], 1, 600000, 3); for(int j = 0; j < 100; j++) { - fieldstat_hist_record(instance, cube_id, hist_id, cell_tags, 2, i*100 + j); + fieldstat_histogram_record(instance, cube_id, hist_id, cell_tags, 2, i*100 + j); } } } @@ -127,10 +127,10 @@ void write_histogram(struct fieldstat *instance) { // struct field cell_tags; // global_tags[0].key = "policy_id"; -// global_tags[0].type = TAG_INTEGER; +// global_tags[0].type = FIELD_VALUE_INTEGER; // global_tags[0].value_longlong = 1; // global_tags[1].key = "quanlity"; -// global_tags[1].type = TAG_DOUBLE; +// global_tags[1].type = FIELD_VALUE_DOUBLE; // global_tags[1].value_double = 0.5; // const char *cell_tag_value[] = { @@ -140,7 +140,7 @@ void write_histogram(struct fieldstat *instance) { // "STATISTICS-RULE-METRIC", "OBJECT-STATISTICS-METRIC"}; // cell_tags.key = "send_log"; -// cell_tags.type = TAG_CSTRING; +// cell_tags.type = FIELD_VALUE_CSTRING; // cell_tags.value_str = "true"; // struct fieldstat_easy *fse = fieldstat_easy_new(N_THREAD, NULL, global_tags, 2); @@ -168,10 +168,10 @@ void fieldstat_easy_to_file(struct fieldstat_easy *fse, const char *file_path) void write_table(struct fieldstat *instance) { struct field shared_tags[2]; shared_tags[0].key = "policy_id"; - shared_tags[0].type = TAG_INTEGER; + shared_tags[0].type = FIELD_VALUE_INTEGER; shared_tags[0].value_longlong = 1; shared_tags[1].key = "quanlity"; - shared_tags[1].type = TAG_DOUBLE; + shared_tags[1].type = FIELD_VALUE_DOUBLE; shared_tags[1].value_double = 0.5; const char *cell_tag_value[] = { @@ -182,7 +182,7 @@ void write_table(struct fieldstat *instance) { struct field cell_tags; cell_tags.key = "send_log"; - cell_tags.type = TAG_CSTRING; + cell_tags.type = FIELD_VALUE_CSTRING; cell_tags.value_str = "true"; int cube_id = fieldstat_create_cube(instance, shared_tags, 2, diff --git a/test/utils.cpp b/test/utils.cpp index eb14f6f..4e41d8f 100644 --- a/test/utils.cpp +++ b/test/utils.cpp @@ -45,13 +45,13 @@ Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const struct field_list * tag_list_c.field[i].type = tag_list->field[i].type; switch (tag_list->field[i].type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: tag_list_c.field[i].value_longlong = tag_list->field[i].value_longlong; break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: tag_list_c.field[i].value_double = tag_list->field[i].value_double; break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: tag_list_c.field[i].value_str = strdup(tag_list->field[i].value_str); break; default: @@ -65,7 +65,7 @@ Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const char * key, int val tag_list_c.field = (struct field *)malloc(sizeof(struct field)); tag_list_c.n_field = 1; tag_list_c.field[0].key = strdup(key); - tag_list_c.field[0].type = TAG_INTEGER; + tag_list_c.field[0].type = FIELD_VALUE_INTEGER; tag_list_c.field[0].value_longlong = value; } @@ -74,7 +74,7 @@ Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const char * key, const c tag_list_c.field = (struct field *)malloc(sizeof(struct field)); tag_list_c.n_field = 1; tag_list_c.field[0].key = strdup(key); - tag_list_c.field[0].type = TAG_CSTRING; + tag_list_c.field[0].type = FIELD_VALUE_CSTRING; tag_list_c.field[0].value_str = strdup(value); } @@ -82,7 +82,7 @@ Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const char * key, const c Fieldstat_tag_list_wrapper::~Fieldstat_tag_list_wrapper() { for (size_t i = 0; i < tag_list_c.n_field; i++) { free((char *)tag_list_c.field[i].key); - if (tag_list_c.field[i].type == TAG_CSTRING) { + if (tag_list_c.field[i].type == FIELD_VALUE_CSTRING) { free((char *)tag_list_c.field[i].value_str); } } @@ -100,17 +100,17 @@ Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(std::uniform_int_distribu int rand_ret = rand() % 3; if (rand_ret == 0) { - tag_list_c.field[i].type = TAG_INTEGER; + tag_list_c.field[i].type = FIELD_VALUE_INTEGER; tag_list_c.field[i].value_longlong = static_cast(dist(rng)); } else if (rand_ret == 1) { - tag_list_c.field[i].type = TAG_DOUBLE; + tag_list_c.field[i].type = FIELD_VALUE_DOUBLE; tag_list_c.field[i].value_double = static_cast(dist(rng)) + 0.5; } else { - tag_list_c.field[i].type = TAG_CSTRING; + tag_list_c.field[i].type = FIELD_VALUE_CSTRING; tag_list_c.field[i].value_str = strdup(gen_rand_string(10).c_str()); } } @@ -132,13 +132,13 @@ Fieldstat_tag_list_wrapper::Fieldstat_tag_list_wrapper(const Fieldstat_tag_list_ tag_list_c.field[i].type = tag_list->field[i].type; switch (tag_list->field[i].type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: tag_list_c.field[i].value_longlong = tag_list->field[i].value_longlong; break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: tag_list_c.field[i].value_double = tag_list->field[i].value_double; break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: tag_list_c.field[i].value_str = strdup(tag_list->field[i].value_str); break; default: @@ -171,13 +171,13 @@ void Fieldstat_tag_list_wrapper::print_tag_list() const printf("tag_list_c.field[%zu].type: %d\n", i, (int)tag_list_c.field[i].type); switch (tag_list_c.field[i].type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: printf("tag_list_c.field[%zu].value_longlong: %lld\n", i, tag_list_c.field[i].value_longlong); break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: printf("tag_list_c.field[%zu].value_double: %lf\n", i, tag_list_c.field[i].value_double); break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: printf("tag_list_c.field[%zu].value_str: %s\n", i, tag_list_c.field[i].value_str); break; default: @@ -196,13 +196,13 @@ string Fieldstat_tag_list_wrapper::to_string() const str += ":"; switch (tag_list_c.field[i].type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: str += std::to_string(tag_list_c.field[i].value_longlong); break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: str += std::to_string(tag_list_c.field[i].value_double); break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: str += tag_list_c.field[i].value_str; break; default: @@ -227,17 +227,17 @@ bool Fieldstat_tag_list_wrapper::operator==(const Fieldstat_tag_list_wrapper &ta return false; } switch (tag_list_c.field[i].type) { - case TAG_INTEGER: + case FIELD_VALUE_INTEGER: if (tag_list_c.field[i].value_longlong != tag_list->field[i].value_longlong) { return false; } break; - case TAG_DOUBLE: + case FIELD_VALUE_DOUBLE: if (tag_list_c.field[i].value_double != tag_list->field[i].value_double) { return false; } break; - case TAG_CSTRING: + case FIELD_VALUE_CSTRING: if (strcmp((char *)tag_list_c.field[i].value_str, (char *)tag_list->field[i].value_str) != 0) { return false; } diff --git a/test/utils.hpp b/test/utils.hpp index ce73db0..bfb9414 100644 --- a/test/utils.hpp +++ b/test/utils.hpp @@ -3,16 +3,16 @@ #include #include "fieldstat.h" -const struct field TEST_TAG_STRING = {"STRING KEY_", TAG_CSTRING, {.value_str = "100.1"}}; +const struct field TEST_TAG_STRING = {"STRING KEY_", FIELD_VALUE_CSTRING, {.value_str = "100.1"}}; const struct field_list TEST_TAG_LIST_STRING = {(struct field *)&TEST_TAG_STRING, 1}; -const struct field TEST_TAG_STRING_collided = {"collided", TAG_CSTRING, {.value_str = "2"}}; -const struct field TEST_TAG_INT = {"INT key_", TAG_INTEGER, {.value_longlong = 100}}; +const struct field TEST_TAG_STRING_collided = {"collided", FIELD_VALUE_CSTRING, {.value_str = "2"}}; +const struct field TEST_TAG_INT = {"INT key_", FIELD_VALUE_INTEGER, {.value_longlong = 100}}; const struct field_list TEST_TAG_LIST_INT = {(struct field *)&TEST_TAG_INT, 1}; -const struct field TEST_TAG_INT_collided = {"collided", TAG_INTEGER, {.value_longlong = 2}}; -const struct field TEST_TAG_DOUBLE = {"DOUBLE key_", TAG_DOUBLE, {.value_double = 100.1}}; -const struct field_list TEST_TAG_LIST_DOUBLE = {(struct field *)&TEST_TAG_DOUBLE, 1}; -const struct field TEST_TAG_DOUBLE_collided = {"collided", TAG_DOUBLE, {.value_double = 2.0}}; -const struct field TEST_SHARED_TAG = {"shared", TAG_INTEGER, {.value_longlong = 1}}; +const struct field TEST_TAG_INT_collided = {"collided", FIELD_VALUE_INTEGER, {.value_longlong = 2}}; +const struct field TEST_FIELD_VALUE_DOUBLE = {"DOUBLE key_", FIELD_VALUE_DOUBLE, {.value_double = 100.1}}; +const struct field_list TEST_TAG_LIST_DOUBLE = {(struct field *)&TEST_FIELD_VALUE_DOUBLE, 1}; +const struct field TEST_FIELD_VALUE_DOUBLE_collided = {"collided", FIELD_VALUE_DOUBLE, {.value_double = 2.0}}; +const struct field TEST_SHARED_TAG = {"shared", FIELD_VALUE_INTEGER, {.value_longlong = 1}}; const struct timeval TEST_TIMEVAL = {100, 10000}; const long long TEST_TIMEVAL_LONG = 100010; // 100s * 1000 + 10000us / 1000 = 100010ms -- cgit v1.2.3 From 8ce45ff4f96186c5d9e0f3e82addd2085d7c8788 Mon Sep 17 00:00:00 2001 From: chenzizhan Date: Wed, 17 Jul 2024 15:46:47 +0800 Subject: cube set sampling --- include/fieldstat/fieldstat.h | 13 ++-- readme_fieldstat.md | 2 +- src/cells/hash_table.c | 3 + src/cells/heavy_keeper.c | 3 + src/cells/spread_sketch.c | 3 + src/cube.c | 86 +++++++++++++++++------- src/cube.h | 3 +- src/fieldstat.c | 46 ++++++------- src/fieldstat_easy.c | 3 +- test/profiling/main.c | 2 +- test/test_empty_tags.cpp | 13 ++-- test/test_exporter_json.cpp | 57 +++++++++------- test/test_fuzz_test.cpp | 37 +++++++---- test/test_merge.cpp | 70 +++++++++++++------- test/test_metric_counter.cpp | 28 +++++--- test/test_metric_histogram.cpp | 16 +++-- test/test_metric_hll.cpp | 17 +++-- test/test_performance.cpp | 39 +++++++---- test/test_register_and_reset.cpp | 138 +++++++++++++++++++++++---------------- test/test_write_json_file.cpp | 14 +++- 20 files changed, 383 insertions(+), 210 deletions(-) (limited to 'test/test_write_json_file.cpp') diff --git a/include/fieldstat/fieldstat.h b/include/fieldstat/fieldstat.h index b5fef15..0f77ec4 100644 --- a/include/fieldstat/fieldstat.h +++ b/include/fieldstat/fieldstat.h @@ -67,11 +67,8 @@ int fieldstat_calibrate(const struct fieldstat *master, struct fieldstat *replic * @param max_n_cell: max number of samplings(cells) in each cube. When mode is TOPK, max_n_cell > 0, while in COMPREHENSIVE mode, max_n_cell can be 0, meaning that there is no limit. * @return cube id, if success; otherwise, return FS_ERR_NULL_HANDLER, or FS_ERR_INVALID_PARAM when (max_n_cell == 0 && mode == TOPK). return FS_ERR_INVALID_KEY when the cube_dimensions is not unique. */ -int fieldstat_create_cube(struct fieldstat *instance, const struct field *cube_dimensions, size_t n_dimension, enum sampling_mode mode, size_t max_n_cell); -// todo: 重命名为fieldstat_cube_create - -//todo: create cube 接口变化 -// int fieldstat_cube_set_sampling(struct fieldstat *instance, int cube_id, enum sampling_mode mode, int max_n_cell, int primary_metric_id); +int fieldstat_cube_create(struct fieldstat *instance, const struct field *cube_dimensions, size_t n_dimension); +int fieldstat_cube_set_sampling(struct fieldstat *instance, int cube_id, enum sampling_mode mode, int max_n_cell, int primary_metric_id); /* @brief Change the topk cube primary metric id. When fieldstat_counter_add or fieldstat_counter_set are called on the primary metric, the topk record of such cell will be updated. @@ -87,7 +84,7 @@ int fieldstat_cube_set_primary_metric(struct fieldstat *instance, int cube_id, i * @brief Delete the cube of cube_id. All the cells and metrics are deleted. The cube_id may be reused by other new cubes. Increase the corresponding cube_version by 1. * @return FS_OK, FS_ERR_NULL_HANDLER or FS_ERR_INVALID_CUBE_ID */ -int fieldstat_destroy_cube(struct fieldstat *instance, int cube_id); +int fieldstat_cube_destroy(struct fieldstat *instance, int cube_id); /* * @brief add a metric to the cube of cube_id. One metric may be associated with different cells. @@ -114,7 +111,7 @@ int fieldstat_register_histogram(struct fieldstat *instance, int cube_id, const /* * @brief let the value of counter metric of cell_id increase by `increment`. - * @param cube_id: cube id, previously returned by fieldstat_create_cube. + * @param cube_id: cube id, previously returned by fieldstat_cube_create. * @param metric_id: metric id, previously returned by fieldstat_register_counter. * @param increment: increment of the counter metric. Can be negative. * @return FS_OK if success. FS_ERR_NULL_HANDLER, FS_ERR_INVALID_CUBE_ID, FS_ERR_INVALID_METRIC_ID if fail. @@ -200,7 +197,7 @@ enum metric_type fieldstat_get_metric_type(const struct fieldstat *instance, int void fieldstat_cube_get_cells(const struct fieldstat *instance, int cube_id, struct field_list **cell_dimensions, size_t *n_cell); /* - get the field of fieldstat_create_cube. User free them by calling fieldstat_tag_list_arr_free(struct field_list *, 1) + get the field of fieldstat_cube_create. User free them by calling fieldstat_tag_list_arr_free(struct field_list *, 1) return NULL when ID is invalid. */ struct field_list *fieldstat_cube_get_tags(const struct fieldstat *instance, int cube_id); diff --git a/readme_fieldstat.md b/readme_fieldstat.md index 42c6680..4dd7a99 100644 --- a/readme_fieldstat.md +++ b/readme_fieldstat.md @@ -40,7 +40,7 @@ Download fieldstat4 rpm from https://repo.geedge.net/pulp/content/ and install r #include "fieldstat.h" struct fieldstat *instance = fieldstat_new(); -int cube_id = fieldstat_create_cube(instance, YOUR_SHARED_TAG, YOUR_SHARED_TAG_LENGTH, SAMPLING_MODE_TOPK, MAX_CELL_NUMBER); +int cube_id = fieldstat_cube_create(instance, YOUR_SHARED_TAG, YOUR_SHARED_TAG_LENGTH, SAMPLING_MODE_TOPK, MAX_CELL_NUMBER); int metric_counter_id = fieldstat_register_counter(instance, cube_id, "any metric name", 0/1); int metric_histogram_id = fieldstat_register_histogramogram(instance, cube_id, "any metric name", THE_MINIMUM_NUMBER_TO_RECORD, THE_MAXIMUM_NUMBER_TO_RECORD, PRECISION); int metric_hll_id = fieldstat_register_hll(instance, cube_id, "any metric name", PRECISION); diff --git a/src/cells/hash_table.c b/src/cells/hash_table.c index d6dbfb5..60d2465 100644 --- a/src/cells/hash_table.c +++ b/src/cells/hash_table.c @@ -64,6 +64,9 @@ struct hash_table *hash_table_new(int max_query_num) { } void hash_table_free(struct hash_table *pthis) { + if (pthis == NULL) { + return; + } struct tag_exdata_item *item, *tmp; HASH_ITER(hh, pthis->tag_id_map, item, tmp) { HASH_DEL(pthis->tag_id_map, item); diff --git a/src/cells/heavy_keeper.c b/src/cells/heavy_keeper.c index b606a67..c62e550 100644 --- a/src/cells/heavy_keeper.c +++ b/src/cells/heavy_keeper.c @@ -518,6 +518,9 @@ struct heavy_keeper *heavy_keeper_new(int max_query_num) { } void heavy_keeper_free(struct heavy_keeper *hk) { + if (hk == NULL) { + return; + } sorted_set_free(hk->top_K_heap); free(hk->sketch); diff --git a/src/cells/spread_sketch.c b/src/cells/spread_sketch.c index 5d5dd72..3e9b11e 100644 --- a/src/cells/spread_sketch.c +++ b/src/cells/spread_sketch.c @@ -382,6 +382,9 @@ struct spread_sketch *duplicate_and_step(const struct spread_sketch *ss, const s } void spread_sketch_free(struct spread_sketch *ss) { + if (ss == NULL) { + return; + } smart_ptr_table_free(ss->table); for (int i = 0; i < ss->depth * ss->width; i++) { hll_free_register(ss->buckets[i].sthll_register); diff --git a/src/cube.c b/src/cube.c index 4bd3305..abc3a66 100644 --- a/src/cube.c +++ b/src/cube.c @@ -497,10 +497,9 @@ void *exdata_copy_i(void *exdata) { return cell_copy((struct cell *)exdata); } -struct cube *cube_info_new(const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, size_t max_n_cell) +struct cube *cube_info_new(const struct field *dimensions, size_t n_dimensions) { struct cube *cube = calloc(1, sizeof(struct cube)); - cube->sampling_mode = mode; if (n_dimensions == 0) { cube->cube_dimensions = NULL; @@ -509,42 +508,81 @@ struct cube *cube_info_new(const struct field *dimensions, size_t n_dimensions, } cube->n_dimensions = n_dimensions; - cube->max_n_cell = max_n_cell; field_array_to_key(dimensions, n_dimensions, &cube->serialized_dimensions, &cube->serialized_dimensions_len); cube->id = -1; + cube->primary_metric_id = -1; return cube; } -struct cube *cube_new(const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, size_t max_n_cell) +struct cube *cube_new(const struct field *dimensions, size_t n_dimensions) { - struct cube *cube = cube_info_new(dimensions, n_dimensions, mode, max_n_cell); + struct cube *cube = cube_info_new(dimensions, n_dimensions); cube->manifest_manager = metric_manifest_manager_new(); - switch (mode) - { + return cube; +} + +int cube_set_sampling_mode(struct cube *cube, enum sampling_mode mode, int max_n_cell, int primary_metric_id) { + if (cube->sampling_mode == mode && cube->max_n_cell == max_n_cell && cube->primary_metric_id == primary_metric_id) { + return FS_OK; + } + const struct metric_manifest *manifest = metric_manifest_manager_get_by_id(cube->manifest_manager, primary_metric_id); + if (manifest == NULL && mode != SAMPLING_MODE_COMPREHENSIVE) { + return FS_ERR_INVALID_METRIC_ID; + } + if ((mode == SAMPLING_MODE_TOPK && manifest->type != METRIC_TYPE_COUNTER) || + (mode == SAMPLING_MODE_TOP_CARDINALITY && manifest->type != METRIC_TYPE_HLL)) { + return FS_ERR_INVALID_PARAM; + } + + if (cube->primary_metric_id != -1) { + // delete previous settings + switch (cube->sampling_mode) + { case SAMPLING_MODE_TOPK: - cube->heavykeeper = heavy_keeper_new(max_n_cell); - heavy_keeper_set_exdata_schema(cube->heavykeeper, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); + heavy_keeper_free(cube->heavykeeper); break; case SAMPLING_MODE_COMPREHENSIVE: - cube->table = hash_table_new(max_n_cell); - hash_table_set_exdata_schema(cube->table, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); + hash_table_free(cube->table); + break; + case SAMPLING_MODE_TOP_CARDINALITY: + spread_sketch_free(cube->spread_sketch); break; - case SAMPLING_MODE_TOP_CARDINALITY: { - int width, depth; - unsigned char precision; - spread_sketch_get_parameter_recommendation(max_n_cell, &depth, &width, &precision); - cube->spread_sketch = spread_sketch_new(depth, width, precision, 0, DUMMY_TIME_VAL); - spread_sketch_set_exdata_schema(cube->spread_sketch, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); - break; } default: assert(0); break; + } } - return cube; + switch (mode) + { + case SAMPLING_MODE_TOPK: + cube->heavykeeper = heavy_keeper_new(max_n_cell); + heavy_keeper_set_exdata_schema(cube->heavykeeper, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); + break; + case SAMPLING_MODE_COMPREHENSIVE: + cube->table = hash_table_new(max_n_cell); + hash_table_set_exdata_schema(cube->table, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); + break; + case SAMPLING_MODE_TOP_CARDINALITY: { + int width, depth; + unsigned char precision; + spread_sketch_get_parameter_recommendation(max_n_cell, &depth, &width, &precision); + cube->spread_sketch = spread_sketch_new(depth, width, precision, 0, DUMMY_TIME_VAL); + spread_sketch_set_exdata_schema(cube->spread_sketch, exdata_new_i, exdata_free_i, exdata_merge_i, exdata_reset_i, exdata_copy_i); + break; } + default: + assert(0); + break; + } + + cube->sampling_mode = mode; + cube->max_n_cell = max_n_cell; + cube->primary_metric_id = primary_metric_id; + + return FS_OK; } void cube_free(struct cube *cube) { @@ -932,6 +970,7 @@ int cube_hll_add_field(struct cube *cube, int metric_id, const struct field *dim } int cube_counter_incrby(struct cube *cube, int metric_id, const struct field *dimensions, size_t n_dimensions, long long increment) { + assert(cube->primary_metric_id != -1); assert(cube->sampling_mode == SAMPLING_MODE_COMPREHENSIVE || (cube->sampling_mode == SAMPLING_MODE_TOPK && (cube->primary_metric_id != metric_id || increment >= 0)) || (cube->sampling_mode == SAMPLING_MODE_TOP_CARDINALITY && cube->primary_metric_id != metric_id) @@ -1020,8 +1059,10 @@ int cube_counter_set(struct cube *cube, int metric_id, const struct field *dimen struct cube *cube_copy(const struct cube *cube) { - struct cube *cube_dup = cube_info_new(cube->cube_dimensions, cube->n_dimensions, cube->sampling_mode, cube->max_n_cell); + struct cube *cube_dup = cube_info_new(cube->cube_dimensions, cube->n_dimensions); cube_dup->primary_metric_id = cube->primary_metric_id; + cube_dup->sampling_mode = cube->sampling_mode; + cube_dup->max_n_cell = cube->max_n_cell; switch (cube->sampling_mode) { @@ -1087,8 +1128,10 @@ int cube_merge(struct cube *dest, const struct cube *src) } struct cube *cube_fork(const struct cube *cube) { - struct cube *ret = cube_info_new(cube->cube_dimensions, cube->n_dimensions, cube->sampling_mode, cube->max_n_cell); + struct cube *ret = cube_info_new(cube->cube_dimensions, cube->n_dimensions); ret->primary_metric_id = cube->primary_metric_id; + ret->sampling_mode = cube->sampling_mode; + ret->max_n_cell = cube->max_n_cell; ret->manifest_manager = metric_manifest_manager_copy(cube->manifest_manager); switch (cube->sampling_mode) { @@ -1431,7 +1474,6 @@ struct field_list *cube_get_identifier(const struct cube *cube) { const char *cube_get_metric_name(const struct cube *cube, int metric_id) { const struct metric_manifest *metric = metric_manifest_manager_get_by_id(cube->manifest_manager, metric_id); if (metric == NULL) { - printf("metric is null\n"); return NULL; } diff --git a/src/cube.h b/src/cube.h index 134ede8..842f064 100644 --- a/src/cube.h +++ b/src/cube.h @@ -13,7 +13,8 @@ extern "C" struct cube; struct cube_manager; -struct cube *cube_new(const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, size_t max_n_cell); +struct cube *cube_new(const struct field *dimensions, size_t n_dimensions); +int cube_set_sampling_mode(struct cube *cube, enum sampling_mode mode, int max_n_cell, int primary_metric_id); void cube_free(struct cube *cube); void cube_reset(struct cube *cube); struct cube *cube_copy(const struct cube *cube); diff --git a/src/fieldstat.c b/src/fieldstat.c index 4f4582b..002d754 100644 --- a/src/fieldstat.c +++ b/src/fieldstat.c @@ -48,7 +48,7 @@ void fieldstat_reset(struct fieldstat *instance) cube_manager_reset(instance->cube_manager); } -int fieldstat_destroy_cube(struct fieldstat *instance, int cube_id) +int fieldstat_cube_destroy(struct fieldstat *instance, int cube_id) { struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); if (cube == NULL) { @@ -76,7 +76,24 @@ void fieldstat_free_tag_array(struct field *fields, size_t n_tags) free(fields); } -int fieldstat_create_cube(struct fieldstat *instance, const struct field *cube_dimensions, size_t n_dimension, enum sampling_mode mode, size_t max_n_cell) +// cppcheck-suppress [constParameterPointer, unmatchedSuppression] +int fieldstat_cube_set_sampling(struct fieldstat *instance, int cube_id, enum sampling_mode mode, int max_n_cell, int primary_metric_id) { + if (max_n_cell <= 0) { + if (mode != SAMPLING_MODE_COMPREHENSIVE) { + return FS_ERR_INVALID_PARAM; + } + max_n_cell = INT32_MAX; + } + + struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); + if (cube == NULL) { + return FS_ERR_INVALID_CUBE_ID; + } + + return cube_set_sampling_mode(cube, mode, max_n_cell, primary_metric_id); +} + +int fieldstat_cube_create(struct fieldstat *instance, const struct field *cube_dimensions, size_t n_dimension) { if (instance == NULL) { return FS_ERR_NULL_HANDLER; @@ -86,14 +103,8 @@ int fieldstat_create_cube(struct fieldstat *instance, const struct field *cube_d cube_dimensions = NULL; n_dimension = 0; } - if (mode == SAMPLING_MODE_TOPK && max_n_cell == 0) { - return FS_ERR_INVALID_PARAM; - } - if (max_n_cell == 0) { - max_n_cell = INT32_MAX; - } - - struct cube *cube = cube_new(cube_dimensions, n_dimension, mode, max_n_cell); + + struct cube *cube = cube_new(cube_dimensions, n_dimension); int ret = cube_manager_add(instance->cube_manager, cube); if (ret < 0) { cube_free(cube); @@ -103,21 +114,6 @@ int fieldstat_create_cube(struct fieldstat *instance, const struct field *cube_d return ret; //ret is the cube_id } -// cppcheck-suppress [constParameterPointer, unmatchedSuppression] -int fieldstat_cube_set_primary_metric(struct fieldstat *instance, int cube_id, int metric_id) -{ - if (instance == NULL) { - return FS_ERR_NULL_HANDLER; - } - - struct cube *cube = cube_manager_get_cube_by_id(instance->cube_manager, cube_id); - if (cube == NULL) { - return FS_ERR_INVALID_CUBE_ID; - } - - return cube_set_primary_metric(cube, metric_id); -} - /* -------------------------------------------------------------------------- */ /* metric register */ /* -------------------------------------------------------------------------- */ diff --git a/src/fieldstat_easy.c b/src/fieldstat_easy.c index 00a569a..46133f4 100644 --- a/src/fieldstat_easy.c +++ b/src/fieldstat_easy.c @@ -122,7 +122,8 @@ struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const char *name, fse->fsu = malloc(sizeof(struct fs_easy_thread) * max_thread_num); fse->max_thread_num = max_thread_num; fse->delta = fieldstat_new(); - fieldstat_create_cube(fse->delta, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); + fieldstat_cube_create(fse->delta, NULL, 0); + fieldstat_cube_set_sampling(fse->delta, 0, SAMPLING_MODE_COMPREHENSIVE, 0, 0); fse->accumulate = fieldstat_fork(fse->delta); fse->exporter = fieldstat_json_exporter_new(); diff --git a/test/profiling/main.c b/test/profiling/main.c index 3af2b1a..8be10d3 100644 --- a/test/profiling/main.c +++ b/test/profiling/main.c @@ -31,7 +31,7 @@ int main () { }; struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); + fieldstat_cube_create(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); fieldstat_register_counter(instance, "counter"); start = clock(); diff --git a/test/test_empty_tags.cpp b/test/test_empty_tags.cpp index 967f8c0..8360eab 100644 --- a/test/test_empty_tags.cpp +++ b/test/test_empty_tags.cpp @@ -20,13 +20,13 @@ void assert_cell_null(const struct fieldstat *instance, int cube_id, long long e fieldstat_tag_list_arr_free(tag_list, n_cell); } - TEST(test_empty_tag, add_many_times) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 1); - + int cube_id = fieldstat_cube_create(instance, NULL, 0); int metric_id = fieldstat_register_counter(instance, cube_id, "metric"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_COMPREHENSIVE, 1, 0); + fieldstat_counter_incrby(instance, cube_id, metric_id, NULL, 0, 1); fieldstat_counter_incrby(instance, cube_id, metric_id, NULL, 0, 1); @@ -38,8 +38,10 @@ TEST(test_empty_tag, add_many_times) struct fieldstat *test_empty_my_init(enum sampling_mode mode = SAMPLING_MODE_COMPREHENSIVE) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, NULL, 0, mode, 1); + int cube_id = fieldstat_cube_create(instance, NULL, 0); int metric_id = fieldstat_register_counter(instance, cube_id, "metric"); + fieldstat_cube_set_sampling(instance, cube_id, mode, 1, 0); + fieldstat_counter_incrby(instance, cube_id, metric_id, NULL, 0, 1); return instance; @@ -97,8 +99,9 @@ TEST(test_empty_tag, merge_topk) TEST(test_empty_tag, merge_spreadsketch) { struct fieldstat *instance_src = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance_src, NULL, 0, SAMPLING_MODE_TOP_CARDINALITY, 1); + int cube_id = fieldstat_cube_create(instance_src, NULL, 0); int metric_id = fieldstat_register_hll(instance_src, cube_id, "metric", 4); + fieldstat_cube_set_sampling(instance_src, cube_id, SAMPLING_MODE_TOP_CARDINALITY, 1, 0); fieldstat_hll_add(instance_src, cube_id, metric_id, NULL, 0, "1", 1); struct fieldstat *instance_dst = fieldstat_new(); diff --git a/test/test_exporter_json.cpp b/test/test_exporter_json.cpp index 45a05cf..ebf6750 100644 --- a/test/test_exporter_json.cpp +++ b/test/test_exporter_json.cpp @@ -167,9 +167,10 @@ void topk_standard_oper(const std::function topk_add = [instance, cube_id, m1, m2](const Fieldstat_tag_list_wrapper *my_tags, unsigned int counts[TEST_METRIC_NUM]) { @@ -186,12 +187,14 @@ TEST(export_test, cjson_export_with_fixed_tag_and_many_metrics_on_one_cube_of_co // new instance struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, tag_list_num); + int cube_id = fieldstat_cube_create(instance, TEST_TAG_SHARED1, 3); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); int id_gauge = fieldstat_register_hll(instance, cube_id, "gauge", g_hll_standard->cfg.precision); int id_histogram = fieldstat_register_histogram(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_COMPREHENSIVE, tag_list_num, 0); + Fieldstat_tag_list_wrapper *fields[tag_list_num]; fill_random_tag(fields, tag_list_num); @@ -289,9 +292,11 @@ extern "C" { TEST(export_test, cjson_export_on_one_cube_of_spreadsketch_sampling) { int K = 10; struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, K); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 7); int metric_count = fieldstat_register_counter(instance, cube_id, "oper cnt"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOP_CARDINALITY, K, 0); + SpreadSketchZipfGenerator flow_generator(1.0, K * 10); for (int i = 0; i < 100000; i++) { @@ -342,11 +347,19 @@ TEST(export_test, empty_fieldstat_export_null) { fieldstat_free(instance); } +int test_fieldstat_cube_create(struct fieldstat *instance, const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, int k, int primary_metric_id=0) +{ + assert(mode == SAMPLING_MODE_COMPREHENSIVE); + int ret = fieldstat_cube_create(instance, dimensions, n_dimensions); + fieldstat_cube_set_sampling(instance, ret, mode, k, primary_metric_id); + return ret; +} + TEST(export_test, only_registered_but_not_added_export_null_with_global_tag) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); + int cube_id = test_fieldstat_cube_create(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_register_hll(instance, cube_id, "gauge", g_hll_standard->cfg.precision); fieldstat_register_histogram(instance, cube_id, "histogram", @@ -362,9 +375,9 @@ TEST(export_test, only_registered_but_not_added_export_null_with_global_tag) TEST(export_test, skip_two_empty_cube_and_export_last_one_with_global_tag) { struct fieldstat *instance = fieldstat_new(); - (void)fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); - (void)fieldstat_create_cube(instance, TEST_TAG_SHARED2, 3, SAMPLING_MODE_COMPREHENSIVE, 3); - int cube_id_3 = fieldstat_create_cube(instance, TEST_TAG_SHARED3, 1, SAMPLING_MODE_COMPREHENSIVE, 3); + (void)test_fieldstat_cube_create(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); + (void)test_fieldstat_cube_create(instance, TEST_TAG_SHARED2, 3, SAMPLING_MODE_COMPREHENSIVE, 3); + int cube_id_3 = test_fieldstat_cube_create(instance, TEST_TAG_SHARED3, 1, SAMPLING_MODE_COMPREHENSIVE, 3); (void)fieldstat_register_counter(instance, cube_id_3, "counter"); (void)fieldstat_register_hll(instance, cube_id_3, "gauge", g_hll_standard->cfg.precision); int id_histogram = fieldstat_register_histogram(instance, cube_id_3, "histogram", @@ -410,9 +423,9 @@ TEST(export_test, skip_two_empty_cube_and_export_last_one_with_global_tag) TEST(export_test, skip_empty_metrics_given_cube_deleted) { struct fieldstat *instance = fieldstat_new(); - int cube_id_del = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); - int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED2, 3, SAMPLING_MODE_COMPREHENSIVE, 3); - fieldstat_destroy_cube(instance, cube_id_del); + int cube_id_del = test_fieldstat_cube_create(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); + int cube_id = test_fieldstat_cube_create(instance, TEST_TAG_SHARED2, 3, SAMPLING_MODE_COMPREHENSIVE, 3); + fieldstat_cube_destroy(instance, cube_id_del); (void)fieldstat_register_counter(instance, cube_id, "counter"); (void)fieldstat_register_counter(instance, cube_id, "counter2"); int metric_id = fieldstat_register_counter(instance, cube_id, "counter3"); @@ -459,7 +472,7 @@ TEST(export_test, skip_empty_metrics_given_cube_deleted) { TEST(export_test, enable_delta_and_export_twice_without_new_metric) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, id_counter, &TEST_TAG_INT, 1, 1); @@ -528,7 +541,7 @@ TEST(export_test, enable_delta_and_export_twice_without_new_metric) TEST(export_test, enable_delta_and_export_twice_with_new_metric_and_omit_histogram) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); int id_histogram = fieldstat_register_histogram(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); @@ -610,7 +623,7 @@ TEST(export_test, enable_delta_and_export_twice_with_new_metric_and_omit_histogr TEST(export_test, enable_delta_and_export_three_times_skipping_cube_with_no_counter) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); int id_histogram = fieldstat_register_histogram(instance, cube_id, "histogram", g_histogram_standard->lowest_discernible_value, g_histogram_standard->highest_trackable_value, g_histogram_standard->significant_figures); @@ -719,12 +732,12 @@ void test_check_delta_for_one_json(const struct field_list *expect_cell_tag, con TEST(export_test, enable_delta_and_export_instance_with_many_cells_with_global_tags) { struct fieldstat *instance = fieldstat_new(); - int cube_id1 = fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id1 = test_fieldstat_cube_create(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 10); int id_counter1 = fieldstat_register_counter(instance, cube_id1, "counter"); fieldstat_counter_incrby(instance, cube_id1, id_counter1, &TEST_TAG_INT, 1, 11); fieldstat_counter_incrby(instance, cube_id1, id_counter1, &TEST_TAG_STRING, 1, 12); - int cube_id2 = fieldstat_create_cube(instance, TEST_TAG_SHARED3, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id2 = test_fieldstat_cube_create(instance, TEST_TAG_SHARED3, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int id_counter2 = fieldstat_register_counter(instance, cube_id2, "counter"); fieldstat_counter_incrby(instance, cube_id2, id_counter2, &TEST_TAG_INT, 1, 21); fieldstat_counter_incrby(instance, cube_id2, id_counter2, &TEST_TAG_DOUBLE, 1, 22); @@ -805,7 +818,7 @@ TEST(export_test, enable_delta_and_export_instance_with_many_cells_with_global_t void test_reset_one_round(std::function trigger_reset) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 1); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 1); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, id_counter, &TEST_TAG_INT, 1, 11); @@ -869,8 +882,8 @@ TEST(export_test, enable_delta_and_reset_on_change_exporter_tag) { TEST(export_test, enable_delta_and_reset_on_delete_cube) { auto trigger = [](struct fieldstat *instance, struct fieldstat_json_exporter *fieldstat_json_exporter) { - fieldstat_destroy_cube(instance, 0); - fieldstat_create_cube(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); + fieldstat_cube_destroy(instance, 0); + test_fieldstat_cube_create(instance, TEST_TAG_SHARED1, 3, SAMPLING_MODE_COMPREHENSIVE, 3); fieldstat_register_counter(instance, 0, "counter"); }; @@ -880,7 +893,7 @@ TEST(export_test, enable_delta_and_reset_on_delete_cube) { TEST(export_test, delta_with_two_instance_same_config) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); + int cube_id = test_fieldstat_cube_create(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, 0, id_counter, &TEST_TAG_INT, 1, 123); int id_hist = fieldstat_register_histogram(instance, cube_id, "histogram", 1, 1000, 3); @@ -920,7 +933,7 @@ TEST(export_test, delta_with_two_instance_same_config) TEST(export_test, delta_with_two_instance_one_empty) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); + int cube_id = test_fieldstat_cube_create(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); int id_counter = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, 0, id_counter, &TEST_TAG_INT, 1, 123); int id_hist = fieldstat_register_histogram(instance, cube_id, "histogram", 1, 1000, 3); @@ -959,7 +972,7 @@ TEST(export_test, delta_with_two_instance_one_empty) TEST(export_test, delta_with_two_instance_different_cell) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); + test_fieldstat_cube_create(instance, NULL, 0, SAMPLING_MODE_COMPREHENSIVE, 0); int id_counter = fieldstat_register_counter(instance, 0, "counter"); fieldstat_counter_incrby(instance, 0, id_counter, &TEST_TAG_INT, 1, 123); @@ -1022,7 +1035,7 @@ TEST(export_test, export_flat_null_with_only_global_tag) { TEST(export_test, export_flat_many_tags_many_cell) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_TAG_STRING, 1, SAMPLING_MODE_COMPREHENSIVE, 3); + int cube_id = test_fieldstat_cube_create(instance, &TEST_TAG_STRING, 1, SAMPLING_MODE_COMPREHENSIVE, 3); int metric_id = fieldstat_register_counter(instance, cube_id, "counter metric"); diff --git a/test/test_fuzz_test.cpp b/test/test_fuzz_test.cpp index 9eed5ed..aa3487a 100644 --- a/test/test_fuzz_test.cpp +++ b/test/test_fuzz_test.cpp @@ -77,11 +77,12 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ // init cube for (int i = 0; i < CUBE_NUM; i++) { shared_tags[i] = new Fieldstat_tag_list_wrapper("shared_tag", i); - int cube_id = fieldstat_create_cube(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_COMPREHENSIVE, CELL_MAX); + int cube_id = fieldstat_cube_create(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count()); EXPECT_EQ(cube_id, i); fieldstat_register_counter(master, cube_id, metric_name[METRIC_ID_COUNTER]); fieldstat_register_hll(master, cube_id, metric_name[METRIC_ID_HLL], 6); + fieldstat_cube_set_sampling(master, cube_id, SAMPLING_MODE_COMPREHENSIVE, CELL_MAX, 0); } // all the possible fields @@ -120,10 +121,12 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ Fieldstat_tag_list_wrapper *new_tag = new Fieldstat_tag_list_wrapper("shared_tag", next_shared_tag_value++); delete shared_tags[cube_id_to_change]; shared_tags[cube_id_to_change] = new_tag; - fieldstat_destroy_cube(master, cube_id_to_change); - int cube_id_new = fieldstat_create_cube(master, new_tag->get_tag(), new_tag->get_tag_count(), SAMPLING_MODE_COMPREHENSIVE, CELL_MAX); + fieldstat_cube_destroy(master, cube_id_to_change); + int cube_id_new = fieldstat_cube_create(master, new_tag->get_tag(), new_tag->get_tag_count()); fieldstat_register_counter(master, cube_id_new, metric_name[METRIC_ID_COUNTER]); fieldstat_register_hll(master, cube_id_new, metric_name[METRIC_ID_HLL], 6); + fieldstat_cube_set_sampling(master, cube_id_new, SAMPLING_MODE_COMPREHENSIVE, CELL_MAX, 0); + EXPECT_EQ(cube_id_new, cube_id_to_change); // should new the cube in the hole leaved by the destroyed cube // calibrate for (int j = 0; j < INSTANCE_NUM; j++) { @@ -220,9 +223,10 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ // init cube for (int i = 0; i < CUBE_NUM; i++) { shared_tags[i] = new Fieldstat_tag_list_wrapper("shared_tag", i); - int cube_id = fieldstat_create_cube(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_TOPK, CELL_MAX); + int cube_id = fieldstat_cube_create(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count()); EXPECT_EQ(cube_id, i); fieldstat_register_counter(master, cube_id, "topk"); + fieldstat_cube_set_sampling(master, cube_id, SAMPLING_MODE_TOPK, CELL_MAX, 0); } // all the possible fields @@ -258,9 +262,11 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ Fieldstat_tag_list_wrapper *new_tag = new Fieldstat_tag_list_wrapper("shared_tag", next_shared_tag_value++); delete shared_tags[cube_id_to_change]; shared_tags[cube_id_to_change] = new_tag; - fieldstat_destroy_cube(master, cube_id_to_change); - int cube_id_new = fieldstat_create_cube(master, new_tag->get_tag(), new_tag->get_tag_count(), SAMPLING_MODE_TOPK, CELL_MAX); + fieldstat_cube_destroy(master, cube_id_to_change); + int cube_id_new = fieldstat_cube_create(master, new_tag->get_tag(), new_tag->get_tag_count()); fieldstat_register_counter(master, cube_id_new, "topk"); + fieldstat_cube_set_sampling(master, cube_id_new, SAMPLING_MODE_TOPK, CELL_MAX, 0); + EXPECT_EQ(cube_id_new, cube_id_to_change); // should new the cube in the hole leaved by the destroyed cube // calibrate for (int j = 0; j < INSTANCE_NUM; j++) { @@ -361,9 +367,10 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ // init cube for (int i = 0; i < CUBE_NUM; i++) { shared_tags[i] = new Fieldstat_tag_list_wrapper("shared_tag", i); - int cube_id = fieldstat_create_cube(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_TOP_CARDINALITY, CELL_MAX); + int cube_id = fieldstat_cube_create(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count()); EXPECT_EQ(cube_id, i); fieldstat_register_hll(master, cube_id, "hll", 6); + fieldstat_cube_set_sampling(master, cube_id, SAMPLING_MODE_TOP_CARDINALITY, CELL_MAX, 0); } //init instance @@ -392,10 +399,12 @@ TEST(Fuzz_test, many_instance_random_flow_unregister_calibrate_reset_fork_merge_ Fieldstat_tag_list_wrapper *new_tag = new Fieldstat_tag_list_wrapper("shared_tag", next_shared_tag_value++); delete shared_tags[cube_id_to_change]; shared_tags[cube_id_to_change] = new_tag; - fieldstat_destroy_cube(master, cube_id_to_change); - int cube_id_new = fieldstat_create_cube(master, new_tag->get_tag(), new_tag->get_tag_count(), SAMPLING_MODE_TOP_CARDINALITY, CELL_MAX); + fieldstat_cube_destroy(master, cube_id_to_change); + int cube_id_new = fieldstat_cube_create(master, new_tag->get_tag(), new_tag->get_tag_count()); fieldstat_register_hll(master, cube_id_new, "hll", 6); EXPECT_EQ(cube_id_new, cube_id_to_change); // should new the cube in the hole leaved by the destroyed cube + fieldstat_cube_set_sampling(master, cube_id_new, SAMPLING_MODE_TOP_CARDINALITY, CELL_MAX, 0); + // calibrate for (int j = 0; j < INSTANCE_NUM; j++) { fieldstat_calibrate(master, replica[j]); @@ -499,9 +508,11 @@ TEST(Fuzz_test, add_and_reset_with_randomly_generated_flows_and_randomly_chosen_ struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance,NULL,0,SAMPLING_MODE_TOPK, 1); // K = 1, just to increase the possibility of FS_ERR_TOO_MANY_CELLS + int cube_id = fieldstat_cube_create(instance,NULL,0); int primary_metric_id = fieldstat_register_counter(instance, cube_id, "counter"); int counter2_id = fieldstat_register_counter(instance, cube_id, "counter2"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 1, 0); // K = 1, just to increase the possibility of FS_ERR_TOO_MANY_CELLS + fieldstat_counter_incrby(instance, cube_id, primary_metric_id, tag_list_wrapper[0]->get_tag(), tag_list_wrapper[0]->get_tag_count(), 1); fieldstat_counter_incrby(instance, cube_id, counter2_id, tag_list_wrapper[0]->get_tag(), tag_list_wrapper[0]->get_tag_count(), 1); @@ -550,9 +561,10 @@ TEST(perf, simple_one_for_perf_topk) // init cube for (int i = 0; i < CUBE_NUM; i++) { shared_tags[i] = new Fieldstat_tag_list_wrapper("shared_tag", i); - int cube_id = fieldstat_create_cube(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count(), SAMPLING_MODE_TOPK, CELL_MAX); + int cube_id = fieldstat_cube_create(master, shared_tags[i]->get_tag(), shared_tags[i]->get_tag_count()); EXPECT_EQ(cube_id, i); fieldstat_register_counter(master, cube_id, "topk"); + fieldstat_cube_set_sampling(master, cube_id, SAMPLING_MODE_TOPK, CELL_MAX, 0); } // init metric @@ -598,8 +610,9 @@ TEST(perf, simple_one_for_perf_spreadsketch) const int TEST_ROUND = 500000; struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_TAG_STRING, 1, SAMPLING_MODE_TOP_CARDINALITY, CELL_MAX); + int cube_id = fieldstat_cube_create(instance, &TEST_TAG_STRING, 1); fieldstat_register_hll(instance, cube_id, "hll", 6); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOP_CARDINALITY, CELL_MAX, 0); SpreadSketchZipfGenerator generator(1.0, CELL_MAX * 10); Fieldstat_tag_list_wrapper *cell_dimension[TEST_ROUND]; diff --git a/test/test_merge.cpp b/test/test_merge.cpp index 6e8f802..5024cff 100644 --- a/test/test_merge.cpp +++ b/test/test_merge.cpp @@ -46,15 +46,23 @@ double merge_test_fieldstat_hll_get(const struct fieldstat *instance, int cube_i return ret; } +int test_fieldstat_cube_create(struct fieldstat *instance, const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, int k, int primary_metric_id=0) +{ + assert(mode == SAMPLING_MODE_COMPREHENSIVE); + int ret = fieldstat_cube_create(instance, dimensions, n_dimensions); + fieldstat_cube_set_sampling(instance, ret, mode, k, primary_metric_id); + return ret; +} + TEST(unit_test_merge, cube_shared_tag_mapping_with_new_cube) { struct fieldstat *instance = fieldstat_new(); - (void)fieldstat_create_cube(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int cube_id2 = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + (void)test_fieldstat_cube_create(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id2 = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_counter(instance,cube_id2,"metric in cube 2"); fieldstat_counter_incrby(instance, cube_id2, metric_id, &TEST_TAG_STRING, 1, 1); struct fieldstat *instance_dest = fieldstat_new(); - int cube_id_dest = fieldstat_create_cube(instance_dest, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id_dest = test_fieldstat_cube_create(instance_dest, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_merge(instance_dest, instance); @@ -87,7 +95,7 @@ TEST(unit_test_merge, empty_instance) TEST(unit_test_merge, new_cube_and_metric_to_empty_comprehensive) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + test_fieldstat_cube_create(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_register_counter(instance, 0, "metric_name"); struct fieldstat *instance_dest = fieldstat_new(); @@ -108,7 +116,7 @@ TEST(unit_test_merge, new_cube_and_metric_to_empty_comprehensive) TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_comprehensive) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_counter(instance, 0, "metric_name"); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -140,7 +148,7 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_comprehensive) TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_comprehensive) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_counter(instance, cube_id, "metric_name"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, 5); struct fieldstat *instance_dest = fieldstat_new(); @@ -159,7 +167,7 @@ TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_comprehens TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_and_get_different_cube_comprehensive) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 2); // limit is 2 + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 2); // limit is 2 int metric_id = fieldstat_register_counter(instance, cube_id, "metric name"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, 1); struct fieldstat *instance_dest = fieldstat_new(); @@ -187,7 +195,7 @@ TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_a TEST(unit_test_merge, new_too_many_cells_on_multiple_metric_given_source_cube_reset_and_get_different_cube_comprehensive) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 2); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 2); int metric_id1 = fieldstat_register_counter(instance, cube_id, "metric name1"); int metric_id2 = fieldstat_register_counter(instance, cube_id, "metric name2"); fieldstat_counter_incrby(instance, cube_id, metric_id1, &TEST_TAG_STRING, 1, 1); // 1st cell on metric name1 @@ -222,8 +230,9 @@ TEST(unit_test_merge, new_too_many_cells_on_multiple_metric_given_source_cube_re TEST(unit_test_merge, new_cube_and_metric_to_empty_topk) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_TOPK, 10); + fieldstat_cube_create(instance, &TEST_TAG_INT, 1); fieldstat_register_counter(instance, 0, "metric_name"); + fieldstat_cube_set_sampling(instance, 0, SAMPLING_MODE_TOPK, 10, 0); struct fieldstat *instance_dest = fieldstat_new(); @@ -243,8 +252,9 @@ TEST(unit_test_merge, new_cube_and_metric_to_empty_topk) TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_topk) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_counter(instance, cube_id, "metric_name"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 10, 0); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -275,8 +285,9 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_topk) TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_topk) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_counter(instance, cube_id, "metric_name"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 10, 0); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, 5); struct fieldstat *instance_dest = fieldstat_new(); @@ -306,8 +317,9 @@ TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_topk) TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_and_get_different_cube_topk) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 2); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_counter(instance, cube_id, "metric name"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 2, 0); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, 1); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -334,8 +346,9 @@ TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_a struct fieldstat *topk_test_push_flows(vector &flows_in_test, int K, long long count = 1) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, K); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_counter(instance, cube_id, "metric name"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, K, 0); for (size_t i = 0; i < flows_in_test.size(); i++) { fieldstat_counter_incrby(instance, cube_id, metric_id, flows_in_test[i]->get_tag(), flows_in_test[i]->get_tag_count(), count); } @@ -449,9 +462,10 @@ TEST(unit_test_merge, merge_accuracy_test_gen_dest_full_some_inserted_and_some_m TEST(unit_test_merge, primary_metric_has_no_value) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 2); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_primary = fieldstat_register_counter(instance, cube_id, "primary"); int metric_operated = fieldstat_register_counter(instance, cube_id, "operated"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 2, metric_primary); fieldstat_counter_incrby(instance, cube_id, metric_operated, &TEST_TAG_STRING, 1, 1); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -474,17 +488,19 @@ TEST(unit_test_merge, primary_metric_has_no_value) TEST(unit_test_merge, primary_metric_id_different) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 2); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_primary = fieldstat_register_counter(instance, cube_id, "primary"); int metric_2 = fieldstat_register_counter(instance, cube_id, "2"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 2, metric_primary); + fieldstat_counter_incrby(instance, cube_id, metric_primary, &TEST_TAG_STRING, 1, 100); fieldstat_counter_incrby(instance, cube_id, metric_2, &TEST_TAG_STRING, 1, 1); struct fieldstat *instance_dst = fieldstat_new(); - int cube_id_dst = fieldstat_create_cube(instance_dst, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 2); + int cube_id_dst = fieldstat_cube_create(instance_dst, &TEST_SHARED_TAG, 1); fieldstat_register_counter(instance_dst, cube_id_dst, "2"); int metric_primary_dst = fieldstat_register_counter(instance_dst, cube_id_dst, "primary"); - fieldstat_cube_set_primary_metric(instance_dst, cube_id_dst, metric_primary_dst); + fieldstat_cube_set_sampling(instance_dst, cube_id_dst, SAMPLING_MODE_TOPK, 2, metric_primary_dst); EXPECT_EQ(fieldstat_merge(instance_dst, instance), FS_ERR_INVALID_PARAM); @@ -494,8 +510,9 @@ TEST(unit_test_merge, primary_metric_id_different) TEST(unit_test_merge, new_cube_and_metric_to_empty_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_TOP_CARDINALITY, 10); + fieldstat_cube_create(instance, &TEST_TAG_INT, 1); fieldstat_register_hll(instance, 0, "metric", 6); + fieldstat_cube_set_sampling(instance, 0, SAMPLING_MODE_TOP_CARDINALITY, 10, 0); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -513,8 +530,9 @@ TEST(unit_test_merge, new_cube_and_metric_to_empty_spreadsketch) { TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 6); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOP_CARDINALITY, 10, 0); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -545,8 +563,9 @@ TEST(unit_test_merge, new_cell_on_existing_cube_and_metric_spreadsketch) { TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 6); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOP_CARDINALITY, 10, 0); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, "1", 1); struct fieldstat *instance_dest = fieldstat_new(); @@ -569,8 +588,9 @@ TEST(unit_test_merge, merge_existing_cell_on_existing_cube_and_metric_spreadsket TEST(unit_test_merge, new_too_many_cells_on_one_metric_given_source_cube_reset_and_get_different_cube_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 2); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_hll(instance, cube_id, "metric", 6); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOP_CARDINALITY, 2, 0); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_STRING, 1, "1", 1); struct fieldstat *instance_dest = fieldstat_new(); fieldstat_merge(instance_dest, instance); @@ -602,8 +622,9 @@ TEST(unit_test_merge, gen_dest_full_all_src_inserted_given_src_flows_larger_spre int K = 100; SpreadSketchZipfGenerator flow_generator(1.0, K); // exactly the number of cells, so there will be almost all(in case of hash collision happen) cells added successfully struct fieldstat *instance_src = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance_src, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, K); + int cube_id = fieldstat_cube_create(instance_src, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_hll(instance_src, cube_id, "metric", 6); + fieldstat_cube_set_sampling(instance_src, cube_id, SAMPLING_MODE_TOP_CARDINALITY, K, 0); struct fieldstat *instance_dest = fieldstat_fork(instance_src); const char dest_key[] = "key of dest"; const char src_key[] = "key of src"; @@ -660,8 +681,9 @@ TEST(unit_test_merge, merge_accuracy_test_gen_dest_full_some_inserted_and_some_m int K = 10; SpreadSketchZipfGenerator flow_generator(1.0, K * 10); struct fieldstat *instance_src = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance_src, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, K); + int cube_id = fieldstat_cube_create(instance_src, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_hll(instance_src, cube_id, "metric", 6); + fieldstat_cube_set_sampling(instance_src, cube_id, SAMPLING_MODE_TOP_CARDINALITY, K, 0); struct fieldstat *instance_dest = fieldstat_fork(instance_src); std::unordered_map> flow_cnt; @@ -699,7 +721,7 @@ TEST(unit_test_merge, merge_accuracy_test_gen_dest_full_some_inserted_and_some_m expected_unique_cnt[kv.first] = kv.second.size(); } double recall = test_cal_topk_accuracy(test_result, expected_unique_cnt); - EXPECT_GT(recall, 0.7); + EXPECT_GE(recall, 0.7); printf("gen_dest_full_all_src_inserted_given_src_flows_larger_spreadsketch recall is %lf\n", recall); fieldstat_free(instance_src); diff --git a/test/test_metric_counter.cpp b/test/test_metric_counter.cpp index d8ce16c..4c30b78 100644 --- a/test/test_metric_counter.cpp +++ b/test/test_metric_counter.cpp @@ -7,15 +7,18 @@ using namespace std; + struct fieldstat *test_init_standard_instance() { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); EXPECT_EQ(cube_id, 0); int metric_id = fieldstat_register_counter(instance, cube_id, "czz_test counter metric"); EXPECT_EQ(metric_id, 0); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_COMPREHENSIVE, 10, 0); + return instance; } @@ -26,6 +29,14 @@ long long my_fieldstat_counter_get(const struct fieldstat *instance, int cube_id return ret; } +int test_fieldstat_cube_create(struct fieldstat *instance, const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, int k, int primary_metric_id=0) +{ + assert(mode == SAMPLING_MODE_COMPREHENSIVE); + int ret = fieldstat_cube_create(instance, dimensions, n_dimensions); + fieldstat_cube_set_sampling(instance, ret, mode, k, primary_metric_id); + return ret; +} + void test_assert_standard_instance(const struct fieldstat *instance) { int *ret_cube_id_arr = NULL; @@ -110,8 +121,9 @@ TEST(metric_test_counter, merge_counter_twice_with_reset) TEST(metric_test_counter, topk_add_and_test_accuracy) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_TOPK, 10); + fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1); fieldstat_register_counter(instance, 0, "test"); + fieldstat_cube_set_sampling(instance, 0, SAMPLING_MODE_TOPK, 10, 0); int tag_list_num = 10000; Fieldstat_tag_list_wrapper *fields[tag_list_num]; @@ -165,7 +177,7 @@ TEST(metric_test_counter, topk_add_and_test_accuracy) TEST(metric_test_counter, add_with_wrong_cube_id_expecting_fail) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_TOPK, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int ret = fieldstat_counter_incrby(instance, cube_id + 1, 0, &TEST_TAG_INT, 1, 1); EXPECT_EQ(ret, FS_ERR_INVALID_CUBE_ID); @@ -178,7 +190,7 @@ TEST(metric_test_counter, add_with_wrong_cube_id_expecting_fail) TEST(metric_test_counter, add_with_wrong_metric_id_expecting_fail) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_TOPK, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_counter(instance, 0, "test"); int ret = fieldstat_counter_incrby(instance, cube_id, metric_id + 1, &TEST_TAG_INT, 1, 1); @@ -192,9 +204,10 @@ TEST(metric_test_counter, add_with_wrong_metric_id_expecting_fail) TEST(metric_test_counter, add_and_query_on_dummy_cell_of_topk) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); fieldstat_register_counter(instance, cube_id, "primary"); // also the dummy one int metric_id = fieldstat_register_counter(instance, cube_id, "using"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 10, 0); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); @@ -208,11 +221,10 @@ TEST(metric_test_counter, add_and_query_on_dummy_cell_of_topk) TEST(metric_test_counter, primary_counter_add_after_first) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id_primary = fieldstat_register_counter(instance, cube_id, "primary"); int metric_id2 = fieldstat_register_counter(instance, cube_id, "using"); - fieldstat_cube_set_primary_metric(instance, cube_id, metric_id_primary); - + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 10, metric_id_primary); int ret = fieldstat_counter_incrby(instance, cube_id, metric_id2, &TEST_TAG_INT, 1, 10); EXPECT_EQ(ret, FS_OK); diff --git a/test/test_metric_histogram.cpp b/test/test_metric_histogram.cpp index 3a28aa3..3ef171c 100644 --- a/test/test_metric_histogram.cpp +++ b/test/test_metric_histogram.cpp @@ -6,10 +6,18 @@ #include "hdr/hdr_histogram.h" #include "histogram_encoder.h" +int test_fieldstat_cube_create(struct fieldstat *instance, const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, int k) +{ + assert(mode == SAMPLING_MODE_COMPREHENSIVE); + int ret = fieldstat_cube_create(instance, dimensions, n_dimensions); + fieldstat_cube_set_sampling(instance, ret, mode, k, 0); + return ret; +} + struct fieldstat *test_init_standard_instance_one_cube_one_metric_one_cell_hdr() { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, 0); int metric_id = fieldstat_register_histogram(instance, cube_id, "czz_test hdr metric", 1, 600000, 3); @@ -107,7 +115,7 @@ TEST(metric_test_histogram, merge_twice_with_reset) TEST(metric_test_histogram, add_with_wrong_cube_id_expecting_fail) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int ret = fieldstat_histogram_record(instance, cube_id + 1, 0, &TEST_TAG_INT, 1, 1); EXPECT_EQ(ret, FS_ERR_INVALID_CUBE_ID); @@ -120,7 +128,7 @@ TEST(metric_test_histogram, add_with_wrong_cube_id_expecting_fail) TEST(metric_test_histogram, add_with_wrong_metric_id_expecting_fail) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_histogram(instance, cube_id, "czz_test", 1, 600000, 3); int ret = fieldstat_histogram_record(instance, cube_id, metric_id + 1, &TEST_TAG_INT, 1, 1); @@ -169,7 +177,7 @@ TEST(metric_test_histogram, encode_decode_b64) TEST(metric_test_histogram, can_add_0value) // histogram only allow min_val > 0, but it can accept value == 0 { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_histogram(instance, cube_id, "czz_test", 1, 600000, 3); int ret = fieldstat_histogram_record(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 0); diff --git a/test/test_metric_hll.cpp b/test/test_metric_hll.cpp index 204c762..713c00d 100644 --- a/test/test_metric_hll.cpp +++ b/test/test_metric_hll.cpp @@ -8,10 +8,18 @@ #include "fieldstat.h" #include "utils.hpp" +int test_fieldstat_cube_create(struct fieldstat *instance, const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, int k) +{ + assert(mode == SAMPLING_MODE_COMPREHENSIVE); + int ret = fieldstat_cube_create(instance, dimensions, n_dimensions); + fieldstat_cube_set_sampling(instance, ret, mode, k, 0); + return ret; +} + struct fieldstat *test_init_standard_instance_one_cube_one_metric_one_cell_hll(bool is_gauge = false) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, 0); int metric_id = fieldstat_register_hll(instance, cube_id, "czz_test hll metric", 10); @@ -198,7 +206,7 @@ TEST(metric_test_hll, serialize_with_b64_and_query_with_python_api) TEST(metric_test_hll, add_with_wrong_cube_id_expecting_fail) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int ret = fieldstat_hll_add(instance, cube_id + 1, 0, &TEST_TAG_INT, 1, "hello", 5); EXPECT_EQ(ret, FS_ERR_INVALID_CUBE_ID); @@ -211,7 +219,7 @@ TEST(metric_test_hll, add_with_wrong_cube_id_expecting_fail) TEST(metric_test_hll, add_with_wrong_metric_id_expecting_fail) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_hll(instance, cube_id, "czz_test hll metric", 10); int ret = fieldstat_hll_add(instance, cube_id, metric_id + 1, &TEST_TAG_INT, 1, "hello", 5); @@ -226,8 +234,9 @@ TEST(metric_test_hll, spread_sketch_add_and_test_accuracy) { struct fieldstat *instance = fieldstat_new(); int K = 10; - fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_TOP_CARDINALITY, K); + fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1); fieldstat_register_hll(instance, 0, "testss", 6); + fieldstat_cube_set_sampling(instance, 0, SAMPLING_MODE_TOP_CARDINALITY, K, 0); int n_flows = 100000; std::unordered_map> flow_cnt; diff --git a/test/test_performance.cpp b/test/test_performance.cpp index b1ada45..d0ca633 100644 --- a/test/test_performance.cpp +++ b/test/test_performance.cpp @@ -6,6 +6,15 @@ #include "fieldstat_exporter.h" #include "utils.hpp" + +int test_fieldstat_cube_create(struct fieldstat *instance, const struct field *tag, size_t tag_count, enum sampling_mode mode, int k, int primary_metric_id=0) +{ + int ret = fieldstat_cube_create(instance, tag, tag_count); + fieldstat_cube_set_sampling(instance, ret, mode, k, primary_metric_id); + return ret; +} + + // /* -------------------------------------------------------------------------- */ // /* merge */ // /* -------------------------------------------------------------------------- */ @@ -18,8 +27,9 @@ double perform_merge_test(std::functionget_tag(), 1); } @@ -163,11 +173,13 @@ struct fieldstat *construct_fs_with_many_empty_cubes(int cube_num, int metric_nu struct field tmp_tag = TEST_TAG_INT; for (int i = 0; i < cube_num; i++) { tmp_tag.value_longlong = i; - int cube_id = fieldstat_create_cube(instance, &tmp_tag, 1, mode, 1000); + int cube_id = fieldstat_cube_create(instance, &tmp_tag, 1); for (int j = 0; j < metric_num; j++) { fieldstat_register_counter(instance, cube_id, std::to_string(j).c_str()); } + + fieldstat_cube_set_sampling(instance, cube_id, mode, 1000, 0); } return instance; } @@ -219,7 +231,7 @@ TEST(test_performance, performance_test_add_cells_comprehensive) } // getchar(); struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, cell_count); + test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, cell_count); fieldstat_register_counter(instance, 0, "test"); clock_t start = clock(); @@ -246,8 +258,9 @@ TEST(test_performance, performance_test_add_cells_topk) fields[i].value_longlong = rand() % 1000; } struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_TOPK, 1000); + fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1); fieldstat_register_counter(instance, 0, "test"); + fieldstat_cube_set_sampling(instance, 0, SAMPLING_MODE_TOPK, 1000, 0); // getchar(); clock_t start = clock(); @@ -267,7 +280,7 @@ TEST(test_performance, performance_test_add_cells_topk) TEST(test_performance, performance_test_add_cells_histogram_record) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_register_histogram(instance, 0, "test", 1, 100000, 3); size_t test_num = 100000; long long vals[test_num]; @@ -288,7 +301,7 @@ TEST(test_performance, performance_test_add_cells_histogram_record) TEST(test_performance, performance_test_add_cells_hll_add) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_register_hll(instance, 0, "test", 6); size_t test_num = 100000; std::string vals[test_num]; @@ -325,7 +338,7 @@ TEST(test_performance, performance_test_add_cells_comprehensive_5_tags) } // getchar(); struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, cell_count); + test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, cell_count); fieldstat_register_counter(instance, 0, "test"); clock_t start = clock(); @@ -346,7 +359,7 @@ TEST(test_performance, performance_test_add_cells_comprehensive_5_tags) TEST(test_performance, performance_test_add_cells_histogram_record_5tags) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_register_histogram(instance, 0, "test", 1, 100000, 3); size_t test_num = 100000; long long vals[test_num]; @@ -374,7 +387,7 @@ TEST(test_performance, performance_test_add_cells_histogram_record_5tags) TEST(test_performance, performance_test_add_cells_hll_add_5tags) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + test_fieldstat_cube_create(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_register_hll(instance, 0, "test", 6); size_t test_num = 100000; std::string vals[test_num]; @@ -419,7 +432,7 @@ TEST(test_performance, export_many_cells) struct fieldstat *instance = fieldstat_new(); for (int i = 0; i < CUBE_NUM; i++) { Fieldstat_tag_list_wrapper cube_tag("shared key", i); - int cube_id = fieldstat_create_cube(instance, cube_tag.get_tag(), cube_tag.get_tag_count(), SAMPLING_MODE_COMPREHENSIVE, MAX_CELL_NUM); + int cube_id = test_fieldstat_cube_create(instance, cube_tag.get_tag(), cube_tag.get_tag_count(), SAMPLING_MODE_COMPREHENSIVE, MAX_CELL_NUM); for (int j = 0; j < METRIC_NUM; j++) { string metric_name = "metric name" + to_string(i) + to_string(j); @@ -493,10 +506,10 @@ TEST(test_performance, callibrate_unchanged) fieldstat_free(instance_dest); } -struct fieldstat *construct_fs_with_many_cells(int cell_num, enum sampling_mode mode) +struct fieldstat *construct_fs_with_many_cells(int cell_num) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_TAG_INT, 1, mode, cell_num); + test_fieldstat_cube_create(instance, &TEST_TAG_INT, 1, SAMPLING_MODE_COMPREHENSIVE, cell_num); fieldstat_register_counter(instance, 0, "test"); struct field tmp_tag = TEST_TAG_INT; for (int i = 0; i < cell_num; i++) { @@ -509,7 +522,7 @@ struct fieldstat *construct_fs_with_many_cells(int cell_num, enum sampling_mode TEST(test_performance, reset_many_cells) { - struct fieldstat *instance = construct_fs_with_many_cells(1000, SAMPLING_MODE_COMPREHENSIVE); // many empty cubes, 10 metrics is a common case + struct fieldstat *instance = construct_fs_with_many_cells(1000); // many empty cubes, 10 metrics is a common case clock_t start = clock(); fieldstat_reset(instance); clock_t end = clock(); diff --git a/test/test_register_and_reset.cpp b/test/test_register_and_reset.cpp index 31f57ba..380b156 100644 --- a/test/test_register_and_reset.cpp +++ b/test/test_register_and_reset.cpp @@ -3,13 +3,20 @@ #include "fieldstat.h" #include "utils.hpp" +int test_fieldstat_cube_create(struct fieldstat *instance, const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, int k) +{ + assert(mode == SAMPLING_MODE_COMPREHENSIVE); + int ret = fieldstat_cube_create(instance, dimensions, n_dimensions); + fieldstat_cube_set_sampling(instance, ret, mode, k, 0); + return ret; +} TEST(test_register, delete_cube_and_register_and_origin_position) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_destroy_cube(instance, cube_id); - cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + fieldstat_cube_destroy(instance, cube_id); + cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, 0); EXPECT_EQ(fieldstat_find_cube(instance, &TEST_SHARED_TAG, 1) , 0); fieldstat_free(instance); @@ -18,11 +25,11 @@ TEST(test_register, delete_cube_and_register_and_origin_position) TEST(test_register, delete_comprehensive_cube_with_cells_and_metrics) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); - fieldstat_destroy_cube(instance, cube_id); + fieldstat_cube_destroy(instance, cube_id); struct field_list *tag_list = fieldstat_cube_get_tags(instance, cube_id); EXPECT_EQ(tag_list, nullptr); @@ -35,11 +42,12 @@ TEST(test_register, delete_comprehensive_cube_with_cells_and_metrics) TEST(test_register, delete_topk_cube_with_cells_and_metrics) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 10, metric_id); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); - fieldstat_destroy_cube(instance, cube_id); + fieldstat_cube_destroy(instance, cube_id); struct field_list *tag_list = fieldstat_cube_get_tags(instance, cube_id); EXPECT_EQ(tag_list, nullptr); int cube_id_ret = fieldstat_find_cube(instance, &TEST_SHARED_TAG, 1); @@ -51,14 +59,15 @@ TEST(test_register, delete_topk_cube_with_cells_and_metrics) TEST(test_register, delete_spreadsketch_cube_with_cells_and_metrics) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id1 = fieldstat_register_counter(instance, cube_id, "counter"); int metric_primary = fieldstat_register_hll(instance, cube_id, "hll_primary", 5); - fieldstat_cube_set_primary_metric(instance, cube_id, metric_primary); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOP_CARDINALITY, 10, metric_primary); + fieldstat_counter_incrby(instance, cube_id, metric_id1, &TEST_TAG_INT, 1, 1); fieldstat_hll_add_field(instance, cube_id, metric_primary, &TEST_TAG_INT, 1, &TEST_TAG_DOUBLE, 1); - fieldstat_destroy_cube(instance, cube_id); + fieldstat_cube_destroy(instance, cube_id); struct field_list *tag_list = fieldstat_cube_get_tags(instance, cube_id); EXPECT_EQ(tag_list, nullptr); int cube_id_ret = fieldstat_find_cube(instance, &TEST_SHARED_TAG, 1); @@ -67,7 +76,6 @@ TEST(test_register, delete_spreadsketch_cube_with_cells_and_metrics) fieldstat_free(instance); } - int test_get_max_metric_id(const struct fieldstat *instance) { int *metric_id_out; @@ -80,7 +88,7 @@ int test_get_max_metric_id(const struct fieldstat *instance) TEST(test_register, reset_and_try_to_query_cell_comprehensive) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); @@ -99,8 +107,10 @@ TEST(test_register, reset_and_try_to_query_cell_comprehensive) TEST(test_register, reset_and_try_to_query_cell_topk) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 10, metric_id); + fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); fieldstat_reset(instance); @@ -118,8 +128,9 @@ TEST(test_register, reset_and_try_to_query_cell_topk) TEST(test_register, reset_and_try_to_query_cell_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 10); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_hll(instance, cube_id, "hll", 5); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOP_CARDINALITY, 10, metric_id); fieldstat_hll_add(instance, cube_id, metric_id, &TEST_TAG_INT, 1, "12abc", 5); fieldstat_reset(instance); @@ -137,7 +148,7 @@ TEST(test_register, reset_and_try_to_query_cell_spreadsketch) TEST(test_register, reset_and_new_cell_comprehensive) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 2); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 2); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, 1); @@ -154,8 +165,9 @@ TEST(test_register, reset_and_new_cell_comprehensive) TEST(test_register, reset_and_new_cell_topk) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 1); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, 1, metric_id); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 100);//100: bigger value int ret = fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_DOUBLE, 1, 1); EXPECT_EQ(ret, FS_ERR_TOO_MANY_CELLS); @@ -170,8 +182,9 @@ TEST(test_register, reset_and_new_cell_topk) TEST(test_register, reset_and_new_cell_spreadsketch) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, 1); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_hll(instance, cube_id, "hll", 5); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOP_CARDINALITY, 1, metric_id); // spread sketch will store more data than expected cell number 1. So loop for many cells first to trigger the error struct field test_tag_long = TEST_TAG_INT; for (int i = 0; i < 10000; i++) { @@ -191,7 +204,7 @@ TEST(test_register, reset_and_new_cell_spreadsketch) TEST(test_register, ensure_recovery_more_faster_comprehensive) { struct fieldstat *instance = fieldstat_new(); int cell_num = 1000; - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, cell_num); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, cell_num); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); struct field test_tag_long = TEST_TAG_INT; @@ -221,8 +234,10 @@ TEST(test_register, ensure_recovery_more_faster_comprehensive) { TEST(test_register, ensure_recovery_more_faster_topk) { struct fieldstat *instance = fieldstat_new(); int cell_num = 1000; - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, cell_num); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOPK, cell_num, metric_id); + struct field test_tag_long = TEST_TAG_INT; clock_t start = clock(); @@ -251,8 +266,9 @@ TEST(test_register, ensure_recovery_more_faster_topk) { TEST(test_register, ensure_recovery_more_faster_spreadsketch) { struct fieldstat *instance = fieldstat_new(); int cell_num = 1000; - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOP_CARDINALITY, cell_num); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); int metric_id = fieldstat_register_hll(instance, cube_id, "counter", 6); + fieldstat_cube_set_sampling(instance, cube_id, SAMPLING_MODE_TOP_CARDINALITY, cell_num, metric_id); struct field test_tag_long = TEST_TAG_INT; clock_t start = clock(); @@ -285,7 +301,7 @@ TEST(test_register, register_many_cubes) struct field shared_tag = TEST_SHARED_TAG; for (int i = 0; i < registered_cube; i++) { shared_tag.value_longlong = i; - int cube_id = fieldstat_create_cube(instance, &shared_tag, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &shared_tag, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, i); fieldstat_register_counter(instance, cube_id, "counter"); } @@ -306,7 +322,7 @@ TEST(test_register, register_many_cubes) TEST(test_register, add_many_tagged_cells) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); size_t n_field = 1000; struct field test_tag_long[n_field]; for (size_t i = 0; i < n_field; i++) { @@ -327,7 +343,7 @@ TEST(test_register, add_many_tagged_cells) TEST(test_register, add_long_tagged_cells) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); struct field test_tag_long = TEST_TAG_STRING; char *long_string = (char *)malloc(5001); memset(long_string, 'a', 5001); @@ -349,7 +365,7 @@ TEST(test_register, add_long_tagged_cells) TEST(test_register, register_many_metrics) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = 0; for (int i = 0; i < 200; i++) { metric_id = fieldstat_register_counter(instance, cube_id, (std::string("counter ") + std::to_string(i)).c_str()); @@ -381,13 +397,13 @@ TEST(test_register, fork_registered_info_from_empty_one) TEST(test_register, fork_registered_info_with_cube_and_metric) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); int metric_id2 = fieldstat_register_counter(instance, cube_id, "counter2"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); - int cube_id_del = fieldstat_create_cube(instance, &TEST_FIELD_VALUE_DOUBLE_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_create_cube(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - fieldstat_destroy_cube(instance, cube_id_del); + int cube_id_del = test_fieldstat_cube_create(instance, &TEST_FIELD_VALUE_DOUBLE_collided, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + test_fieldstat_cube_create(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + fieldstat_cube_destroy(instance, cube_id_del); struct fieldstat *dup = fieldstat_fork(instance); @@ -423,8 +439,8 @@ TEST(test_register, unregister_cube_on_wrong_instance) struct fieldstat *instance = fieldstat_new(); struct fieldstat *instance_dst = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); - int cube_id2 = fieldstat_create_cube(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id2 = test_fieldstat_cube_create(instance, &TEST_TAG_DOUBLE, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); int metric_id2 = fieldstat_register_counter(instance, cube_id2, "counter2"); fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); @@ -432,7 +448,7 @@ TEST(test_register, unregister_cube_on_wrong_instance) fieldstat_merge(instance_dst, instance); - fieldstat_destroy_cube(instance_dst, 0); + fieldstat_cube_destroy(instance_dst, 0); int *cube_ids; int cube_num; @@ -457,7 +473,7 @@ TEST(test_register, unregister_cube_on_wrong_instance) TEST(test_register, register_many_cells_on_unlimited_sized_cube) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 0); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 0); int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); struct field test_tag = {"abc", FIELD_VALUE_INTEGER, {.value_longlong = 0}}; for (int i = 0; i < 10000; i++) { @@ -478,15 +494,15 @@ TEST(test_register, register_many_cells_on_unlimited_sized_cube) TEST(test_register, register_cube_twice) { struct fieldstat *instance = fieldstat_new(); - fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); - int cube_id2 = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); + test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id2 = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id2, FS_ERR_INVALID_KEY); fieldstat_free(instance); } TEST(test_register, find_cube) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); int find_cube_id = fieldstat_find_cube(instance, &TEST_SHARED_TAG, 1); EXPECT_EQ(cube_id, find_cube_id); @@ -498,7 +514,7 @@ TEST(test_register, find_cube) { TEST(test_register, register_metric_twice) { struct fieldstat *instance = fieldstat_new(); - int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_register_counter(instance, cube_id, "counter"); int metric_id2 = fieldstat_register_counter(instance, cube_id, "counter"); @@ -506,10 +522,20 @@ TEST(test_register, register_metric_twice) { fieldstat_free(instance); } +TEST(test_register, add_on_uninitialized_cube) { + struct fieldstat *instance = fieldstat_new(); + int cube_id = fieldstat_cube_create(instance, &TEST_SHARED_TAG, 1); + int metric_id = fieldstat_register_counter(instance, cube_id, "counter"); + // fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1); + EXPECT_DEATH(fieldstat_counter_incrby(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 1), ".*"); + + fieldstat_free(instance); +} + TEST(calibrate, target_one_more_metric) { struct fieldstat *master = fieldstat_new(); - int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_register_counter(master, cube_id, "counter"); struct fieldstat *target = fieldstat_fork(master); EXPECT_EQ(fieldstat_register_counter(target, cube_id, "counter2"), 1); @@ -529,7 +555,7 @@ TEST(calibrate, target_one_more_metric) TEST(calibrate, master_one_more_metric) { struct fieldstat *master = fieldstat_new(); - int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_register_counter(master, cube_id, "counter"); struct fieldstat *target = fieldstat_fork(master); EXPECT_EQ(fieldstat_register_counter(master, cube_id, "counter2"), 1); @@ -551,7 +577,7 @@ TEST(calibrate, master_one_more_metric) TEST(calibrate, different_metric) { struct fieldstat *master = fieldstat_new(); - int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_register_counter(master, cube_id, "counter"); struct fieldstat *target = fieldstat_fork(master); EXPECT_EQ(fieldstat_register_counter(target, cube_id, "counter2"), 1); @@ -573,10 +599,10 @@ TEST(calibrate, different_metric) TEST(calibrate, target_more_cube) { struct fieldstat *master = fieldstat_new(); - int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_register_counter(master, cube_id, "counter"); struct fieldstat *target = fieldstat_fork(master); - int cube_id2 = fieldstat_create_cube(target, &TEST_TAG_STRING, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id2 = test_fieldstat_cube_create(target, &TEST_TAG_STRING, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id2, 1); fieldstat_register_counter(target, cube_id, "counter2"); @@ -605,9 +631,9 @@ TEST(calibrate, target_more_cube) TEST(calibrate, master_more_cube) { struct fieldstat *master = fieldstat_new(); - int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); struct fieldstat *target = fieldstat_fork(master); - int cube_id2 = fieldstat_create_cube(master, &TEST_TAG_STRING, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id2 = test_fieldstat_cube_create(master, &TEST_TAG_STRING, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_calibrate(master, target); @@ -636,10 +662,10 @@ TEST(calibrate, master_more_cube) TEST(calibrate, master_change_cube) { struct fieldstat *master = fieldstat_new(); - int cube_id = fieldstat_create_cube(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(master, &TEST_SHARED_TAG, 1, SAMPLING_MODE_COMPREHENSIVE, 10); struct fieldstat *target = fieldstat_fork(master); - fieldstat_destroy_cube(master, cube_id); - fieldstat_create_cube(master, &TEST_TAG_STRING, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + fieldstat_cube_destroy(master, cube_id); + test_fieldstat_cube_create(master, &TEST_TAG_STRING, 1, SAMPLING_MODE_COMPREHENSIVE, 10); fieldstat_calibrate(master, target); @@ -660,14 +686,14 @@ TEST(calibrate, master_many_cube) struct field shared_tag = TEST_SHARED_TAG; for (int i = 0; i < registered_cube; i++) { shared_tag.value_longlong = i; - int cube_id = fieldstat_create_cube(master, &shared_tag, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(master, &shared_tag, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, i); } struct fieldstat *target = fieldstat_fork(master); int new_registered = 5000; for (int i = 0; i < new_registered; i++) { shared_tag.value_longlong = i + registered_cube; - int cube_id = fieldstat_create_cube(master, &shared_tag, 1, SAMPLING_MODE_COMPREHENSIVE, 10); + int cube_id = test_fieldstat_cube_create(master, &shared_tag, 1, SAMPLING_MODE_COMPREHENSIVE, 10); EXPECT_EQ(cube_id, i + registered_cube); } @@ -707,13 +733,13 @@ TEST(calibrate, issue_calibrate_wrong) struct fieldstat *master = fieldstat_new(); const struct field *tag_A = &TEST_SHARED_TAG; const struct field *tag_B = &TEST_TAG_INT; - int cube_idA = fieldstat_create_cube(master, tag_A, 1, SAMPLING_MODE_COMPREHENSIVE, 1); - int cube_idB = fieldstat_create_cube(master, tag_B, 1, SAMPLING_MODE_COMPREHENSIVE, 1); + int cube_idA = test_fieldstat_cube_create(master, tag_A, 1, SAMPLING_MODE_COMPREHENSIVE, 1); + int cube_idB = test_fieldstat_cube_create(master, tag_B, 1, SAMPLING_MODE_COMPREHENSIVE, 1); struct fieldstat *target = fieldstat_fork(master); - EXPECT_EQ(fieldstat_destroy_cube(master, cube_idA), FS_OK); - EXPECT_EQ(fieldstat_destroy_cube(master, cube_idB), FS_OK); - int cube_idBa = fieldstat_create_cube(master, tag_B, 1, SAMPLING_MODE_COMPREHENSIVE, 1); + EXPECT_EQ(fieldstat_cube_destroy(master, cube_idA), FS_OK); + EXPECT_EQ(fieldstat_cube_destroy(master, cube_idB), FS_OK); + int cube_idBa = test_fieldstat_cube_create(master, tag_B, 1, SAMPLING_MODE_COMPREHENSIVE, 1); EXPECT_EQ(cube_idBa, 0); fieldstat_calibrate(master, target); @@ -739,11 +765,11 @@ TEST(calibrate, delete_first_cube) struct fieldstat *master = fieldstat_new(); const struct field *tag_A = &TEST_SHARED_TAG; const struct field *tag_B = &TEST_TAG_INT; - int cube_idA = fieldstat_create_cube(master, tag_A, 1, SAMPLING_MODE_COMPREHENSIVE, 1); - int cube_idB = fieldstat_create_cube(master, tag_B, 1, SAMPLING_MODE_COMPREHENSIVE, 1); + int cube_idA = test_fieldstat_cube_create(master, tag_A, 1, SAMPLING_MODE_COMPREHENSIVE, 1); + int cube_idB = test_fieldstat_cube_create(master, tag_B, 1, SAMPLING_MODE_COMPREHENSIVE, 1); struct fieldstat *target = fieldstat_fork(master); - fieldstat_destroy_cube(master, cube_idA); + fieldstat_cube_destroy(master, cube_idA); fieldstat_calibrate(master, target); diff --git a/test/test_write_json_file.cpp b/test/test_write_json_file.cpp index ff3dedf..1dba94b 100644 --- a/test/test_write_json_file.cpp +++ b/test/test_write_json_file.cpp @@ -58,6 +58,14 @@ extern "C" { return fse; } +int test_fieldstat_cube_create(struct fieldstat *instance, const struct field *dimensions, size_t n_dimensions, enum sampling_mode mode, int k) +{ + assert(mode == SAMPLING_MODE_COMPREHENSIVE); + int ret = fieldstat_cube_create(instance, dimensions, n_dimensions); + fieldstat_cube_set_sampling(instance, ret, mode, k, 0); + return ret; +} + static void write_hll(struct fieldstat *instance) { struct field shared_tags[1]; @@ -66,7 +74,7 @@ static void write_hll(struct fieldstat *instance) { shared_tags[0].value_longlong = 1; const char *hll_name[] = {"external_ip", "internal_ip", "acc_ip"}; - int cube_id = fieldstat_create_cube(instance, shared_tags, 1, + int cube_id = test_fieldstat_cube_create(instance, shared_tags, 1, SAMPLING_MODE_COMPREHENSIVE, 100); for(unsigned int i = 0; i < sizeof(hll_name) / sizeof(hll_name[0]); i++) @@ -107,7 +115,7 @@ void write_histogram(struct fieldstat *instance) { "bye/udp", "oth_mtd/udp"}; - int cube_id = fieldstat_create_cube(instance, shared_tags, 2, + int cube_id = test_fieldstat_cube_create(instance, shared_tags, 2, SAMPLING_MODE_COMPREHENSIVE, 100); for(unsigned int i = 0; i < sizeof(hist_names)/sizeof(hist_names[0]); i++) @@ -185,7 +193,7 @@ void write_table(struct fieldstat *instance) { cell_tags.type = FIELD_VALUE_CSTRING; cell_tags.value_str = "true"; - int cube_id = fieldstat_create_cube(instance, shared_tags, 2, + int cube_id = test_fieldstat_cube_create(instance, shared_tags, 2, SAMPLING_MODE_COMPREHENSIVE, 100); int counter_id_0 = fieldstat_register_counter(instance, cube_id, "T_success_log"); -- cgit v1.2.3