From 0f6eccbb47d3902b59a62a7703e841a22cd7b6dc Mon Sep 17 00:00:00 2001 From: zhengchao Date: Thu, 1 Apr 2021 14:37:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0hierarachy=E4=B8=AD=E4=B8=BA?= =?UTF-8?q?=E6=AF=8F=E4=B8=AA=E7=BA=BF=E7=A8=8B=E5=88=86=E9=85=8Dexpr=5Fbu?= =?UTF-8?q?ff=EF=BC=8C=E4=BB=A5=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AE=BE=E7=BD=AE=E7=9A=84=E7=BC=93=E5=86=B2?= =?UTF-8?q?=E5=8C=BA=E5=A4=A7=E5=B0=8F=EF=BC=8C=E5=AF=BC=E8=87=B4=E4=B8=8D?= =?UTF-8?q?=E5=91=BD=E4=B8=AD=E7=9A=84bug=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CMakeLists.txt | 2 +- src/entry/Maat_hierarchy.cpp | 24 ++++++++++++++---------- src/entry/Maat_rule.cpp | 2 +- src/entry/bool_matcher.cpp | 4 ++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a9ba7a2..223bf10 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.5) set(MAAT_FRAME_MAJOR_VERSION 3) set(MAAT_FRAME_MINOR_VERSION 1) -set(MAAT_FRAME_PATCH_VERSION 4) +set(MAAT_FRAME_PATCH_VERSION 17) set(MAAT_FRAME_VERSION ${MAAT_FRAME_MAJOR_VERSION}.${MAAT_FRAME_MINOR_VERSION}.${MAAT_FRAME_PATCH_VERSION}) message(STATUS "Maat Frame, Version: ${MAAT_FRAME_VERSION}") diff --git a/src/entry/Maat_hierarchy.cpp b/src/entry/Maat_hierarchy.cpp index ae40428..1db7500 100644 --- a/src/entry/Maat_hierarchy.cpp +++ b/src/entry/Maat_hierarchy.cpp @@ -110,6 +110,7 @@ struct Maat_hierarchy int thread_num; struct Maat_garbage_bin* garbage_bin; void* logger; + struct bool_expr_match *expr_match_buff; }; int compare_literal_id(const void *pa, const void *pb) @@ -296,6 +297,7 @@ struct Maat_hierarchy* Maat_hierarchy_new(int thread_num, void* mesa_handle_logg hier->hash_literal_by_id=NULL; hier->hash_region_by_id=NULL; + hier->expr_match_buff=ALLOC(struct bool_expr_match, thread_num*MAX_SCANNER_HIT_NUM); ret=igraph_empty(&hier->group_graph, 0, IGRAPH_DIRECTED); assert(ret==IGRAPH_SUCCESS); @@ -345,6 +347,8 @@ void Maat_hierarchy_free(struct Maat_hierarchy* hier) bool_matcher_free(hier->bm); hier->bm=NULL; pthread_rwlock_unlock(&hier->rwlock); + free(hier->expr_match_buff); + hier->expr_match_buff=NULL; free(hier); } @@ -1338,8 +1342,8 @@ int Maat_hierarchy_region_compile(struct Maat_hierarchy_compile_mid* mid, int is { int bool_match_ret=0, i=0; struct Maat_hierarchy* hier=mid->ref_hier; - struct Maat_hierarchy_compile* compile_array[ud_array_sz]; - struct bool_expr_match expr_match[ud_array_sz]; + struct Maat_hierarchy_compile* compile_array=NULL; + struct bool_expr_match *expr_match=hier->expr_match_buff+mid->thread_num*MAX_SCANNER_HIT_NUM; size_t r_in_c_cnt=0, this_scan_region_hits=mid->this_scan_region_hit_cnt; size_t ud_result_cnt=0; @@ -1351,22 +1355,22 @@ int Maat_hierarchy_region_compile(struct Maat_hierarchy_compile_mid* mid, int is pthread_rwlock_rdlock(&hier->rwlock); bool_match_ret=bool_matcher_match(hier->bm, mid->thread_num, (unsigned long long*)utarray_eltptr(mid->_all_hit_clause_array, 0), utarray_len(mid->_all_hit_clause_array), - expr_match, ud_array_sz); - for(i=0; icompile_id==expr_match[i].expr_id); - r_in_c_cnt=Maat_hierarchy_compile_mid_update_by_compile(mid, compile_array[i]); - if(compile_array[i]->not_clause_cnt>0 && !is_last_compile) + compile_array=(struct Maat_hierarchy_compile*)expr_match[i].user_tag; + assert((unsigned long long)compile_array->compile_id==expr_match[i].expr_id); + r_in_c_cnt=Maat_hierarchy_compile_mid_update_by_compile(mid, compile_array); + if(compile_array->not_clause_cnt>0 && !is_last_compile) { mid->not_clause_hitted_flag=1; } - else if(compile_array[i]->user_data)//For compile may be dettached by Maat_hierarchy_compile_dettach_user_data, only return non-NULL userdata. + else if(compile_array->user_data)//For compile may be dettached by Maat_hierarchy_compile_dettach_user_data, only return non-NULL userdata. { if(r_in_c_cnt>0 || //compile hitted becasue of new reigon this_scan_region_hits==0) //or hit a compile that refer a NOT-logic group in previous scan. { - user_data_array[ud_result_cnt]=compile_array[i]->user_data; + user_data_array[ud_result_cnt]=compile_array->user_data; ud_result_cnt++; } } diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index 0aeff39..2aa53e9 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -57,7 +57,7 @@ extern "C" } #endif -int MAAT_FRAME_VERSION_3_1_16_20210320=1; +int MAAT_FRAME_VERSION_3_1_17_20210323=1; int is_valid_table_name(const char* str) { diff --git a/src/entry/bool_matcher.cpp b/src/entry/bool_matcher.cpp index c391d5d..f868d3f 100644 --- a/src/entry/bool_matcher.cpp +++ b/src/entry/bool_matcher.cpp @@ -194,7 +194,7 @@ int bool_matcher_match(struct bool_matcher * matcher, unsigned int thread_id, co for(unsigned int j=matcher->mapped_ptr[h]; jmapped_ptr[h+1]; j++) { - if(ids_num==MAX_ARRAY_SIZE) return -1; + if(ids_num==MAX_ARRAY_SIZE) continue; mapped_ids[ids_num++]=matcher->mapped_ids[j]; } } @@ -203,7 +203,7 @@ int bool_matcher_match(struct bool_matcher * matcher, unsigned int thread_id, co unsigned int used_num=0; for(unsigned int i=0; i>3); }