change lib name to libmaat4 for test

This commit is contained in:
liuwentan
2023-03-22 11:23:21 +08:00
parent 23ef2c3797
commit 93d4de4d79
6 changed files with 48 additions and 42 deletions

View File

@@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 2.8)
set(lib_name maatframe)
project(maatframe)
set(lib_name maat4)
project(maat4)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(Version)

View File

@@ -356,9 +356,9 @@ struct bool_expr *bool_exprs_new(struct hs_expr *exprs, size_t n_expr, struct hs
return bool_exprs;
}
struct adapter_hs *adapter_hs_initialize(size_t n_worker_thread,
struct hs_expr *exprs, size_t n_expr,
struct log_handle *logger)
struct adapter_hs *adapter_hs_new(size_t n_worker_thread,
struct hs_expr *exprs, size_t n_expr,
struct log_handle *logger)
{
if (0 == n_worker_thread || NULL == exprs || 0 == n_expr) {
log_error(logger, MODULE_ADAPTER_HS, "[%s:%d] input parameters illegal!",
@@ -490,11 +490,11 @@ struct adapter_hs *adapter_hs_initialize(size_t n_worker_thread,
return hs_instance;
error:
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
return NULL;
}
void adapter_hs_destroy(struct adapter_hs *hs_instance)
void adapter_hs_free(struct adapter_hs *hs_instance)
{
if (NULL == hs_instance) {
return;

View File

@@ -82,7 +82,7 @@ struct hs_expr {
};
/**
* @brief initialize adapter_hs instance
* @brief new adapter_hs instance
*
* @param nr_worker_threads: the number of scan threads which will call adapter_hs_scan()
* @param expr_array: logic AND expression's array
@@ -90,14 +90,14 @@ struct hs_expr {
*
* @retval the pointer to adapter_hs instance
*/
struct adapter_hs *adapter_hs_initialize(size_t n_worker_thread,
struct hs_expr *exprs, size_t n_expr,
struct log_handle *logger);
struct adapter_hs *adapter_hs_new(size_t n_worker_thread,
struct hs_expr *exprs, size_t n_expr,
struct log_handle *logger);
/**
* @brief scan input data to match logic AND expression, return all matched expr_id
*
* @param instance: adapter_hs instance obtained by adapter_hs_initialize()
* @param instance: adapter_hs instance obtained by adapter_hs_new()
* @param thread_id: the thread_id of caller
* @param data: data to be scanned
* @param data_len: the length of data to be scanned
@@ -112,9 +112,9 @@ int adapter_hs_scan(struct adapter_hs *hs_instance, int thread_id,
/**
* @brief destroy adapter_hs instance
*
* @param instance: adapter_hs instance obtained by adapter_hs_initialize()
* @param instance: adapter_hs instance obtained by adapter_hs_new()
*/
void adapter_hs_destroy(struct adapter_hs *instance);
void adapter_hs_free(struct adapter_hs *instance);
struct adapter_hs_stream;
/**

View File

@@ -1725,7 +1725,13 @@ void maat_scan_stream_close(struct maat_stream **maat_stream)
struct maat_state *maat_state_new(struct maat *maat_instance, int thread_id)
{
return NULL;
struct maat_state *state = ALLOC(struct maat_state, 1);
state->maat_instance = maat_instance;
state->district_id = DISTRICT_ANY;
state->thread_id = (signed short)thread_id;
return state;
}
void maat_state_reset(struct maat_state *state)

View File

@@ -432,7 +432,7 @@ void expr_runtime_free(void *expr_runtime)
struct expr_runtime *expr_rt = (struct expr_runtime *)expr_runtime;
if (expr_rt->hs != NULL) {
adapter_hs_destroy(expr_rt->hs);
adapter_hs_free(expr_rt->hs);
expr_rt->hs = NULL;
}
@@ -783,7 +783,7 @@ int expr_runtime_commit(void *expr_runtime, const char *table_name)
int ret = 0;
struct adapter_hs *new_adapter_hs = NULL;
struct adapter_hs *old_adapter_hs = NULL;
new_adapter_hs = adapter_hs_initialize(expr_rt->n_worker_thread, rules, rule_cnt, expr_rt->logger);
new_adapter_hs = adapter_hs_new(expr_rt->n_worker_thread, rules, rule_cnt, expr_rt->logger);
if (NULL == new_adapter_hs) {
log_error(expr_rt->logger, MODULE_EXPR,
"[%s:%d] table[%s] rebuild adapter_hs engine failed when update %zu expr rules",
@@ -795,7 +795,7 @@ int expr_runtime_commit(void *expr_runtime, const char *table_name)
expr_rt->hs = new_adapter_hs;
if (old_adapter_hs != NULL) {
maat_garbage_bagging(expr_rt->ref_garbage_bin, old_adapter_hs,
(void (*)(void*))adapter_hs_destroy);
(void (*)(void*))adapter_hs_free);
}
rcu_hash_commit(expr_rt->item_htable);
expr_rt->rule_num = rule_cnt;

View File

@@ -209,23 +209,23 @@ TEST(adapter_hs_init, invalid_input_parameter)
struct hs_expr expr_array[64];
size_t n_expr_array = 0;
struct adapter_hs *hs_instance = adapter_hs_initialize(1, NULL, 0, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, NULL, 0, g_logger);
EXPECT_TRUE(hs_instance == NULL);
hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance == NULL);
n_expr_array = 1;
expr_array[0].expr_id = 101;
expr_array[0].n_patterns = 10;
hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance == NULL);
memset(expr_array, 0, sizeof(expr_array));
n_expr_array = 1;
expr_array[0].expr_id = 101;
expr_array[0].n_patterns = 1;
hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance == NULL);
}
@@ -238,7 +238,7 @@ TEST(adapter_hs_scan, literal_sub_has_normal_offset)
EXPECT_EQ(ret, 0);
EXPECT_EQ(n_expr_array, 12);
struct adapter_hs *hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance != NULL);
expr_array_free(expr_array, n_expr_array);
@@ -273,7 +273,7 @@ TEST(adapter_hs_scan, literal_sub_has_normal_offset)
EXPECT_EQ(ret, 0);
EXPECT_EQ(n_result, 0);
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
hs_instance = NULL;
}
@@ -285,7 +285,7 @@ TEST(adapter_hs_scan, literal_sub_has_left_unlimit_offset)
int ret = parse_config_file("./literal_expr.conf", expr_array, &n_expr_array);
EXPECT_EQ(ret, 0);
struct adapter_hs *hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance != NULL);
expr_array_free(expr_array, n_expr_array);
@@ -321,7 +321,7 @@ TEST(adapter_hs_scan, literal_sub_has_left_unlimit_offset)
EXPECT_EQ(ret, 0);
EXPECT_EQ(n_result, 0);
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
hs_instance = NULL;
}
@@ -333,7 +333,7 @@ TEST(adapter_hs_scan, literal_sub_has_right_unlimit_offset)
int ret = parse_config_file("./literal_expr.conf", expr_array, &n_expr_array);
EXPECT_EQ(ret, 0);
struct adapter_hs *hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance != NULL);
expr_array_free(expr_array, n_expr_array);
@@ -376,7 +376,7 @@ TEST(adapter_hs_scan, literal_sub_has_right_unlimit_offset)
EXPECT_EQ(n_result, 1);
EXPECT_EQ(result[0].item_id, 103);
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
hs_instance = NULL;
}
@@ -388,7 +388,7 @@ TEST(adapter_hs_scan, literal_sub_with_no_offset)
int ret = parse_config_file("./literal_expr.conf", expr_array, &n_expr_array);
EXPECT_EQ(ret, 0);
struct adapter_hs *hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance != NULL);
expr_array_free(expr_array, n_expr_array);
@@ -423,7 +423,7 @@ TEST(adapter_hs_scan, literal_sub_with_no_offset)
EXPECT_EQ(ret, 0);
EXPECT_EQ(n_result, 0);
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
hs_instance = NULL;
}
@@ -435,7 +435,7 @@ TEST(adapter_hs_scan, literal_exactly)
int ret = parse_config_file("./literal_expr.conf", expr_array, &n_expr_array);
EXPECT_EQ(ret, 0);
struct adapter_hs *hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance != NULL);
expr_array_free(expr_array, n_expr_array);
@@ -464,7 +464,7 @@ TEST(adapter_hs_scan, literal_exactly)
EXPECT_EQ(ret, 0);
EXPECT_EQ(n_result, 0);
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
hs_instance = NULL;
}
@@ -476,7 +476,7 @@ TEST(adapter_hs_scan, literal_prefix)
int ret = parse_config_file("./literal_expr.conf", expr_array, &n_expr_array);
EXPECT_EQ(ret, 0);
struct adapter_hs *hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance != NULL);
expr_array_free(expr_array, n_expr_array);
@@ -514,7 +514,7 @@ TEST(adapter_hs_scan, literal_prefix)
EXPECT_EQ(n_result, 1);
EXPECT_EQ(result[0].item_id, 106);
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
hs_instance = NULL;
}
@@ -526,7 +526,7 @@ TEST(adapter_hs_scan, literal_suffix)
int ret = parse_config_file("./literal_expr.conf", expr_array, &n_expr_array);
EXPECT_EQ(ret, 0);
struct adapter_hs *hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance != NULL);
expr_array_free(expr_array, n_expr_array);
@@ -564,7 +564,7 @@ TEST(adapter_hs_scan, literal_suffix)
EXPECT_EQ(ret, 0);
EXPECT_EQ(n_result, 0);
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
hs_instance = NULL;
}
@@ -576,7 +576,7 @@ TEST(adapter_hs_scan, literal_sub_with_hexbin)
int ret = parse_config_file("./literal_expr.conf", expr_array, &n_expr_array);
EXPECT_EQ(ret, 0);
struct adapter_hs *hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance != NULL);
expr_array_free(expr_array, n_expr_array);
@@ -596,7 +596,7 @@ TEST(adapter_hs_scan, literal_sub_with_hexbin)
EXPECT_EQ(ret, 0);
EXPECT_EQ(n_result, 0);
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
hs_instance = NULL;
}
@@ -608,7 +608,7 @@ TEST(adapter_hs_scan, literal_with_chinese)
int ret = parse_config_file("./literal_expr.conf", expr_array, &n_expr_array);
EXPECT_EQ(ret, 0);
struct adapter_hs *hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance != NULL);
expr_array_free(expr_array, n_expr_array);
@@ -620,7 +620,7 @@ TEST(adapter_hs_scan, literal_with_chinese)
EXPECT_EQ(n_result0, 1);
EXPECT_EQ(result0[0].item_id, 110);
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
hs_instance = NULL;
}
@@ -632,7 +632,7 @@ TEST(adapter_hs_scan, same_pattern_different_offset)
int ret = parse_config_file("./literal_expr.conf", expr_array, &n_expr_array);
EXPECT_EQ(ret, 0);
struct adapter_hs *hs_instance = adapter_hs_initialize(1, expr_array, n_expr_array, g_logger);
struct adapter_hs *hs_instance = adapter_hs_new(1, expr_array, n_expr_array, g_logger);
EXPECT_TRUE(hs_instance != NULL);
expr_array_free(expr_array, n_expr_array);
@@ -644,7 +644,7 @@ TEST(adapter_hs_scan, same_pattern_different_offset)
EXPECT_EQ(n_result, 1);
EXPECT_EQ(result[0].item_id, 112);
adapter_hs_destroy(hs_instance);
adapter_hs_free(hs_instance);
hs_instance = NULL;
}