bool Matcher对输入的item id(clause id)排序和去重,会改变外部ut_array内容,可能造成风险, 去除bool matcher 中的这部分代码。
This commit is contained in:
@@ -52,7 +52,7 @@ extern "C"
|
|||||||
struct bool_matcher * bool_matcher_new(struct bool_expr * exprs, size_t expr_num, unsigned int max_thread_num, size_t * mem_size);
|
struct bool_matcher * bool_matcher_new(struct bool_expr * exprs, size_t expr_num, unsigned int max_thread_num, size_t * mem_size);
|
||||||
|
|
||||||
/* Returned results are sorted by expr_id in descending order. */
|
/* Returned results are sorted by expr_id in descending order. */
|
||||||
/* 本函数将对数组item_ids进行排序,会改变item_ids中元素的顺序 */
|
//Input item_ids MUST be ASCENDING order and NO duplication.
|
||||||
int bool_matcher_match(struct bool_matcher * matcher, unsigned int thread_id, unsigned long long * item_ids, size_t item_num, struct bool_expr_match * results, size_t n_result);
|
int bool_matcher_match(struct bool_matcher * matcher, unsigned int thread_id, unsigned long long * item_ids, size_t item_num, struct bool_expr_match * results, size_t n_result);
|
||||||
|
|
||||||
void bool_matcher_free(struct bool_matcher * matcher);
|
void bool_matcher_free(struct bool_matcher * matcher);
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ static void Maat_hierarchy_region_free(struct Maat_hierarchy* hier, struct Maat_
|
|||||||
struct Maat_hierarchy* Maat_hierarchy_new(int thread_num, void* mesa_handle_logger, struct Maat_garbage_bin* bin)
|
struct Maat_hierarchy* Maat_hierarchy_new(int thread_num, void* mesa_handle_logger, struct Maat_garbage_bin* bin)
|
||||||
{
|
{
|
||||||
struct Maat_hierarchy* hier=ALLOC(struct Maat_hierarchy, 1);
|
struct Maat_hierarchy* hier=ALLOC(struct Maat_hierarchy, 1);
|
||||||
int ret=0;
|
UNUSED int ret=0;
|
||||||
hier->logger=mesa_handle_logger;
|
hier->logger=mesa_handle_logger;
|
||||||
hier->thread_num=thread_num;
|
hier->thread_num=thread_num;
|
||||||
hier->version=time(NULL);
|
hier->version=time(NULL);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ extern "C"
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int MAAT_FRAME_VERSION_3_2_1_20210613=1;
|
int MAAT_FRAME_VERSION_3_2_2_20210629=1;
|
||||||
|
|
||||||
int is_valid_table_name(const char* str)
|
int is_valid_table_name(const char* str)
|
||||||
{
|
{
|
||||||
@@ -1425,7 +1425,7 @@ int del_region_rule(struct Maat_table_schema* table, int region_id, int group_id
|
|||||||
struct Maat_table_runtime* table_rt=NULL;
|
struct Maat_table_runtime* table_rt=NULL;
|
||||||
struct op_expr_t* op_expr=NULL;
|
struct op_expr_t* op_expr=NULL;
|
||||||
|
|
||||||
int ret=0;
|
UNUSED int ret=0;
|
||||||
struct Maat_region_inner* region=NULL;
|
struct Maat_region_inner* region=NULL;
|
||||||
region=(struct Maat_region_inner*)Maat_hierarchy_region_dettach_user_data(maat_scanner->hier, region_id);
|
region=(struct Maat_region_inner*)Maat_hierarchy_region_dettach_user_data(maat_scanner->hier, region_id);
|
||||||
if(region==NULL)
|
if(region==NULL)
|
||||||
|
|||||||
@@ -150,13 +150,13 @@ int bool_matcher_match(struct bool_matcher * matcher, unsigned int thread_id, un
|
|||||||
if(matcher==NULL) return -1;
|
if(matcher==NULL) return -1;
|
||||||
if(item_num==0) return 0;
|
if(item_num==0) return 0;
|
||||||
|
|
||||||
sort(item_ids, item_ids+item_num);
|
// sort(item_ids, item_ids+item_num);
|
||||||
size_t J=0;
|
// size_t J=0;
|
||||||
for(unsigned int i=1; i<item_num; i++)
|
// for(unsigned int i=1; i<item_num; i++)
|
||||||
{
|
// {
|
||||||
if(item_ids[i]!=item_ids[J]) item_ids[++J]=item_ids[i];
|
// if(item_ids[i]!=item_ids[J]) item_ids[++J]=item_ids[i];
|
||||||
}
|
// }
|
||||||
item_num=J+1;
|
// item_num=J+1;
|
||||||
|
|
||||||
unsigned int r=0;
|
unsigned int r=0;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "stream_fuzzy_hash.h"
|
#include "stream_fuzzy_hash.h"
|
||||||
#include "Maat_command.h"
|
#include "Maat_command.h"
|
||||||
#include <MESA/MESA_handle_logger.h>
|
#include <MESA/MESA_handle_logger.h>
|
||||||
|
using namespace std;
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@@ -92,6 +93,7 @@ TEST(BoolMatcher, Match)
|
|||||||
input_item_ids[input_item_num]=random();
|
input_item_ids[input_item_num]=random();
|
||||||
input_item_num++;
|
input_item_num++;
|
||||||
}
|
}
|
||||||
|
sort(input_item_ids, input_item_ids+input_item_num);
|
||||||
ret=bool_matcher_match(bm, 1, input_item_ids, input_item_num, result_array, 1024);
|
ret=bool_matcher_match(bm, 1, input_item_ids, input_item_num, result_array, 1024);
|
||||||
if(ret>0)
|
if(ret>0)
|
||||||
{
|
{
|
||||||
@@ -116,6 +118,7 @@ TEST(BoolMatcher, Match)
|
|||||||
input_item_ids[14]=222;
|
input_item_ids[14]=222;
|
||||||
input_item_ids[15]=333;
|
input_item_ids[15]=333;
|
||||||
input_item_num=8;
|
input_item_num=8;
|
||||||
|
sort(input_item_ids, input_item_ids+input_item_num);
|
||||||
for(i=0; i<test_count; i++)
|
for(i=0; i<test_count; i++)
|
||||||
{
|
{
|
||||||
ret=bool_matcher_match(bm, 1, input_item_ids, input_item_num, result_array, 1024);
|
ret=bool_matcher_match(bm, 1, input_item_ids, input_item_num, result_array, 1024);
|
||||||
|
|||||||
Reference in New Issue
Block a user