fix flag_matcher and interval_matcher compile error

This commit is contained in:
liuwentan
2023-02-07 11:25:31 +08:00
parent 4d2f783874
commit c1902f8deb
27 changed files with 1275 additions and 295 deletions

View File

@@ -8,11 +8,15 @@
***********************************************************************************************
*/
#include <assert.h>
#include "cJSON/cJSON.h"
#include "maat_kv.h"
#include "maat_utils.h"
#include "log/log.h"
#include "maat_virtual.h"
#include "maat_rule.h"
#include "maat_table.h"
#define MODULE_VIRTUAL module_name_str("maat.virtual")
@@ -25,8 +29,6 @@ struct virtual_schema {
void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger)
{
//size_t read_cnt = 0;
cJSON *item = cJSON_GetObjectItem(json, "physical_table");
if (NULL == item || item->type != cJSON_Array) {
log_error(logger, MODULE_VIRTUAL,
@@ -35,37 +37,43 @@ void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
}
struct virtual_schema *vt_schema = ALLOC(struct virtual_schema, 1);
vt_schema->tbl_mgr = tbl_mgr;
return vt_schema;
#if 0
struct virtual_schema *vt_schema = ALLOC(struct virtual_schema, 1);
int cnt = cJSON_GetArraySize(item);
for (int i = 0; i < cnt; i++) {
cJSON *tmp_item = cJSON_GetArrayItem(item, i);
if (tmp_item != NULL && tmp_item->type == cJSON_String) {
int table_id = -1;
int table_id = table_manager_get_table_id(tbl_mgr, tmp_item->valuestring);
/* physical table should already exist */
int ret = maat_kv_read(tablename2id_map, tmp_item->valuestring, &table_id);
if (ret < 0) {
return -1;
}
if (table_id < 0) {
log_error(logger, MODULE_VIRTUAL, "table:%s is not registered",
tmp_item->valuestring);
FREE(vt_schema);
return NULL;
}
enum scan_type table_scan_type = table_schema_get_scan_type(table_array[table_id]);
vt_schema->physical_table_id[table_scan_type]= table_id;
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
assert(table_type != TABLE_TYPE_INVALID);
enum scan_type scan_type = maat_table_get_scan_type(table_type);
assert(scan_type != SCAN_TYPE_INVALID);
vt_schema->physical_table_id[scan_type]= table_id;
}
}
if (read_cnt < 3) {
FREE(vt_schema);
return NULL;
}
return vt_schema;
#endif
}
void virtual_schema_free(void *virtual_schema)
{
FREE(virtual_schema);
}
int virtual_table_get_physical_table_id(void *virtual_schema, enum scan_type type)
{
if (NULL == virtual_schema) {
return -1;
}
struct virtual_schema *schema = (struct virtual_schema *)virtual_schema;
return schema->physical_table_id[type];
}