合并plugin和ip_plugin的处理逻辑,抽象为Maat_ex_data.h/cpp。
This commit is contained in:
45
src/inc_internal/Maat_ex_data.h
Normal file
45
src/inc_internal/Maat_ex_data.h
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
#include "dynamic_array.h"
|
||||
#include "Maat_rule.h"
|
||||
#include <MESA/MESA_htable.h>
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
||||
struct EX_data_rt
|
||||
{
|
||||
dynamic_array_t *cache_rows;
|
||||
long long cache_row_num;
|
||||
long long cache_size;
|
||||
MESA_htable_handle key2ex_hash;
|
||||
const struct EX_data_schema* ex_schema;
|
||||
int table_id;
|
||||
void (* user_data_free)(void *user_data);
|
||||
};
|
||||
struct EX_data_container
|
||||
{
|
||||
MAAT_RULE_EX_DATA ex_data;
|
||||
const struct EX_data_rt* rt;
|
||||
void* user_data;
|
||||
TAILQ_ENTRY(EX_data_container) entries;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(EX_data_container_q, EX_data_container);
|
||||
struct EX_data_rt* EX_data_rt_new(int table_id, long long estimate_size, Maat_plugin_EX_key2index_func_t * key2index, void (* user_data_free)(void *user_data));
|
||||
void EX_data_rt_free(struct EX_data_rt* p);
|
||||
void EX_data_rt_set_schema(struct EX_data_rt* p, const struct EX_data_schema* schema);
|
||||
void EX_data_rt_cache_row(struct EX_data_rt* p, const char* row);
|
||||
|
||||
const char* EX_data_rt_get_cached_row(struct EX_data_rt* p, int i);
|
||||
|
||||
void EX_data_rt_clear_row_cache(struct EX_data_rt* p);
|
||||
int EX_data_rt_get_row_num(struct EX_data_rt* p);
|
||||
|
||||
struct EX_data_container* EX_data_rt_row2EX_data(struct EX_data_rt* ex_rt,
|
||||
const char* row, const char* key, size_t key_len,
|
||||
void* user_data, void* logger);
|
||||
|
||||
int EX_data_rt_delete_by_row(struct EX_data_rt* ex_rt, const char* row, const char* key, size_t key_len, void *logger);
|
||||
MAAT_RULE_EX_DATA EX_data_rt_get_EX_data_by_key(struct EX_data_rt* ex_rt, const char* key, size_t key_len);
|
||||
MAAT_RULE_EX_DATA EX_data_rt_get_EX_data_by_container(struct EX_data_rt* ex_rt, struct EX_data_container* container);
|
||||
size_t EX_data_rt_list_all(struct EX_data_rt* ex_rt, EX_data_container_q* listed);
|
||||
|
||||
@@ -457,9 +457,6 @@ void rewrite_table_line_with_foreign(struct serial_rule_t*p);
|
||||
void fill_maat_rule(struct Maat_rule_t *rule, const struct Maat_rule_head* rule_head, const char* srv_def, int srv_def_len);
|
||||
MAAT_RULE_EX_DATA rule_ex_data_new(const struct Maat_rule_head * rule_head, const char* srv_def, const struct compile_ex_data_idx* ex_desc);
|
||||
void rule_ex_data_free(const struct Maat_rule_head * rule_head, const char* srv_def, MAAT_RULE_EX_DATA *ad, const struct compile_ex_data_idx* ex_desc);
|
||||
MESA_htable_handle wrap_plugin_EX_hash_new(long long estimate_size, Maat_plugin_EX_key2index_func_t * key2index);
|
||||
int plugin_EX_data_new(const struct Maat_table_schema* plugin_table, const char* line, MESA_htable_handle key2ex_hash, void *logger);
|
||||
int plugin_EX_data_free(const char* line, int key_column, MESA_htable_handle key2ex_hash, void *logger);
|
||||
|
||||
|
||||
void set_serial_rule(struct serial_rule_t* rule,enum MAAT_OPERATION op,int rule_id,int label_id,const char* table_name,const char* line, long long timeout);
|
||||
|
||||
@@ -79,7 +79,7 @@ struct plugin_table_callback_schema
|
||||
Maat_finish_callback_t *finish;
|
||||
void* u_para;
|
||||
};
|
||||
struct plugin_table_ex_data_schema
|
||||
struct EX_data_schema
|
||||
{
|
||||
Maat_plugin_EX_new_func_t* new_func;
|
||||
Maat_plugin_EX_free_func_t* free_func;
|
||||
@@ -99,7 +99,7 @@ struct plugin_table_schema
|
||||
int have_exdata;
|
||||
long long estimate_size;
|
||||
struct plugin_table_callback_schema cb_plug[MAX_PLUGIN_PER_TABLE];
|
||||
struct plugin_table_ex_data_schema ex_desc;
|
||||
struct EX_data_schema ex_schema;
|
||||
};
|
||||
struct ip_plugin_table_schema
|
||||
{
|
||||
@@ -110,7 +110,8 @@ struct ip_plugin_table_schema
|
||||
int valid_flag_column;
|
||||
int rule_tag_column;
|
||||
long long estimate_size;
|
||||
struct plugin_table_ex_data_schema ex_desc;
|
||||
int have_exdata;
|
||||
struct EX_data_schema ex_schema;
|
||||
};
|
||||
struct Maat_table_schema
|
||||
{
|
||||
@@ -161,12 +162,21 @@ int Maat_table_new_compile_rule_ex_index(struct Maat_table_manager* table_mgr, c
|
||||
Maat_rule_EX_dup_func_t* dup_func,
|
||||
long argl, void *argp);
|
||||
struct compile_ex_data_idx* Maat_table_get_compile_rule_ex_desc(struct Maat_table_manager* table_mgr, const char* compile_table_name, int idx);
|
||||
int Maat_table_plugin_new_ex_index(struct Maat_table_manager* table_mgr, int table_id,
|
||||
int Maat_table_plugin_EX_data_schema_set(struct Maat_table_schema *table_schema,
|
||||
Maat_plugin_EX_new_func_t* new_func,
|
||||
Maat_plugin_EX_free_func_t* free_func,
|
||||
Maat_plugin_EX_dup_func_t* dup_func,
|
||||
Maat_plugin_EX_key2index_func_t* key2index_func,
|
||||
long argl, void *argp);
|
||||
long argl, void *argp,
|
||||
void* logger);
|
||||
int Maat_table_ip_plugin_EX_data_schema_set(struct Maat_table_schema *table_schema,
|
||||
Maat_plugin_EX_new_func_t* new_func,
|
||||
Maat_plugin_EX_free_func_t* free_func,
|
||||
Maat_plugin_EX_dup_func_t* dup_func,
|
||||
Maat_plugin_EX_key2index_func_t* key2index_func,
|
||||
long argl, void *argp,
|
||||
void* logger);
|
||||
|
||||
void Maat_table_manager_all_plugin_cb_start(struct Maat_table_manager* table_mgr, int update_type);
|
||||
void Maat_table_manager_all_plugin_cb_finish(struct Maat_table_manager* table_mgr);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Maat_table.h"
|
||||
#include "Maat_ex_data.h"
|
||||
#include "IPMatcher.h"
|
||||
#include "gram_index_engine.h"
|
||||
#include "alignment_int64.h"
|
||||
@@ -14,16 +15,13 @@ struct similar_runtime
|
||||
|
||||
struct plugin_runtime
|
||||
{
|
||||
dynamic_array_t *cache_lines;
|
||||
long long cache_line_num;
|
||||
struct EX_data_rt* ex_data_rt;
|
||||
long long acc_line_num;
|
||||
long long cache_size;
|
||||
MESA_htable_handle key2ex_hash;
|
||||
};
|
||||
|
||||
struct ip_plugin_runtime
|
||||
{
|
||||
long long row_num;
|
||||
MESA_htable_handle rowid2ex_hash;
|
||||
struct EX_data_rt* ex_data_rt;
|
||||
struct ip_matcher* ip_matcher;
|
||||
struct ip_matcher* old_ip_matcher;
|
||||
};
|
||||
@@ -69,13 +67,18 @@ struct Maat_table_runtime* Maat_table_runtime_get(struct Maat_table_runtime_mana
|
||||
long long Maat_table_runtime_plugin_cached_line_count(struct Maat_table_runtime* table_rt);
|
||||
const char* Maat_table_runtime_plugin_get_cached_line(struct Maat_table_runtime* table_rt, long long Nth_line);
|
||||
|
||||
int Maat_table_runtime_plugin_new_ex_idx(struct Maat_table_runtime* table_rt, struct Maat_table_schema* table_desc, void* logger);
|
||||
int Maat_table_runtime_plugin_commit_ex_schema(struct Maat_table_runtime* table_rt, struct Maat_table_schema* table_desc, void* logger);
|
||||
MAAT_PLUGIN_EX_DATA Maat_table_runtime_plugin_get_ex_data(struct Maat_table_runtime* table_rt, struct Maat_table_schema* table_desc, const char* key);
|
||||
void Maat_table_runtime_digest_add(struct Maat_table_runtime* table_rt, int expr_id, const char* digest, short confidence_degree, void* tag);
|
||||
void Maat_table_runtime_digest_del(struct Maat_table_runtime* table_rt, int expr_id);
|
||||
int Maat_table_runtime_digest_batch_udpate(struct Maat_table_runtime* table_rt);
|
||||
int Maat_table_runtime_ip_plugin_get_N_ex_data(struct Maat_table_runtime* table_rt, struct Maat_table_schema* table_schema, const struct ip_address* ip, MAAT_PLUGIN_EX_DATA* ex_data_array, size_t size);
|
||||
int Maat_table_runtime_rebuild_ip_matcher(struct Maat_table_runtime* table_rt);
|
||||
|
||||
void Maat_table_runtime_plugin_new_row(struct Maat_table_runtime* table_rt, struct Maat_table_schema* table_schema, const char* row, void *logger);
|
||||
void Maat_table_runtime_ip_plugin_new_row(struct Maat_table_runtime* table_rt, struct Maat_table_schema* table_schema, const char* row, void *logger);
|
||||
|
||||
int Maat_table_runtime_ip_plugin_commit_ex_schema(struct Maat_table_runtime* table_rt, struct Maat_table_schema* table_schema, void* logger);
|
||||
int Maat_table_runtime_ip_plugin_get_N_ex_data(struct Maat_table_runtime* table_rt, struct Maat_table_schema* table_schema, const struct ip_data* ip, MAAT_PLUGIN_EX_DATA* ex_data_array, size_t size);
|
||||
int Maat_table_runtime_ip_plugin_rebuild_ip_matcher(struct Maat_table_runtime* table_rt);
|
||||
struct ip_matcher* Maat_table_runtime_dettach_old_ip_matcher(struct Maat_table_runtime* table_rt);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user