From 14a26915772f59e183de570fb827a7a4d7840b61 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Sat, 29 Jun 2019 21:46:46 +0600 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG=EF=BC=9A=E5=88=A0?= =?UTF-8?q?=E9=99=A4compile=E6=97=B6=EF=BC=8C=E6=9C=AA=E7=BD=AE=E7=A9=BAgr?= =?UTF-8?q?oup=E4=B8=AD=E7=9A=84shortcut=EF=BC=8C=E5=AF=BC=E8=87=B4region?= =?UTF-8?q?=20compile=E6=AE=B5=E9=94=99=E8=AF=AF(#16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry/Maat_rule.cpp | 14 ++++++++++- src/inc_internal/Maat_rule_internal.h | 36 ++++++++++++++------------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index 6fa88c3..337748e 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -1947,6 +1947,7 @@ int add_group_to_compile(struct Maat_compile_group_relation*relation, struct Maa relation->not_flag[write_pos]=0; } relation->group_cnt++; + a_rule_group->ref_by_parent_cnt++; //member group->compile_shortcut may set to NULL and compile rule pointer repeatly,until rule build finish. if(a_rule_group->ref_by_parent_cnt==1&&relation->group_cnt==1) { @@ -1956,7 +1957,6 @@ int add_group_to_compile(struct Maat_compile_group_relation*relation, struct Maa { a_rule_group->compile_shortcut=NULL; } - a_rule_group->ref_by_parent_cnt++; //update group's shortcut when compile has more than one group. if(relation->group_cnt!=1) { @@ -1995,6 +1995,12 @@ struct Maat_group_inner* del_group_from_compile(struct Maat_compile_group_relati relation->not_group_cnt--; relation->not_flag[i]=0; } + if(group_rule->compile_shortcut) + { + assert(group_rule->compile_shortcut==relation); + assert(group_rule->ref_by_parent_cnt==1&&relation->group_cnt==1); + group_rule->compile_shortcut=NULL; + } relation->group_cnt--; break; } @@ -2499,6 +2505,12 @@ int add_group_rule(struct Maat_table_desc* table, struct db_group_rule_t* db_gro { parent_group=create_group_rule(db_group_rule->parent_id, table->table_id, scanner); } + //A sub group is not possile to have a compile shortcut. + if(group_rule->compile_shortcut) + { + assert(group_rule->ref_by_parent_cnt==1); + group_rule->compile_shortcut=NULL; + } group_rule->ref_by_parent_cnt++; parent_group->ref_by_children_cnt++; ret=igraph_get_eid(&scanner->group_graph, &edge_id, group_rule->vertex_id, parent_group->vertex_id, IGRAPH_DIRECTED, /*error*/ 0); diff --git a/src/inc_internal/Maat_rule_internal.h b/src/inc_internal/Maat_rule_internal.h index 178e85c..ce6e6a7 100644 --- a/src/inc_internal/Maat_rule_internal.h +++ b/src/inc_internal/Maat_rule_internal.h @@ -135,23 +135,6 @@ struct Maat_region_inner int expr_id_ub; enum MAAT_TABLE_TYPE table_type; }; -struct Maat_group_inner -{ - int group_id; - int table_id; - int region_boundary; - int region_cnt; - int ref_by_parent_cnt; - int ref_by_children_cnt; - char* group_name; - int has_compile_neighbors; - int vertex_id; - int top_group_cnt; - long long* top_groups; - dynamic_array_t *regions; - void* compile_shortcut; - pthread_mutex_t mutex; -}; #define COMPILE_RELATION_MAGIC 0x1a2b3c4d struct Maat_compile_group_relation { @@ -166,6 +149,25 @@ struct Maat_compile_group_relation pthread_rwlock_t rwlock;//reading compile rule is safe in update thread, rwlock lock called when delete or scan thread read }; + +struct Maat_group_inner +{ + int group_id; + int table_id; + int region_boundary; + int region_cnt; + int ref_by_parent_cnt; + int ref_by_children_cnt; + char* group_name; + int has_compile_neighbors; + int vertex_id; + int top_group_cnt; + long long* top_groups; + dynamic_array_t *regions; + struct Maat_compile_group_relation* compile_shortcut; + pthread_mutex_t mutex; +}; + struct _compile_result_t { int compile_id;