[BUGFIX]fix can't get hit path if group is referenced by compile directly
This commit is contained in:
@@ -2134,10 +2134,6 @@ size_t maat_compile_state_get_internal_hit_paths(struct maat_compile_state *comp
|
||||
tmp_path.vtable_id = internal_path->vtable_id;
|
||||
tmp_path.compile_id = -1;
|
||||
|
||||
if (tmp_path.sub_group_id == tmp_path.top_group_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* check if internal_path is duplicated from hit_path_array[] element */
|
||||
if (hit_path_cnt > 0) {
|
||||
if (maat_compile_is_hit_path_existed(hit_path_array, hit_path_cnt, &tmp_path)) {
|
||||
|
||||
@@ -487,25 +487,23 @@ void maat_group_dereference_super_group(struct maat_group *group, long long supe
|
||||
}
|
||||
|
||||
size_t remove_idx = 0;
|
||||
|
||||
long long *tmp_id = NULL;
|
||||
if (0 == is_exclude) {
|
||||
//include superior group
|
||||
if (!utarray_find(group->incl_super_group_ids, &super_group_id, compare_group_id)) {
|
||||
return;
|
||||
tmp_id = utarray_find(group->incl_super_group_ids, &super_group_id, compare_group_id);
|
||||
if (tmp_id != NULL) {
|
||||
remove_idx = utarray_eltidx(group->incl_super_group_ids, tmp_id);
|
||||
utarray_erase(group->incl_super_group_ids, remove_idx, 1);
|
||||
utarray_sort(group->incl_super_group_ids, compare_group_id);
|
||||
}
|
||||
|
||||
remove_idx = utarray_eltidx(group->incl_super_group_ids, &super_group_id);
|
||||
utarray_erase(group->incl_super_group_ids, remove_idx, 1);
|
||||
utarray_sort(group->incl_super_group_ids, compare_group_id);
|
||||
} else {
|
||||
//exclude superior group
|
||||
if (!utarray_find(group->excl_super_group_ids, &super_group_id, compare_group_id)) {
|
||||
return;
|
||||
tmp_id = utarray_find(group->excl_super_group_ids, &super_group_id, compare_group_id);
|
||||
if (tmp_id != NULL) {
|
||||
remove_idx = utarray_eltidx(group->excl_super_group_ids, tmp_id);
|
||||
utarray_erase(group->excl_super_group_ids, remove_idx, 1);
|
||||
utarray_sort(group->excl_super_group_ids, compare_group_id);
|
||||
}
|
||||
|
||||
remove_idx = utarray_eltidx(group->excl_super_group_ids, &super_group_id);
|
||||
utarray_erase(group->excl_super_group_ids, remove_idx, 1);
|
||||
utarray_sort(group->excl_super_group_ids, compare_group_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,25 +515,23 @@ void maat_group_dereference_sub_group(struct maat_group *group, long long sub_gr
|
||||
}
|
||||
|
||||
size_t remove_idx = 0;
|
||||
|
||||
long long *tmp_id = NULL;
|
||||
if (0 == is_exclude) {
|
||||
//include superior group
|
||||
if (!utarray_find(group->incl_sub_group_ids, &sub_group_id, compare_group_id)) {
|
||||
return;
|
||||
tmp_id = utarray_find(group->incl_sub_group_ids, &sub_group_id, compare_group_id);
|
||||
if (tmp_id != NULL) {
|
||||
remove_idx = utarray_eltidx(group->incl_sub_group_ids, tmp_id);
|
||||
utarray_erase(group->incl_sub_group_ids, remove_idx, 1);
|
||||
utarray_sort(group->incl_sub_group_ids, compare_group_id);
|
||||
}
|
||||
|
||||
remove_idx = utarray_eltidx(group->incl_sub_group_ids, &sub_group_id);
|
||||
utarray_erase(group->incl_sub_group_ids, remove_idx, 1);
|
||||
utarray_sort(group->incl_sub_group_ids, compare_group_id);
|
||||
} else {
|
||||
//exclude superior group
|
||||
if (!utarray_find(group->excl_sub_group_ids, &sub_group_id, compare_group_id)) {
|
||||
return;
|
||||
tmp_id = utarray_find(group->excl_sub_group_ids, &sub_group_id, compare_group_id);
|
||||
if (tmp_id != NULL) {
|
||||
remove_idx = utarray_eltidx(group->excl_sub_group_ids, tmp_id);
|
||||
utarray_erase(group->excl_sub_group_ids, remove_idx, 1);
|
||||
utarray_sort(group->excl_sub_group_ids, compare_group_id);
|
||||
}
|
||||
|
||||
remove_idx = utarray_eltidx(group->excl_sub_group_ids, &sub_group_id);
|
||||
utarray_erase(group->excl_sub_group_ids, remove_idx, 1);
|
||||
utarray_sort(group->excl_sub_group_ids, compare_group_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -786,9 +782,12 @@ void get_candidate_super_group_ids(struct maat_group_topology *group_topo, UT_ar
|
||||
continue;
|
||||
}
|
||||
|
||||
if (0 == utarray_len(group->incl_sub_group_ids)) {
|
||||
utarray_push_back(candidate_group_ids, p);
|
||||
utarray_sort(candidate_group_ids, compare_group_id);
|
||||
if ((0 == utarray_len(group->incl_sub_group_ids)) &&
|
||||
(0 == utarray_len(group->excl_sub_group_ids))) {
|
||||
if (!utarray_find(candidate_group_ids, p, compare_group_id)) {
|
||||
utarray_push_back(candidate_group_ids, p);
|
||||
utarray_sort(candidate_group_ids, compare_group_id);
|
||||
}
|
||||
}
|
||||
|
||||
long long *tmp = NULL;
|
||||
@@ -833,8 +832,12 @@ void verify_candidate_super_group_ids(struct maat_group_topology *group_topo, UT
|
||||
struct maat_group *group = group_topology_find_group(group_topo, *p);
|
||||
assert(group != NULL);
|
||||
|
||||
if (0 == utarray_len(group->incl_sub_group_ids)) {
|
||||
utarray_push_back(kept_group_ids, p);
|
||||
if ((0 == utarray_len(group->incl_sub_group_ids)) &&
|
||||
(0 == utarray_len(group->excl_sub_group_ids))) {
|
||||
if (!utarray_find(kept_group_ids, p, compare_group_id)) {
|
||||
utarray_push_back(kept_group_ids, p);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -850,7 +853,7 @@ void verify_candidate_super_group_ids(struct maat_group_topology *group_topo, UT
|
||||
}
|
||||
}
|
||||
|
||||
// group's sub_include not in candidates, it should not be kept
|
||||
// group's all sub_include not in candidates, it should not be kept
|
||||
for (tmp = (long long *)utarray_front(group->incl_sub_group_ids); tmp != NULL;
|
||||
tmp = (long long *)utarray_next(group->incl_sub_group_ids, tmp)) {
|
||||
if (!utarray_find(candidate_group_ids, tmp, compare_group_id)) {
|
||||
@@ -907,6 +910,9 @@ size_t group_topology_get_super_groups(struct maat_group_topology *group_topo,
|
||||
candidates = {g7, g8, g12}
|
||||
*/
|
||||
get_candidate_super_group_ids(group_topo, one_round_hit_group_ids, candidate_group_ids, depth);
|
||||
if (0 == utarray_len(candidate_group_ids)) {
|
||||
goto next;
|
||||
}
|
||||
|
||||
/**
|
||||
verify if candidates should be kept for hit super groups, must consider exclude groups
|
||||
@@ -924,11 +930,24 @@ size_t group_topology_get_super_groups(struct maat_group_topology *group_topo,
|
||||
x \ / \ \
|
||||
x \/ \ \
|
||||
g3 g4 g5 g11
|
||||
candidates = {g7, g8, g12}
|
||||
candidates = {g4, g11, g7, g8, g12}
|
||||
g12's sub_exclude g8 in candidates, so g12 should be dropped
|
||||
after verify candidates, all hit super group's = {g7, g8}
|
||||
after verify candidates, all hit super groups = {g7, g8}, all hit groups = {g4, g11, g7, g8}
|
||||
*/
|
||||
verify_candidate_super_group_ids(group_topo, candidate_group_ids, all_hit_group_ids, depth);
|
||||
if (0 == utarray_len(all_hit_group_ids)) {
|
||||
goto next;
|
||||
}
|
||||
|
||||
// delete group_ids from all_hit_group_ids, just keep all hit super groups
|
||||
for (i = 0; i < n_group_ids; i++) {
|
||||
long long *tmp_id = NULL;
|
||||
tmp_id = utarray_find(all_hit_group_ids, &group_ids[i], compare_group_id);
|
||||
if (tmp_id != NULL) {
|
||||
size_t remove_idx = utarray_eltidx(all_hit_group_ids, tmp_id);
|
||||
utarray_erase(all_hit_group_ids, remove_idx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
long long *p = NULL;
|
||||
for (p = (long long *)utarray_front(all_hit_group_ids); p != NULL;
|
||||
@@ -940,6 +959,7 @@ size_t group_topology_get_super_groups(struct maat_group_topology *group_topo,
|
||||
super_group_ids[idx++] = *p;
|
||||
}
|
||||
|
||||
next:
|
||||
utarray_free(one_round_hit_group_ids);
|
||||
utarray_free(candidate_group_ids);
|
||||
utarray_free(all_hit_group_ids);
|
||||
|
||||
@@ -30,11 +30,6 @@
|
||||
|
||||
#define MODULE_TABLE module_name_str("maat.table")
|
||||
|
||||
struct table_item {
|
||||
enum table_type table_type;
|
||||
void *custom_item;
|
||||
};
|
||||
|
||||
struct maat_table {
|
||||
int table_id;
|
||||
char table_name[NAME_MAX];
|
||||
@@ -402,7 +397,7 @@ static int compare_each_tag_set(cJSON *tag_set, const struct rule_tag *accept_ta
|
||||
|
||||
//@param value {"tag_sets":[[{"tag":"location","value":["北京/朝阳/华严北里","上海/浦东/陆家嘴"]},{"tag":"isp","value":["电信","移动"]}],[{"tag":"location","value":["北京"]},{"tag":"isp","value":["联通"]}]]}
|
||||
//@return 1 on match, 0 on not match, -1 on error.
|
||||
int compare_accept_tag(const char *value, const struct rule_tag *accept_tags, size_t n_accept_tag)
|
||||
static int compare_accept_tag(const char *value, const struct rule_tag *accept_tags, size_t n_accept_tag)
|
||||
{
|
||||
int ret = TAG_MATCH_ERR;
|
||||
int n_set = 0;
|
||||
@@ -972,12 +967,6 @@ void *table_manager_get_schema(struct table_manager *tbl_mgr, int table_id)
|
||||
return tbl_mgr->tbl[table_id]->schema;
|
||||
}
|
||||
|
||||
struct ex_data_schema *
|
||||
table_manager_get_table_ex_data_schema(struct table_manager *tbl_mgr, int table_id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int table_manager_get_valid_column(struct table_manager *tbl_mgr, int table_id)
|
||||
{
|
||||
if (NULL == tbl_mgr || table_id < 0 || table_id >= MAX_TABLE_NUM) {
|
||||
|
||||
101
test/group_exclude/group_exclude_L3.conf
Normal file
101
test/group_exclude/group_exclude_L3.conf
Normal file
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"add_items": [
|
||||
{
|
||||
"group_id": 1,
|
||||
"super_group_id": 6,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 2,
|
||||
"super_group_id": 9,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 4,
|
||||
"super_group_id": 7,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 4,
|
||||
"super_group_id": 8,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 5,
|
||||
"super_group_id": 8,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 6,
|
||||
"super_group_id": 9,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 7,
|
||||
"super_group_id": 9,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 8,
|
||||
"super_group_id": 10,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 8,
|
||||
"super_group_id": 13,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 11,
|
||||
"super_group_id": 12,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 2,
|
||||
"super_group_id": 6,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 3,
|
||||
"super_group_id": 7,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 3,
|
||||
"super_group_id": 8,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 7,
|
||||
"super_group_id": 10,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 7,
|
||||
"super_group_id": 12,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 11,
|
||||
"super_group_id": 13,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 8,
|
||||
"super_group_id": 7,
|
||||
"is_exclude": 1
|
||||
}
|
||||
],
|
||||
"del_items": [
|
||||
{
|
||||
"group_id": 8,
|
||||
"super_group_id": 7,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 11,
|
||||
"super_group_id": 13,
|
||||
"is_exclude": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
test/group_exclude/group_exclude_L3.png
Normal file
BIN
test/group_exclude/group_exclude_L3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 202 KiB |
Reference in New Issue
Block a user