TDengine/include/server/vnode/meta/meta.h

100 lines
3 KiB
C
Raw Normal View History

2021-09-22 05:21:07 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2021-09-22 07:31:07 +00:00
#ifndef _TD_META_H_
#define _TD_META_H_
2021-09-22 05:21:07 +00:00
2021-10-08 05:35:55 +00:00
#include "taosmsg.h"
2021-09-27 06:44:18 +00:00
2021-10-08 02:38:22 +00:00
#include "os.h"
2021-09-22 05:21:07 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2021-10-15 07:13:46 +00:00
/* ------------------------ APIs Exposed ------------------------ */
2021-10-08 02:38:22 +00:00
// Types exported
2021-10-15 07:13:46 +00:00
typedef uint64_t tb_uid_t;
2021-10-12 05:42:12 +00:00
typedef struct SMeta SMeta;
typedef struct SMetaOpts SMetaOpts;
typedef struct SMetaQueryHandle SMetaQueryHandle;
typedef struct SMetaQueryOpts SMetaQueryOpts;
typedef struct STableOpts STableOpts;
2021-10-08 02:38:22 +00:00
// SMeta operations
int metaCreate(const char *path);
2021-10-12 03:41:27 +00:00
void metaDestroy(const char *path);
2021-10-12 05:42:12 +00:00
SMeta *metaOpen(SMetaOpts *);
2021-10-08 02:38:22 +00:00
void metaClose(SMeta *);
2021-10-15 06:59:35 +00:00
int metaCreateTable(SMeta *, const STableOpts *);
2021-10-08 02:38:22 +00:00
int metaDropTable(SMeta *, uint64_t tuid_t);
int metaAlterTable(SMeta *, void *);
int metaCommit(SMeta *);
// Options
2021-10-12 05:42:12 +00:00
SMetaOpts *metaOptionsCreate();
void metaOptionsDestroy(SMetaOpts *);
void metaOptionsSetCache(SMetaOpts *, size_t capacity);
2021-10-08 02:38:22 +00:00
// SMetaQueryHandle
2021-10-12 05:42:12 +00:00
SMetaQueryHandle *metaQueryHandleCreate(SMetaQueryOpts *);
2021-10-08 02:38:22 +00:00
void metaQueryHandleDestroy(SMetaQueryHandle *);
2021-09-27 02:49:36 +00:00
2021-10-12 05:42:12 +00:00
// SMetaQueryOpts
SMetaQueryOpts *metaQueryOptionsCreate();
void metaQueryOptionsDestroy(SMetaQueryOpts *);
2021-09-27 02:49:36 +00:00
2021-10-12 06:45:59 +00:00
// STableOpts
2021-10-15 09:07:37 +00:00
#define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0}
2021-10-15 07:42:01 +00:00
void metaNormalTableOptsInit(STableOpts *, const char *name, const STSchema *pSchema);
2021-10-15 09:07:37 +00:00
void metaSuperTableOptsInit(STableOpts *, const char *name, tb_uid_t uid, const STSchema *pSchema,
const STSchema *pTagSchema);
void metaChildTableOptsInit(STableOpts *, const char *name, tb_uid_t suid, const SKVRow tags);
void metaTableOptsClear(STableOpts *);
2021-10-12 06:45:59 +00:00
2021-10-15 07:13:46 +00:00
/* ------------------------ Impl should hidden ------------------------ */
2021-10-15 07:42:01 +00:00
typedef enum { META_INIT_TABLE = 0, META_SUPER_TABLE = 1, META_CHILD_TABLE = 2, META_NORMAL_TABLE = 3 } EMetaTableT;
2021-10-15 07:13:46 +00:00
typedef struct SSuperTableOpts {
tb_uid_t uid;
STSchema *pSchema; // (ts timestamp, a int)
STSchema *pTagSchema; // (tag1 binary(10), tag2 int)
} SSuperTableOpts;
typedef struct SChildTableOpts {
tb_uid_t suid; // super table uid
SKVRow tags; // tag value of the child table
} SChildTableOpts;
typedef struct SNormalTableOpts {
STSchema *pSchema;
} SNormalTableOpts;
struct STableOpts {
2021-10-15 07:42:01 +00:00
int8_t type;
char * name;
2021-10-15 07:13:46 +00:00
union {
SSuperTableOpts superOpts;
SChildTableOpts childOpts;
SNormalTableOpts normalOpts;
};
};
2021-09-22 05:21:07 +00:00
#ifdef __cplusplus
}
#endif
2021-10-08 05:35:55 +00:00
#endif /*_TD_META_H_*/