This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-maat/src/inc_internal/maat_ex_data.h

113 lines
3.9 KiB
C
Raw Normal View History

2022-11-17 05:05:35 +08:00
/*
**********************************************************************************************
* File: maat_ex_data.h
* Description: ex data
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
* Date: 2022-10-31
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
***********************************************************************************************
*/
#ifndef _MAAT_EX_DATA_H_
#define _MAAT_EX_DATA_H_
#ifdef __cplusplus
2022-11-17 05:05:35 +08:00
extern "C"
{
#endif
#include "maat.h"
2022-11-25 16:32:29 +08:00
#include "rcu_hash.h"
#include "maat_garbage_collection.h"
2022-11-25 16:32:29 +08:00
struct ex_container {
2022-12-09 17:12:18 +08:00
void *ex_data;
void *custom_data;
};
struct ex_data_schema {
maat_ex_new_func_t *new_func;
maat_ex_free_func_t *free_func;
maat_ex_dup_func_t *dup_func;
long argl;
void *argp;
};
struct ex_container_schema {
int table_id;
struct ex_data_schema *ex_schema;
void (*user_data_free)(void *);
};
2022-11-17 05:05:35 +08:00
struct ex_data_runtime;
2022-11-25 16:32:29 +08:00
/* ex_data_runtime API */
2023-02-03 17:28:14 +08:00
struct ex_data_runtime *
ex_data_runtime_new(int table_id, rcu_hash_data_free_fn *data_free_fn,
2023-04-04 09:31:20 +08:00
struct log_handle *logger);
2022-11-17 05:05:35 +08:00
void ex_data_runtime_free(struct ex_data_runtime *ex_data_rt);
2022-11-25 16:32:29 +08:00
void ex_data_runtime_commit(struct ex_data_runtime *ex_data_rt);
/* ex_data_runtime cache row API */
void ex_data_runtime_cache_row_put(struct ex_data_runtime *ex_data_rt, const char *row);
const char *ex_data_runtime_cached_row_get(struct ex_data_runtime *ex_data_rt, size_t index);
size_t ex_data_runtime_cached_row_count(struct ex_data_runtime *ex_data_rt);
void ex_data_runtime_clear_row_cache(struct ex_data_runtime *ex_data_rt);
/* set schema API */
struct ex_data_schema *ex_data_schema_new(maat_ex_new_func_t *new_func,
maat_ex_free_func_t *free_func,
maat_ex_dup_func_t *dup_func,
2023-01-30 21:59:35 +08:00
long argl, void *argp);
void ex_data_schema_free(struct ex_data_schema *ex_schema);
2022-11-25 16:32:29 +08:00
/* set user_ctx API */
void ex_data_runtime_set_ex_container_schema(struct ex_data_runtime *ex_data_rt,
struct ex_container_schema *container_schema);
2022-12-09 17:12:18 +08:00
struct ex_container_schema *
ex_data_runtime_get_ex_container_schema(struct ex_data_runtime *ex_data_rt);
2022-11-25 16:32:29 +08:00
struct ex_container *ex_container_new(void *ex_data, void *custom_data);
void ex_container_free(void *ctx, void *data);
2023-01-30 21:59:35 +08:00
2022-11-25 16:32:29 +08:00
/* ex_data_runtime ex data API */
void *ex_data_runtime_row2ex_data(struct ex_data_runtime *ex_data_rt,
struct ex_data_schema *ex_schema,
const char *table_name, const char *row,
const char *key, size_t key_len);
2022-11-25 16:32:29 +08:00
2023-01-30 21:59:35 +08:00
int ex_data_runtime_add_ex_container(struct ex_data_runtime *ex_data_rt,
const char *key, size_t key_len,
struct ex_container *ex_container);
2022-12-09 17:12:18 +08:00
2023-01-30 21:59:35 +08:00
int ex_data_runtime_del_ex_container(struct ex_data_runtime *ex_data_rt,
const char *key, size_t key_len);
2022-11-25 16:32:29 +08:00
size_t ex_data_runtime_list_ex_container(struct ex_data_runtime *ex_data_rt,
struct ex_container ***ex_container);
size_t ex_data_runtime_ex_container_count(struct ex_data_runtime *ex_data_rt);
int ex_data_runtime_is_updating(struct ex_data_runtime *ex_data_rt);
2022-11-25 16:32:29 +08:00
void *ex_data_runtime_get_ex_data_by_key(struct ex_data_runtime *ex_data_rt,
struct ex_data_schema *ex_schema,
const char *key, size_t key_len);
2022-11-25 16:32:29 +08:00
void *ex_data_runtime_get_ex_data_by_container(struct ex_data_runtime *ex_data_rt,
struct ex_data_schema *ex_schema,
struct ex_container *ex_container);
2023-02-03 17:28:14 +08:00
void *ex_data_runtime_get_custom_data(struct ex_data_runtime *ex_data_rt,
const char *key, size_t key_len);
2022-11-25 16:32:29 +08:00
#ifdef __cplusplus
2022-11-17 05:05:35 +08:00
}
#endif
#endif