meta.h 2.1 KB
Newer Older
H
more  
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
Hongze Cheng 已提交
16 17
#ifndef _TD_VNODE_META_H_
#define _TD_VNODE_META_H_
H
more  
Hongze Cheng 已提交
18 19 20 21 22

#ifdef __cplusplus
extern "C" {
#endif

H
refact  
Hongze Cheng 已提交
23 24
typedef struct SMetaCache SMetaCache;
typedef struct SMetaIdx   SMetaIdx;
H
refact  
Hongze Cheng 已提交
25 26 27 28 29 30 31
typedef struct SMetaDB    SMetaDB;

// SMetaDB
int  metaOpenDB(SMeta* pMeta);
void metaCloseDB(SMeta* pMeta);
int  metaSaveTableToDB(SMeta* pMeta, STbCfg* pTbCfg);
int  metaRemoveTableFromDb(SMeta* pMeta, tb_uid_t uid);
C
Cary Xu 已提交
32
int  metaSaveSmaToDB(SMeta* pMeta, STSma* pTbCfg);
C
Cary Xu 已提交
33
int  metaRemoveSmaFromDb(SMeta* pMeta, int64_t indexUid);
H
refact  
Hongze Cheng 已提交
34 35 36 37 38 39 40 41

// SMetaCache
int  metaOpenCache(SMeta* pMeta);
void metaCloseCache(SMeta* pMeta);

// SMetaCfg
extern const SMetaCfg defaultMetaOptions;
// int                   metaValidateOptions(const SMetaCfg*);
H
refact  
Hongze Cheng 已提交
42
void metaOptionsCopy(SMetaCfg* pDest, const SMetaCfg* pSrc);
H
refact  
Hongze Cheng 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55

// SMetaIdx
int  metaOpenIdx(SMeta* pMeta);
void metaCloseIdx(SMeta* pMeta);
int  metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions);
int  metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid);

// STbUidGnrt
typedef struct STbUidGenerator {
  tb_uid_t nextUid;
} STbUidGenerator;

// STableUidGenerator
H
refact  
Hongze Cheng 已提交
56 57
int  metaOpenUidGnrt(SMeta* pMeta);
void metaCloseUidGnrt(SMeta* pMeta);
H
refact  
Hongze Cheng 已提交
58 59 60

// tb_uid_t
#define IVLD_TB_UID 0
H
refact  
Hongze Cheng 已提交
61
tb_uid_t metaGenerateUid(SMeta* pMeta);
H
refact  
Hongze Cheng 已提交
62

H
more  
Hongze Cheng 已提交
63
struct SMeta {
H
refact  
Hongze Cheng 已提交
64
  char*                 path;
H
refact  
Hongze Cheng 已提交
65
  SMetaCfg              options;
H
more  
Hongze Cheng 已提交
66
  SMetaDB*              pDB;
H
Hongze Cheng 已提交
67 68
  SMetaIdx*             pIdx;
  SMetaCache*           pCache;
H
refact  
Hongze Cheng 已提交
69 70
  STbUidGenerator       uidGnrt;
  SMemAllocatorFactory* pmaf;
H
more  
Hongze Cheng 已提交
71 72 73 74 75 76
};

#ifdef __cplusplus
}
#endif

H
Hongze Cheng 已提交
77
#endif /*_TD_VNODE_META_H_*/