rename o2o and object2object to object_group

This commit is contained in:
root
2024-10-24 07:56:49 +00:00
parent 1cd21a43c9
commit da715f21ef
22 changed files with 311 additions and 311 deletions

View File

@@ -13,7 +13,7 @@
#define MAX_IDS_STR_LEN 64
#define MAX_ITEM_NUM 64
#define WAIT_FOR_EFFECTIVE_S 2
#define MAX_O2O_SCAN_TIMES (1000 * 1000)
#define MAX_OBJECT_GROUP_SCAN_TIMES (1000 * 1000)
const char *g_table_info_path = "./object_exclude_table_info.json";
const char *log_file = "./object_exclude_gtest.log";
@@ -24,7 +24,7 @@ struct object_item {
char excl_sub_ids_str[MAX_IDS_STR_LEN];
};
struct object2object_rule {
struct object_group_rule {
size_t n_add_item;
size_t n_del_item;
struct object_item add_items[MAX_ITEM_NUM];
@@ -34,7 +34,7 @@ struct object2object_rule {
UT_icd ut_ex_object_id_icd = {sizeof(long long), NULL, NULL, NULL};
static int
parse_config_file(const char *filename, struct object2object_rule *rules)
parse_config_file(const char *filename, struct object_group_rule *rules)
{
unsigned char *json_buff = NULL;
size_t json_buff_size = 0;
@@ -140,12 +140,12 @@ protected:
assert(0);
}
o2o_schema = object2object_schema_new(root, NULL, "EXCLUDE_OBJECT2OBJECT", logger);
object_group_schema = object_group_schema_new(root, NULL, "EXCLUDE_OBJECT_GROUP", logger);
FREE(json_buff);
cJSON_Delete(root);
if (NULL == o2o_schema) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_schema_new failed.");
if (NULL == object_group_schema) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_schema_new failed.");
assert(0);
}
}
@@ -153,26 +153,26 @@ protected:
static void TearDownTestCase() {
log_handle_destroy(logger);
maat_garbage_bin_free(garbage_bin);
object2object_schema_free(o2o_schema);
object_group_schema_free(object_group_schema);
}
static void *o2o_schema;
static void *object_group_schema;
static struct log_handle *logger;
static struct maat_garbage_bin *garbage_bin;
};
void *MaatObjectExclude::o2o_schema;
void *MaatObjectExclude::object_group_schema;
struct log_handle *MaatObjectExclude::logger;
struct maat_garbage_bin *MaatObjectExclude::garbage_bin;
TEST_F(MaatObjectExclude, level_3_function) {
char table_line[1024];
struct object2object_rule rules;
const char *table_name = "EXCLUDE_OBJECT2OBJECT";
struct object_group_rule rules;
const char *table_name = "EXCLUDE_OBJECT_GROUP";
void *o2o_runtime = object2object_runtime_new(o2o_schema, 1, garbage_bin, logger);
if (NULL == o2o_runtime) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
void *object_group_runtime = object_group_runtime_new(object_group_schema, 1, garbage_bin, logger);
if (NULL == object_group_runtime) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_runtime_new failed.");
assert(0);
}
@@ -185,14 +185,14 @@ TEST_F(MaatObjectExclude, level_3_function) {
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_ADD);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_ADD);
}
object2object_runtime_commit(o2o_runtime, table_name, 1);
object_group_runtime_commit(object_group_runtime, table_name, 1);
long long hit_object_ids[2] = {11, 13};
long long super_object_ids[MAX_ITEM_NUM];
size_t super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
size_t super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
EXPECT_EQ(super_object_cnt, 2);
EXPECT_EQ(super_object_ids[0], 2);
@@ -202,10 +202,10 @@ TEST_F(MaatObjectExclude, level_3_function) {
memset(table_line, 0, sizeof(table_line));
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
object2object_runtime_commit(o2o_runtime, table_name, 2);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
object_group_runtime_commit(object_group_runtime, table_name, 2);
super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
EXPECT_EQ(super_object_cnt, 3);
EXPECT_EQ(super_object_ids[0], 1);
@@ -216,10 +216,10 @@ TEST_F(MaatObjectExclude, level_3_function) {
memset(table_line, 0, sizeof(table_line));
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[1].object_id,
rules.del_items[1].incl_sub_ids_str, rules.del_items[1].excl_sub_ids_str, 0);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
object2object_runtime_commit(o2o_runtime, table_name, 3);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
object_group_runtime_commit(object_group_runtime, table_name, 3);
super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
EXPECT_EQ(super_object_cnt, 4);
EXPECT_EQ(super_object_ids[0], 1);
@@ -227,17 +227,17 @@ TEST_F(MaatObjectExclude, level_3_function) {
EXPECT_EQ(super_object_ids[2], 6);
EXPECT_EQ(super_object_ids[3], 7);
object2object_runtime_free(o2o_runtime);
object_group_runtime_free(object_group_runtime);
}
TEST_F(MaatObjectExclude, level_3_perf) {
char table_line[1024];
struct object2object_rule rules;
const char *table_name = "EXCLUDE_OBJECT2OBJECT";
struct object_group_rule rules;
const char *table_name = "EXCLUDE_OBJECT_GROUP";
void *o2o_runtime = object2object_runtime_new(o2o_schema, 1, garbage_bin, logger);
if (NULL == o2o_runtime) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
void *object_group_runtime = object_group_runtime_new(object_group_schema, 1, garbage_bin, logger);
if (NULL == object_group_runtime) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_runtime_new failed.");
assert(0);
}
@@ -250,10 +250,10 @@ TEST_F(MaatObjectExclude, level_3_perf) {
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_ADD);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_ADD);
}
object2object_runtime_commit(o2o_runtime, table_name, 4);
object_group_runtime_commit(object_group_runtime, table_name, 4);
long long hit_object_ids[2] = {11, 13};
long long super_object_ids[MAX_ITEM_NUM];
@@ -261,8 +261,8 @@ TEST_F(MaatObjectExclude, level_3_perf) {
struct log_handle *logger = MaatObjectExclude::logger;
clock_gettime(CLOCK_MONOTONIC, &start);
for (int i = 0; i < MAX_O2O_SCAN_TIMES; i++) {
object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
for (int i = 0; i < MAX_OBJECT_GROUP_SCAN_TIMES; i++) {
object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
}
clock_gettime(CLOCK_MONOTONIC, &end);
@@ -274,12 +274,12 @@ TEST_F(MaatObjectExclude, level_3_perf) {
memset(table_line, 0, sizeof(table_line));
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
object2object_runtime_commit(o2o_runtime, table_name, 5);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
object_group_runtime_commit(object_group_runtime, table_name, 5);
clock_gettime(CLOCK_MONOTONIC, &start);
for (int i = 0; i < MAX_O2O_SCAN_TIMES; i++) {
object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
for (int i = 0; i < MAX_OBJECT_GROUP_SCAN_TIMES; i++) {
object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
}
clock_gettime(CLOCK_MONOTONIC, &end);
@@ -291,12 +291,12 @@ TEST_F(MaatObjectExclude, level_3_perf) {
memset(table_line, 0, sizeof(table_line));
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[1].object_id,
rules.del_items[1].incl_sub_ids_str, rules.del_items[1].excl_sub_ids_str, 0);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
object2object_runtime_commit(o2o_runtime, table_name, 6);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
object_group_runtime_commit(object_group_runtime, table_name, 6);
clock_gettime(CLOCK_MONOTONIC, &start);
for (int i = 0; i < MAX_O2O_SCAN_TIMES; i++) {
object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
for (int i = 0; i < MAX_OBJECT_GROUP_SCAN_TIMES; i++) {
object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
}
clock_gettime(CLOCK_MONOTONIC, &end);
@@ -304,17 +304,17 @@ TEST_F(MaatObjectExclude, level_3_perf) {
log_info(logger, MODULE_OBJECT_NESTING_GTEST, "level_3_basic hit 4 super_objects scan consume time %lldms",
time_elapse_ms);
object2object_runtime_free(o2o_runtime);
object_group_runtime_free(object_group_runtime);
}
TEST_F(MaatObjectExclude, level_4_function) {
char table_line[1024];
struct object2object_rule rules;
const char *table_name = "EXCLUDE_OBJECT2OBJECT";
struct object_group_rule rules;
const char *table_name = "EXCLUDE_OBJECT_GROUP";
void *o2o_runtime = object2object_runtime_new(o2o_schema, 1, garbage_bin, logger);
if (NULL == o2o_runtime) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
void *object_group_runtime = object_group_runtime_new(object_group_schema, 1, garbage_bin, logger);
if (NULL == object_group_runtime) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_runtime_new failed.");
assert(0);
}
@@ -327,14 +327,14 @@ TEST_F(MaatObjectExclude, level_4_function) {
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_ADD);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_ADD);
}
object2object_runtime_commit(o2o_runtime, table_name, 7);
object_group_runtime_commit(object_group_runtime, table_name, 7);
long long hit_object_ids[2] = {14, 16};
long long super_object_ids[MAX_ITEM_NUM];
size_t super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
size_t super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
EXPECT_EQ(super_object_cnt, 5);
EXPECT_EQ(super_object_ids[0], 4);
@@ -347,10 +347,10 @@ TEST_F(MaatObjectExclude, level_4_function) {
memset(table_line, 0, sizeof(table_line));
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
object2object_runtime_commit(o2o_runtime, table_name, 8);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
object_group_runtime_commit(object_group_runtime, table_name, 8);
super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
EXPECT_EQ(super_object_cnt, 7);
EXPECT_EQ(super_object_ids[0], 1);
@@ -361,17 +361,17 @@ TEST_F(MaatObjectExclude, level_4_function) {
EXPECT_EQ(super_object_ids[5], 9);
EXPECT_EQ(super_object_ids[6], 10);
object2object_runtime_free(o2o_runtime);
object_group_runtime_free(object_group_runtime);
}
TEST_F(MaatObjectExclude, level_4_perf) {
char table_line[1024];
struct object2object_rule rules;
const char *table_name = "EXCLUDE_OBJECT2OBJECT";
struct object_group_rule rules;
const char *table_name = "EXCLUDE_OBJECT_GROUP";
void *o2o_runtime = object2object_runtime_new(o2o_schema, 1, garbage_bin, logger);
if (NULL == o2o_runtime) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
void *object_group_runtime = object_group_runtime_new(object_group_schema, 1, garbage_bin, logger);
if (NULL == object_group_runtime) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_runtime_new failed.");
assert(0);
}
@@ -384,10 +384,10 @@ TEST_F(MaatObjectExclude, level_4_perf) {
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_ADD);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_ADD);
}
object2object_runtime_commit(o2o_runtime, table_name, 7);
object_group_runtime_commit(object_group_runtime, table_name, 7);
long long hit_object_ids[2] = {14, 16};
long long super_object_ids[MAX_ITEM_NUM];
@@ -395,8 +395,8 @@ TEST_F(MaatObjectExclude, level_4_perf) {
struct log_handle *logger = MaatObjectExclude::logger;
clock_gettime(CLOCK_MONOTONIC, &start);
for (int i = 0; i < MAX_O2O_SCAN_TIMES; i++) {
object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
for (int i = 0; i < MAX_OBJECT_GROUP_SCAN_TIMES; i++) {
object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
}
clock_gettime(CLOCK_MONOTONIC, &end);
@@ -408,12 +408,12 @@ TEST_F(MaatObjectExclude, level_4_perf) {
memset(table_line, 0, sizeof(table_line));
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
object2object_runtime_commit(o2o_runtime, table_name, 8);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
object_group_runtime_commit(object_group_runtime, table_name, 8);
clock_gettime(CLOCK_MONOTONIC, &start);
for (int i = 0; i < MAX_O2O_SCAN_TIMES; i++) {
object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
for (int i = 0; i < MAX_OBJECT_GROUP_SCAN_TIMES; i++) {
object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
}
clock_gettime(CLOCK_MONOTONIC, &end);
@@ -421,17 +421,17 @@ TEST_F(MaatObjectExclude, level_4_perf) {
log_info(logger, MODULE_OBJECT_NESTING_GTEST, "level_4_basic hit 7 super_objects scan consume time %lldms",
time_elapse_ms);
object2object_runtime_free(o2o_runtime);
object_group_runtime_free(object_group_runtime);
}
TEST_F(MaatObjectExclude, level_exceed_function) {
char table_line[1024];
struct object2object_rule rules;
const char *table_name = "EXCLUDE_OBJECT2OBJECT";
struct object_group_rule rules;
const char *table_name = "EXCLUDE_OBJECT_GROUP";
void *o2o_runtime = object2object_runtime_new(o2o_schema, 1, garbage_bin, logger);
if (NULL == o2o_runtime) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
void *object_group_runtime = object_group_runtime_new(object_group_schema, 1, garbage_bin, logger);
if (NULL == object_group_runtime) {
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_runtime_new failed.");
assert(0);
}
@@ -444,14 +444,14 @@ TEST_F(MaatObjectExclude, level_exceed_function) {
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_ADD);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_ADD);
}
object2object_runtime_commit(o2o_runtime, table_name, 8);
object_group_runtime_commit(object_group_runtime, table_name, 8);
long long hit_object_ids[2] = {7, 13};
long long super_object_ids[MAX_ITEM_NUM];
size_t super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
size_t super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
EXPECT_EQ(super_object_cnt, 6);
EXPECT_EQ(super_object_ids[0], 4);
@@ -465,12 +465,12 @@ TEST_F(MaatObjectExclude, level_exceed_function) {
memset(table_line, 0, sizeof(table_line));
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
object2object_runtime_commit(o2o_runtime, table_name, 9);
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
object_group_runtime_commit(object_group_runtime, table_name, 9);
hit_object_ids[0] = 7;
hit_object_ids[1] = 10;
super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
super_object_ids, MAX_ITEM_NUM);
EXPECT_EQ(super_object_cnt, 5);
EXPECT_EQ(super_object_ids[0], 2);
@@ -479,7 +479,7 @@ TEST_F(MaatObjectExclude, level_exceed_function) {
EXPECT_EQ(super_object_ids[3], 8);
EXPECT_EQ(super_object_ids[4], 11);
object2object_runtime_free(o2o_runtime);
object_group_runtime_free(object_group_runtime);
}
int main(int argc, char ** argv)