metaDef.h 2.0 KB
Newer Older
H
more  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * 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/>.
 */

#ifndef _TD_META_DEF_H_
#define _TD_META_DEF_H_

H
refact  
Hongze Cheng 已提交
19 20
#include "mallocator.h"

H
more  
Hongze Cheng 已提交
21
#include "meta.h"
H
more  
Hongze Cheng 已提交
22 23 24 25 26

#ifdef __cplusplus
extern "C" {
#endif

H
refact  
Hongze Cheng 已提交
27 28
typedef struct SMetaCache SMetaCache;
typedef struct SMetaIdx   SMetaIdx;
H
refact  
Hongze Cheng 已提交
29 30 31 32 33 34 35
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);
H
refact  
Hongze Cheng 已提交
36 37 38 39 40 41 42 43

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

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

// 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 已提交
58 59
int  metaOpenUidGnrt(SMeta* pMeta);
void metaCloseUidGnrt(SMeta* pMeta);
H
refact  
Hongze Cheng 已提交
60 61 62

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

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

#ifdef __cplusplus
}
#endif

#endif /*_TD_META_DEF_H_*/