2023-01-30 21:59:35 +08:00
|
|
|
/*
|
|
|
|
|
**********************************************************************************************
|
|
|
|
|
* File: maat_compile.h
|
|
|
|
|
* Description:
|
|
|
|
|
* Authors: Zheng Chao <zhengchao@geedgenetworks.com>
|
|
|
|
|
* Date: 2022-10-31
|
|
|
|
|
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
|
|
|
|
***********************************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _MAAT_COMPILE_H_
|
|
|
|
|
#define _MAAT_COMPILE_H_
|
|
|
|
|
|
2023-02-15 11:53:46 +08:00
|
|
|
#ifdef __cplusplus
|
2023-01-30 21:59:35 +08:00
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "cJSON/cJSON.h"
|
2023-02-15 11:53:46 +08:00
|
|
|
#include "maat.h"
|
2023-01-30 21:59:35 +08:00
|
|
|
#include "maat_kv.h"
|
|
|
|
|
#include "maat_rule.h"
|
|
|
|
|
|
|
|
|
|
struct compile_ex_data_schema {
|
|
|
|
|
maat_rule_ex_new_func_t *new_func;
|
|
|
|
|
maat_rule_ex_free_func_t *free_func;
|
|
|
|
|
maat_rule_ex_dup_func_t *dup_func;
|
|
|
|
|
long argl;
|
|
|
|
|
void *argp;
|
|
|
|
|
int idx;
|
|
|
|
|
int table_id;
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-15 11:53:46 +08:00
|
|
|
struct compile_schema;
|
|
|
|
|
struct compile_runtime;
|
|
|
|
|
struct maat_compile_state;
|
|
|
|
|
struct group2group_runtime;
|
|
|
|
|
|
2023-01-30 21:59:35 +08:00
|
|
|
/* compile schema API */
|
2023-02-03 17:28:14 +08:00
|
|
|
void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
|
|
|
|
const char *table_name, struct log_handle *logger);
|
2023-01-30 21:59:35 +08:00
|
|
|
void compile_schema_free(void *compile_schema);
|
|
|
|
|
|
2023-02-03 17:28:14 +08:00
|
|
|
void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
|
|
|
|
const char *table_name, struct log_handle *logger);
|
2023-01-30 21:59:35 +08:00
|
|
|
void group2compile_schema_free(void *g2c_schema);
|
2023-01-31 20:39:53 +08:00
|
|
|
int group2compile_associated_compile_table_id(void *g2c_schema);
|
2023-01-30 21:59:35 +08:00
|
|
|
|
2023-02-03 17:28:14 +08:00
|
|
|
int compile_table_set_rule_ex_data_schema(struct compile_schema *compile_schema,
|
|
|
|
|
int table_id,
|
2023-01-30 21:59:35 +08:00
|
|
|
maat_rule_ex_new_func_t *new_func,
|
|
|
|
|
maat_rule_ex_free_func_t *free_func,
|
|
|
|
|
maat_rule_ex_dup_func_t *dup_func,
|
|
|
|
|
long argl, void *argp,
|
|
|
|
|
struct log_handle *logger);
|
2023-02-22 15:08:52 +08:00
|
|
|
void *compile_table_get_rule_ex_data(struct compile_schema *compile_schema, uint64_t compile_id, size_t idx);
|
2023-02-21 11:27:18 +08:00
|
|
|
void compile_table_rule_ex_data_iterate(struct compile_schema *compile_schema, int idx);
|
2023-01-30 21:59:35 +08:00
|
|
|
|
|
|
|
|
size_t compile_table_rule_ex_data_schema_count(struct compile_schema *compile_schema);
|
|
|
|
|
|
|
|
|
|
/* compile runtime API */
|
2023-02-03 17:28:14 +08:00
|
|
|
void *compile_runtime_new(void *compile_schema, int max_thread_num,
|
|
|
|
|
struct maat_garbage_bin *garbage_bin,
|
2023-01-30 21:59:35 +08:00
|
|
|
struct log_handle *logger);
|
|
|
|
|
void compile_runtime_free(void *compile_runtime);
|
|
|
|
|
|
2023-02-03 17:28:14 +08:00
|
|
|
int compile_runtime_update(void *compile_runtime, void *compile_schema,
|
|
|
|
|
const char *line, int valid_column);
|
2023-02-09 22:13:15 +08:00
|
|
|
int compile_runtime_commit(void *compile_runtime, const char *table_name);
|
2023-01-30 21:59:35 +08:00
|
|
|
|
2023-02-22 15:08:52 +08:00
|
|
|
int compile_runtime_match(struct compile_runtime *compile_rt, uint64_t *compile_ids,
|
2023-02-03 17:28:14 +08:00
|
|
|
size_t compile_ids_size, struct maat_state *state);
|
2023-01-30 21:59:35 +08:00
|
|
|
|
2023-02-03 17:28:14 +08:00
|
|
|
size_t compile_runtime_get_hit_paths(struct compile_runtime *compile_rt,
|
|
|
|
|
struct group2group_runtime *g2g_rt,
|
2023-01-31 20:39:53 +08:00
|
|
|
struct maat_compile_state *compile_state,
|
2023-02-03 17:28:14 +08:00
|
|
|
struct maat_hit_path *hit_paths,
|
2023-02-20 10:57:40 +08:00
|
|
|
size_t hit_path_index, size_t n_hit_path);
|
2023-01-30 21:59:35 +08:00
|
|
|
/* group2compile runtime API */
|
2023-02-03 17:28:14 +08:00
|
|
|
void *group2compile_runtime_new(void *g2c_schema, int max_thread_num,
|
|
|
|
|
struct maat_garbage_bin *garbage_bin,
|
2023-01-30 21:59:35 +08:00
|
|
|
struct log_handle *logger);
|
2023-01-31 20:39:53 +08:00
|
|
|
void group2compile_runtime_init(void *g2c_runtime, void *compile_runtime, void *g2g_runtime);
|
2023-01-30 21:59:35 +08:00
|
|
|
void group2compile_runtime_free(void *g2c_runtime);
|
|
|
|
|
|
2023-02-03 17:28:14 +08:00
|
|
|
int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
|
|
|
|
|
const char *line, int valid_column);
|
2023-01-30 21:59:35 +08:00
|
|
|
|
|
|
|
|
/* maat compile state API */
|
|
|
|
|
struct maat_compile_state;
|
|
|
|
|
struct maat_compile_state *maat_compile_state_new(int thread_id);
|
|
|
|
|
void maat_compile_state_free(struct maat_compile_state *compile_state);
|
2023-02-03 17:28:14 +08:00
|
|
|
|
|
|
|
|
int maat_compile_state_update(struct maat_item *item_hash, int vtable_id,
|
2023-02-22 15:08:52 +08:00
|
|
|
uint64_t *hit_item_ids, size_t hit_item_cnt,
|
2023-02-03 17:28:14 +08:00
|
|
|
size_t *n_hit_group_id, struct maat_state *state);
|
|
|
|
|
|
2023-01-30 21:59:35 +08:00
|
|
|
int maat_compile_state_has_NOT_clause(struct maat_compile_state *compile_state);
|
|
|
|
|
|
2023-02-15 11:53:46 +08:00
|
|
|
#ifdef __cplusplus
|
2023-01-30 21:59:35 +08:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|