初步完成模糊哈希配置加载的集成,分离Maat_api.c
This commit is contained in:
@@ -170,7 +170,7 @@ void Maat_stream_scan_string_end(stream_para_t* stream_para);
|
|||||||
|
|
||||||
stream_para_t Maat_stream_scan_digest_start(Maat_feather_t feather,int table_id,unsigned long long total_len,int thread_num);
|
stream_para_t Maat_stream_scan_digest_start(Maat_feather_t feather,int table_id,unsigned long long total_len,int thread_num);
|
||||||
int Maat_stream_scan_digest(stream_para_t* stream_para
|
int Maat_stream_scan_digest(stream_para_t* stream_para
|
||||||
,const char* data,int data_len
|
,const char* data,int data_len,unsigned long long offset
|
||||||
,struct Maat_rule_t*result,int rule_num
|
,struct Maat_rule_t*result,int rule_num
|
||||||
,scan_status_t* mid);
|
,scan_status_t* mid);
|
||||||
void Maat_stream_scan_digest_end(stream_para_t* stream_para);
|
void Maat_stream_scan_digest_end(stream_para_t* stream_para);
|
||||||
|
|||||||
1049
src/entry/Maat_api.cpp
Normal file
1049
src/entry/Maat_api.cpp
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -105,6 +105,15 @@ struct db_intval_rule_t
|
|||||||
interval_rule_t intval;
|
interval_rule_t intval;
|
||||||
int is_valid;
|
int is_valid;
|
||||||
};
|
};
|
||||||
|
struct db_digest_rule_t
|
||||||
|
{
|
||||||
|
int region_id;
|
||||||
|
int group_id;
|
||||||
|
unsigned long long orgin_len;
|
||||||
|
const char* digest_string;
|
||||||
|
short confidence_degree;
|
||||||
|
int is_valid;
|
||||||
|
};
|
||||||
struct _head_Maat_rule_t
|
struct _head_Maat_rule_t
|
||||||
{
|
{
|
||||||
int config_id;
|
int config_id;
|
||||||
@@ -233,7 +242,8 @@ struct _stream_para_t
|
|||||||
char* scan_buff;
|
char* scan_buff;
|
||||||
void* rs_stream_para;
|
void* rs_stream_para;
|
||||||
long acc_scan_len;
|
long acc_scan_len;
|
||||||
|
unsigned long long total_len;
|
||||||
|
fuzzy_handle_t *fuzzy_hash_handle;
|
||||||
};
|
};
|
||||||
struct _Maat_scanner_t
|
struct _Maat_scanner_t
|
||||||
{
|
{
|
||||||
@@ -241,12 +251,15 @@ struct _Maat_scanner_t
|
|||||||
time_t last_update_time;
|
time_t last_update_time;
|
||||||
int *ref_cnt; //optimized for cache_alignment 64
|
int *ref_cnt; //optimized for cache_alignment 64
|
||||||
rule_scanner_t region;
|
rule_scanner_t region;
|
||||||
|
pthread_rwlock_t digest_rwlock[MAX_TABLE_NUM];
|
||||||
|
GIE_handle_t* digest_handle[MAX_TABLE_NUM];
|
||||||
MESA_htable_handle region_hash;
|
MESA_htable_handle region_hash;
|
||||||
MESA_htable_handle group_hash;
|
MESA_htable_handle group_hash;
|
||||||
MESA_htable_handle compile_hash;
|
MESA_htable_handle compile_hash;
|
||||||
unsigned int cfg_num;
|
unsigned int cfg_num;
|
||||||
unsigned int exprid_generator;
|
unsigned int exprid_generator;
|
||||||
MESA_lqueue_head region_update_q;
|
MESA_lqueue_head region_update_q;
|
||||||
|
MESA_lqueue_head digest_update_q[MAX_TABLE_NUM];
|
||||||
void * expr_compiler;
|
void * expr_compiler;
|
||||||
scan_result_t *region_rslt_buff;
|
scan_result_t *region_rslt_buff;
|
||||||
MESA_lqueue_head tomb_ref;//reference of feather->garbage_q
|
MESA_lqueue_head tomb_ref;//reference of feather->garbage_q
|
||||||
|
|||||||
@@ -17,36 +17,40 @@ typedef struct
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
unsigned long long orilen;
|
short operation;//GIE_INSERT_OPT or GIE_DELETE_OPT.if operation is GIE_DELETE_OPT, only id is needed;
|
||||||
char * fh;
|
short cfds_lvl;
|
||||||
|
unsigned long long origin_len;
|
||||||
|
char * fuzzy_hash;
|
||||||
void * tag;
|
void * tag;
|
||||||
}fuzzy_digest_t;
|
}GIE_digest_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
int confidence_level;
|
short cfds_lvl;
|
||||||
unsigned long long orilen;
|
unsigned long long origin_len;
|
||||||
void * tag;
|
void * tag;
|
||||||
}result_t;
|
}GIE_result_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned long long precision;
|
unsigned long long index_interval;
|
||||||
int confidence_level_threshold;
|
// int confidence_level_threshold;
|
||||||
double query_accuracy;
|
double query_accuracy;
|
||||||
}GIE_create_para_t;
|
}GIE_create_para_t;
|
||||||
|
|
||||||
|
|
||||||
GIE_handle_t * GIE_create(GIE_create_para_t * usrpara);
|
GIE_handle_t * GIE_create(const GIE_create_para_t * para);
|
||||||
|
|
||||||
|
|
||||||
int GIE_update(GIE_handle_t * handle, fuzzy_digest_t ** digests, int size, int opration);
|
int GIE_update(GIE_handle_t * handle, GIE_digest_t ** digests, int size);
|
||||||
|
|
||||||
|
//return actual matched result count
|
||||||
int GIE_query(GIE_handle_t * handle, unsigned long long orilen, char * fuzzy_string, int strsize, result_t * results, int size);
|
//return 0 when matched nothing;
|
||||||
|
//return -1 when error occurs;
|
||||||
|
int GIE_query(GIE_handle_t * handle, unsigned long long origin_len, const char * fuzzy_string, GIE_result_t * results, int result_size);
|
||||||
|
|
||||||
|
|
||||||
void GIE_destory(GIE_handle_t * handle);
|
void GIE_destory(GIE_handle_t * handle);
|
||||||
|
|||||||
Reference in New Issue
Block a user