#include #include #include #include "fieldstat.h" const struct field TEST_FIELD_STRING = {"STRING KEY_", FIELD_VALUE_CSTRING, {.value_str = "100.1"}}; const struct field_list TEST_FIELD_LIST_STRING = {(struct field *)&TEST_FIELD_STRING, 1}; const struct field TEST_FIELD_INT = {"INT key_", FIELD_VALUE_INTEGER, {.value_longlong = 100}}; const struct field_list TEST_FIELD_LIST_INT = {(struct field *)&TEST_FIELD_INT, 1}; const struct field TEST_FIELD_INT_2 = {"collided", FIELD_VALUE_INTEGER, {.value_longlong = 2}}; const struct field TEST_FIELD_DOUBLE = {"DOUBLE key_", FIELD_VALUE_DOUBLE, {.value_double = 100.1}}; const struct field_list TEST_FIELD_LIST_DOUBLE = {(struct field *)&TEST_FIELD_DOUBLE, 1}; 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 std::string gen_rand_string(int len); class Fieldstat_tag_list_wrapper { public: 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); std::string to_string() const; // std::uniform_int_distribution dist(1,100) explicit Fieldstat_tag_list_wrapper(); Fieldstat_tag_list_wrapper(const Fieldstat_tag_list_wrapper &tag_list_wrapper); ~Fieldstat_tag_list_wrapper(); bool operator==(const Fieldstat_tag_list_wrapper &tag_list_wrapper) const; const struct field *get_tag() const; const struct field **get_field_ptr_array() const; size_t get_tag_count() const; const struct field_list *get_c_struct() const; void print_tag_list() const; Fieldstat_tag_list_wrapper& sort_tag_list(); private: struct field_list tag_list_c; }; double test_cal_topk_accuracy(std::vector &test_result, std::unordered_map &expected_count); // after we change fieldstat_counter_get return a error code in, all the tests should change correspondingly, so just use a adapter aliasing the old function long long my_fieldstat_counter_get(const struct fieldstat *instance, int cube_id, int metric_id, int cell_id); struct Flow { std::string src_ip; std::string dst_ip; }; class SpreadSketchZipfGenerator { private: const int MAX_DATA = 1000000; std::vector> *loadeds; unsigned cursor; public: SpreadSketchZipfGenerator(double alpha, int n); struct Flow next(); ~SpreadSketchZipfGenerator(); double _alpha; int _n; };