diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp index cf762db..c3b335d 100644 --- a/src/entry/Maat_api.cpp +++ b/src/entry/Maat_api.cpp @@ -155,8 +155,9 @@ int region_compile(_Maat_feather_t*feather,struct _INNER_scan_status_t *_mid,int scan_ret=shortcut_avilable_cnt; alignment_int64_array_add(feather->orphan_group_saving, thread_num, 1); } - else if(shortcut_avilable_cnt==0&®ion_hit_num==1&&_mid->hit_group_cnt==1&&is_last_region==1) + else if(0&&shortcut_avilable_cnt==0&®ion_hit_num==1&&_mid->hit_group_cnt==1&&is_last_region==1) { + //This shortcut is NO longger valid after bool macher support NOT-logic. //short cut for last scan and combination rules //region_hit_num==1 : for current scan hitted rules, one and each other group may statisfy a compile rule. //_mid->hit_group_cnt==1: With pre scan hitted group rules, one group may staisfy a compile rule @@ -179,7 +180,7 @@ int region_compile(_Maat_feather_t*feather,struct _INNER_scan_status_t *_mid,int if(0==pthread_rwlock_tryrdlock(&(_mi_rule->rwlock))) { - if(_mi_rule->is_valid==1) + if(_mi_rule->is_valid==1 && !(_mi_rule->not_group_cnt>0 && !is_last_region)) { make_group_set(_mi_rule, &(rs_result[result_cnt].group_set), &has_not_flag); r_in_c_cnt=pickup_hit_region_from_compile(&(rs_result[result_cnt].group_set), _mid->cur_hit_id, _mid->cur_hit_cnt, diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index abd0711..29c2dc3 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -1802,6 +1802,7 @@ int add_group_to_compile(struct Maat_compile_inner_t*a_compile_rule,struct Maat_ if(not_flag) { a_compile_rule->not_flag[write_pos]=1; + a_compile_rule->not_group_cnt++; } else { @@ -1853,7 +1854,11 @@ struct Maat_group_inner_t* del_group_from_compile(struct Maat_compile_inner_t*a_ { group_rule->ref_cnt--; dynamic_array_write(a_compile_rule->groups,i,NULL); - a_compile_rule->not_flag[i]=0; + if(a_compile_rule->not_flag[i]==1) + { + a_compile_rule->not_group_cnt--; + a_compile_rule->not_flag[i]=0; + } a_compile_rule->group_cnt--; pthread_rwlock_unlock(&(a_compile_rule->rwlock)); return group_rule; diff --git a/src/inc_internal/Maat_rule_internal.h b/src/inc_internal/Maat_rule_internal.h index 9ef0f8a..27a7d38 100644 --- a/src/inc_internal/Maat_rule_internal.h +++ b/src/inc_internal/Maat_rule_internal.h @@ -147,7 +147,8 @@ struct Maat_compile_inner_t struct db_compile_rule_t *db_c_rule; dynamic_array_t *groups; //element is struct Maat_group_inner_t* char not_flag[MAX_ITEMS_PER_BOOL_EXPR]; - int is_valid; + char not_group_cnt; + char is_valid; int compile_id;//equal to db_c_rule->m_rule.config_id const struct Maat_table_desc* ref_table; int group_boundary; diff --git a/test/test_maatframe.cpp b/test/test_maatframe.cpp index 2012686..78a6cb1 100644 --- a/test/test_maatframe.cpp +++ b/test/test_maatframe.cpp @@ -303,12 +303,14 @@ TEST(Boolmatcher, NotFlagGroup) table_id=Maat_table_register(g_feather,table_name); ASSERT_GT(table_id, 0); + Maat_set_scan_status(g_feather, &mid, MAAT_SET_SCAN_LAST_REGION, NULL, 0); ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, string_should_hit, strlen(string_should_hit), result,found_pos, 4, &mid, 0); EXPECT_GE(ret, 1); Maat_clean_status(&mid); + Maat_set_scan_status(g_feather, &mid, MAAT_SET_SCAN_LAST_REGION, NULL, 0); ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, string_should_not_hit, strlen(string_should_not_hit), result,found_pos, 4, &mid, 0);