diff options
| author | chenzizhan <[email protected]> | 2023-11-24 09:53:52 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2023-11-24 09:53:52 +0800 |
| commit | a319982221b19b979efa6877f08115c95adec305 (patch) | |
| tree | 6bf75b9ea71c11c0556b5c7eac556b0feefcd61b /test/unit_test_cell_manager.cpp | |
| parent | 30437a0f2756671ba658311c0f179769f2b4e5ea (diff) | |
reduce malloc. use hash128 to circumvent key cmp
Diffstat (limited to 'test/unit_test_cell_manager.cpp')
| -rw-r--r-- | test/unit_test_cell_manager.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test/unit_test_cell_manager.cpp b/test/unit_test_cell_manager.cpp index 958d982..a9c9190 100644 --- a/test/unit_test_cell_manager.cpp +++ b/test/unit_test_cell_manager.cpp @@ -10,6 +10,7 @@ #include "fieldstat.h" #include "tags/cell_manager.h" #include "utils.hpp" +#include "tags/my_ut_hash.h" using namespace std; @@ -21,8 +22,8 @@ struct tag_hash_key *test_gen_tag_key(const char *key, int value) {.value_str = strdup(to_string(value).c_str())}, }; - struct tag_hash_key *tag_key = tag_hash_key_construct_with_fieldstat_tag(&tag, 1); - tag_hash_key_store(tag_key); + struct tag_hash_key *tag_key = (struct tag_hash_key *)malloc(sizeof(struct tag_hash_key)); + tag_hash_key_init_with_fieldstat_tag(tag_key, &tag, 1, true); free((void *)tag.value_str); @@ -398,6 +399,15 @@ void add_key_and_assert_find_result_comprehensive(struct cell_manager *cm, const EXPECT_TRUE(test_is_tag_equal(key_get, key)); } +struct tag_hash_key *tag_hash_key_construct_with_fieldstat_tag(const struct fieldstat_tag *src, size_t n_src) +{ + struct tag_hash_key *ret_hash_key = (struct tag_hash_key *)malloc(sizeof(struct tag_hash_key)); + + tag_hash_key_init_with_fieldstat_tag(ret_hash_key, src, n_src, false); + + return ret_hash_key; +} + TEST(unit_test_cell_manager, add_with_key_length_is_1_int_type_topk) { struct cell_manager *cm = cell_manager_new(SAMPLING_MODE_TOPK, 10); |
