fix group2group bug

This commit is contained in:
liuwentan
2023-03-30 16:50:05 +08:00
parent 96a5dfdecc
commit 4bbd0ebdc4
4 changed files with 21 additions and 22 deletions

View File

@@ -1867,11 +1867,12 @@ int maat_compile_state_update(struct rcu_hash_table *item_htable, int vtable_id,
void *compile_rt = table_manager_get_runtime(state->maat_instance->tbl_mgr, void *compile_rt = table_manager_get_runtime(state->maat_instance->tbl_mgr,
compile_table_id); compile_table_id);
assert(compile_rt != NULL); assert(compile_rt != NULL);
for (size_t i = 0; i < hit_group_cnt; i++) {
long long top_group_ids[MAX_SCANNER_HIT_GROUP_NUM]; long long top_group_ids[MAX_SCANNER_HIT_GROUP_NUM];
memset(top_group_ids, 0, sizeof(top_group_ids)); memset(top_group_ids, -1, sizeof(top_group_ids));
int top_group_cnt = group2group_runtime_get_top_groups(g2g_rt, &hit_group_ids[i], int top_group_cnt = group2group_runtime_get_top_groups(g2g_rt, hit_group_ids,
1, top_group_ids); hit_group_cnt,
top_group_ids);
if (top_group_cnt >= MAX_SCANNER_HIT_GROUP_NUM) { if (top_group_cnt >= MAX_SCANNER_HIT_GROUP_NUM) {
top_group_cnt = MAX_SCANNER_HIT_GROUP_NUM; top_group_cnt = MAX_SCANNER_HIT_GROUP_NUM;
} }
@@ -1880,7 +1881,6 @@ int maat_compile_state_update(struct rcu_hash_table *item_htable, int vtable_id,
maat_compile_state_update_hit_clause(state->compile_state, compile_rt, maat_compile_state_update_hit_clause(state->compile_state, compile_rt,
top_group_ids[j], vtable_id); top_group_ids[j], vtable_id);
} }
}
return 0; return 0;
} }

View File

@@ -498,9 +498,9 @@ int group2group_runtime_build_top_groups(void *g2g_runtime)
struct maat_group *group = NULL, *tmp = NULL; struct maat_group *group = NULL, *tmp = NULL;
struct maat_group *super_group = NULL; struct maat_group *super_group = NULL;
int tmp_vid=0; int tmp_vid = 0;
size_t top_group_cnt=0; size_t top_group_cnt = 0;
int *temp_group_ids=NULL; long long *temp_group_ids = NULL;
struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime; struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime;
pthread_rwlock_wrlock(&(g2g_rt->rwlock)); pthread_rwlock_wrlock(&(g2g_rt->rwlock));
@@ -538,14 +538,14 @@ int group2group_runtime_build_top_groups(void *g2g_runtime)
if (0 == group->ref_by_super_group_cnt) { if (0 == group->ref_by_super_group_cnt) {
//fast path, group is only referenced by compile rules. //fast path, group is only referenced by compile rules.
top_group_cnt = 1; top_group_cnt = 1;
temp_group_ids = ALLOC(int, top_group_cnt); temp_group_ids = ALLOC(long long, top_group_cnt);
temp_group_ids[0] = group->group_id; temp_group_ids[0] = group->group_id;
} else { } else {
igraph_vector_t *vids = &(group_topo->dfs_vids); igraph_vector_t *vids = &(group_topo->dfs_vids);
igraph_dfs(&group_topo->group_graph, group->vertex_id, IGRAPH_OUT, igraph_dfs(&group_topo->group_graph, group->vertex_id, IGRAPH_OUT,
0, vids, NULL, NULL, NULL, NULL, NULL, NULL); 0, vids, NULL, NULL, NULL, NULL, NULL, NULL);
temp_group_ids = ALLOC(int, effective_vertices_count(vids)); temp_group_ids = ALLOC(long long, effective_vertices_count(vids));
for (size_t i = 0; i < (size_t)igraph_vector_size(vids); i++) { for (size_t i = 0; i < (size_t)igraph_vector_size(vids); i++) {
tmp_vid = (int) VECTOR(*vids)[i]; tmp_vid = (int) VECTOR(*vids)[i];

View File

@@ -587,14 +587,13 @@ int table_manager_runtime_create(struct table_manager *tbl_mgr, int max_thread_n
table_type = table_manager_get_table_type(tbl_mgr, i); table_type = table_manager_get_table_type(tbl_mgr, i);
void *runtime = table_manager_get_runtime(tbl_mgr, i); void *runtime = table_manager_get_runtime(tbl_mgr, i);
tbl_mgr->tbl[i]->runtime = maat_table_runtime_new(schema, table_type, max_thread_num,
garbage_bin, tbl_mgr->logger);
if (runtime != NULL) { if (runtime != NULL) {
enum table_type *arg = ALLOC(enum table_type, 1); enum table_type *arg = ALLOC(enum table_type, 1);
*arg = table_type; *arg = table_type;
maat_garbage_bagging(garbage_bin, runtime, arg, garbage_maat_table_runtime_free); maat_garbage_bagging(garbage_bin, runtime, arg, garbage_maat_table_runtime_free);
} }
tbl_mgr->tbl[i]->runtime = maat_table_runtime_new(schema, table_type, max_thread_num,
garbage_bin, tbl_mgr->logger);
} }
/* group2compile runtime depends on associated compile runtime, /* group2compile runtime depends on associated compile runtime,

View File

@@ -2780,7 +2780,7 @@ TEST_F(Policy, CompileEXData) {
maat_state_free(state); maat_state_free(state);
state = NULL; state = NULL;
} }
#if 0
TEST_F(Policy, SubGroup) { TEST_F(Policy, SubGroup) {
long long results[ARRAY_SIZE] = {0}; long long results[ARRAY_SIZE] = {0};
size_t n_hit_result = 0; size_t n_hit_result = 0;
@@ -2811,7 +2811,7 @@ TEST_F(Policy, SubGroup) {
maat_state_free(state); maat_state_free(state);
} }
#endif
TEST_F(Policy, EvaluationOrder) { TEST_F(Policy, EvaluationOrder) {
const char *url = "cavemancircus.com/2019/12/27/pretty-girls-6/"; const char *url = "cavemancircus.com/2019/12/27/pretty-girls-6/";
long long results[ARRAY_SIZE] = {0}; long long results[ARRAY_SIZE] = {0};