meta.h 2.8 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

H
refact  
Hongze Cheng 已提交
16 17
#ifndef _TD_META_H_
#define _TD_META_H_
H
refact  
Hongze Cheng 已提交
18

S
Shengliang Guan 已提交
19
#include "tmallocator.h"
H
more  
Hongze Cheng 已提交
20
#include "tmsg.h"
H
more  
Hongze Cheng 已提交
21
#include "trow.h"
H
more  
Hongze Cheng 已提交
22

H
refact  
Hongze Cheng 已提交
23 24 25 26
#ifdef __cplusplus
extern "C" {
#endif

L
fix  
Liu Jicong 已提交
27 28
#define META_SUPER_TABLE  TD_SUPER_TABLE
#define META_CHILD_TABLE  TD_CHILD_TABLE
H
Hongze Cheng 已提交
29 30
#define META_NORMAL_TABLE TD_NORMAL_TABLE

H
more  
Hongze Cheng 已提交
31
// Types exported
H
refact  
Hongze Cheng 已提交
32 33 34 35 36 37 38
typedef struct SMeta SMeta;

typedef struct SMetaCfg {
  /// LRU cache size
  uint64_t lruSize;
} SMetaCfg;

H
more  
Hongze Cheng 已提交
39 40
typedef struct SMTbCursor  SMTbCursor;
typedef struct SMCtbCursor SMCtbCursor;
C
Cary Xu 已提交
41
typedef struct SMSmaCursor SMSmaCursor;
H
more  
Hongze Cheng 已提交
42

C
Cary Xu 已提交
43 44
typedef SVCreateTbReq   STbCfg;
typedef SVCreateTSmaReq SSmaCfg;
H
more  
Hongze Cheng 已提交
45 46

// SMeta operations
C
Cary Xu 已提交
47 48 49 50 51 52 53 54
SMeta * metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF);
void    metaClose(SMeta *pMeta);
void    metaRemove(const char *path);
int     metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg);
int     metaDropTable(SMeta *pMeta, tb_uid_t uid);
int     metaCommit(SMeta *pMeta);
int32_t metaCreateTSma(SMeta *pMeta, SSmaCfg *pCfg);
int32_t metaDropTSma(SMeta *pMeta, char *indexName);
H
more  
Hongze Cheng 已提交
55

H
more  
Hongze Cheng 已提交
56
// For Query
C
Cary Xu 已提交
57 58
STbCfg *        metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid);
STbCfg *        metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid);
H
Hongze Cheng 已提交
59
SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline);
C
Cary Xu 已提交
60
STSchema *      metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver);
C
Cary Xu 已提交
61 62
STSma *         metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid);
STSmaWrapper *  metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid);
C
Cary Xu 已提交
63
SArray *        metaGetSmaTbUids(SMeta *pMeta, bool isDup);
D
dapan1121 已提交
64
int             metaGetTbNum(SMeta *pMeta);
H
more  
Hongze Cheng 已提交
65

H
more  
Hongze Cheng 已提交
66 67
SMTbCursor *metaOpenTbCursor(SMeta *pMeta);
void        metaCloseTbCursor(SMTbCursor *pTbCur);
C
Cary Xu 已提交
68
char *      metaTbCursorNext(SMTbCursor *pTbCur);
H
more  
Hongze Cheng 已提交
69

H
more  
Hongze Cheng 已提交
70 71
SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid);
void         metaCloseCtbCurosr(SMCtbCursor *pCtbCur);
72
tb_uid_t     metaCtbCursorNext(SMCtbCursor *pCtbCur);
H
more  
Hongze Cheng 已提交
73

C
Cary Xu 已提交
74 75 76 77
SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid);
void         metaCloseSmaCurosr(SMSmaCursor *pSmaCur);
const char * metaSmaCursorNext(SMSmaCursor *pSmaCur);

H
more  
Hongze Cheng 已提交
78
// Options
H
more  
Hongze Cheng 已提交
79 80
void metaOptionsInit(SMetaCfg *pMetaCfg);
void metaOptionsClear(SMetaCfg *pMetaCfg);
H
refact  
Hongze Cheng 已提交
81

H
refact  
Hongze Cheng 已提交
82 83 84 85
#ifdef __cplusplus
}
#endif

D
dapan1121 已提交
86
#endif /*_TD_META_H_*/