2023-01-30 21:59:35 +08:00
|
|
|
/*
|
|
|
|
|
**********************************************************************************************
|
|
|
|
|
* File: maat_compile.h
|
|
|
|
|
* Description:
|
2023-05-04 17:10:19 +08:00
|
|
|
* Authors: Liu wentan <liuwentan@geedgenetworks.com>
|
2023-01-30 21:59:35 +08:00
|
|
|
* Date: 2022-10-31
|
2023-05-04 17:10:19 +08:00
|
|
|
* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
|
2023-01-30 21:59:35 +08:00
|
|
|
***********************************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#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-03-15 11:36:54 +08:00
|
|
|
#include "rcu_hash.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"
|
|
|
|
|
|
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-23 11:37:02 +08:00
|
|
|
int compile_table_set_ex_data_schema(struct compile_schema *compile_schema, int table_id,
|
|
|
|
|
maat_ex_new_func_t *new_func,
|
|
|
|
|
maat_ex_free_func_t *free_func,
|
|
|
|
|
maat_ex_dup_func_t *dup_func,
|
2023-04-05 21:09:19 +08:00
|
|
|
long argl, void *argp);
|
2023-01-30 21:59:35 +08:00
|
|
|
|
|
|
|
|
/* compile runtime API */
|
2023-04-20 15:34:56 +08:00
|
|
|
void *compile_runtime_new(void *compile_schema, size_t max_thread_num,
|
2023-04-13 14:56:35 +08:00
|
|
|
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-06-16 15:59:30 +08:00
|
|
|
void compile_runtime_init(void *compile_runtime, struct maat_runtime *maat_rt);
|
2023-03-15 11:36:54 +08:00
|
|
|
|
2023-06-05 15:14:45 +08:00
|
|
|
int compile_runtime_update(void *compile_runtime, void *compile_schema,
|
|
|
|
|
const char *table_name, const char *line,
|
|
|
|
|
int valid_column);
|
2023-04-13 14:56:35 +08:00
|
|
|
|
2023-06-05 15:14:45 +08:00
|
|
|
int compile_runtime_commit(void *compile_runtime, const char *table_name,
|
|
|
|
|
long long maat_rt_version);
|
2023-01-30 21:59:35 +08:00
|
|
|
|
2023-04-12 19:20:05 +08:00
|
|
|
long long compile_runtime_rule_count(void *compile_runtime);
|
|
|
|
|
|
2023-04-20 15:34:56 +08:00
|
|
|
long long compile_runtime_update_err_count(void *compile_runtime);
|
|
|
|
|
|
2023-02-22 15:22:41 +08:00
|
|
|
int compile_runtime_match(struct compile_runtime *compile_rt, long long *compile_ids,
|
2023-03-22 20:40:36 +08:00
|
|
|
size_t compile_ids_size, struct maat_state *state);
|
2023-01-30 21:59:35 +08:00
|
|
|
|
2023-06-09 16:44:47 +08:00
|
|
|
size_t compile_runtime_get_hit_paths(struct compile_runtime *compile_rt, int thread_id,
|
2023-03-27 15:52:47 +08:00
|
|
|
struct maat_compile_state *compile_state,
|
|
|
|
|
struct maat_hit_path *hit_path_array,
|
2023-05-17 14:34:34 +08:00
|
|
|
size_t array_size, size_t n_internal_hit_path);
|
2023-03-01 13:12:22 +08:00
|
|
|
|
|
|
|
|
void *compile_runtime_get_ex_data(struct compile_runtime *compile_rt,
|
|
|
|
|
struct compile_schema *compile_schema,
|
|
|
|
|
long long compile_id);
|
|
|
|
|
void compile_runtime_ex_data_iterate(struct compile_runtime *compile_rt,
|
|
|
|
|
struct compile_schema *compile_schema);
|
|
|
|
|
|
2023-01-30 21:59:35 +08:00
|
|
|
/* group2compile runtime API */
|
2023-04-20 15:34:56 +08:00
|
|
|
void *group2compile_runtime_new(void *g2c_schema, size_t max_thread_num,
|
2023-04-13 14:56:35 +08:00
|
|
|
struct maat_garbage_bin *garbage_bin,
|
2023-01-30 21:59:35 +08:00
|
|
|
struct log_handle *logger);
|
2023-06-16 15:59:30 +08:00
|
|
|
|
2023-06-14 09:10:16 +00:00
|
|
|
void group2compile_runtime_init(void *g2c_runtime, void *compile_runtime);
|
2023-06-16 15:59:30 +08:00
|
|
|
|
2023-01-30 21:59:35 +08:00
|
|
|
void group2compile_runtime_free(void *g2c_runtime);
|
|
|
|
|
|
2023-06-05 15:14:45 +08:00
|
|
|
int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
|
|
|
|
|
const char *table_name, const char *line,
|
|
|
|
|
int valid_column);
|
2023-04-13 14:56:35 +08:00
|
|
|
|
2023-04-20 15:34:56 +08:00
|
|
|
long long group2compile_runtime_not_group_count(void *g2c_runtime);
|
|
|
|
|
|
2023-04-12 19:20:05 +08:00
|
|
|
long long group2compile_runtime_rule_count(void *g2c_runtime);
|
2023-01-30 21:59:35 +08:00
|
|
|
|
2023-04-20 15:34:56 +08:00
|
|
|
long long group2compile_runtime_update_err_count(void *g2c_runtime);
|
|
|
|
|
|
2023-01-30 21:59:35 +08:00
|
|
|
/* maat compile state API */
|
|
|
|
|
struct maat_compile_state;
|
2023-06-09 16:44:47 +08:00
|
|
|
struct maat_compile_state *maat_compile_state_new(void);
|
2023-03-23 11:57:17 +08:00
|
|
|
void maat_compile_state_reset(struct maat_compile_state *compile_state);
|
2023-06-09 17:30:20 +08:00
|
|
|
void maat_compile_state_free(struct maat_compile_state *compile_state,
|
|
|
|
|
struct maat *maat_instance, int thread_id);
|
2023-02-03 17:28:14 +08:00
|
|
|
|
2023-05-07 23:09:33 +08:00
|
|
|
void maat_compile_state_update(int vtable_id, struct maat_item *hit_items,
|
|
|
|
|
size_t n_hit_item, struct maat_state *state);
|
2023-03-06 16:45:34 +08:00
|
|
|
|
2023-03-27 15:52:47 +08:00
|
|
|
size_t maat_compile_state_get_internal_hit_paths(struct maat_compile_state *compile_state,
|
2023-05-17 14:34:34 +08:00
|
|
|
struct compile_runtime *compile_rt,
|
|
|
|
|
struct group2group_runtime *g2g_rt,
|
|
|
|
|
struct maat_hit_path *hit_path_array,
|
|
|
|
|
size_t array_size);
|
2023-06-05 15:14:45 +08:00
|
|
|
size_t maat_compile_state_get_hit_groups(struct maat_compile_state *compile_state,
|
2023-06-09 16:44:47 +08:00
|
|
|
struct group2group_runtime *g2g_rt,
|
2023-06-05 15:14:45 +08:00
|
|
|
struct maat_hit_group *hit_group_array,
|
|
|
|
|
size_t array_size);
|
2023-03-06 16:45:34 +08:00
|
|
|
|
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
|
|
|
|
|
|
2023-02-22 15:22:41 +08:00
|
|
|
#endif
|