tsdbDef.h 2.2 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 18
#ifndef _TD_TSDB_DEF_H_
#define _TD_TSDB_DEF_H_

wafwerar's avatar
wafwerar 已提交
19
#include "tsdbDBDef.h"
S
Shengliang Guan 已提交
20
#include "tmallocator.h"
H
more  
Hongze Cheng 已提交
21
#include "meta.h"
H
Hongze Cheng 已提交
22
#include "tcompression.h"
H
Hongze Cheng 已提交
23
#include "tglobal.h"
H
Hongze Cheng 已提交
24
#include "thash.h"
H
Hongze Cheng 已提交
25 26
#include "tlist.h"
#include "tmsg.h"
H
Hongze Cheng 已提交
27
#include "tskiplist.h"
H
Hongze Cheng 已提交
28
#include "ttime.h"
H
refact  
Hongze Cheng 已提交
29

H
refact  
Hongze Cheng 已提交
30
#include "tsdb.h"
H
Hongze Cheng 已提交
31
#include "tsdbCommit.h"
H
Hongze Cheng 已提交
32
#include "tsdbFS.h"
H
Hongze Cheng 已提交
33
#include "tsdbFile.h"
H
Hongze Cheng 已提交
34
#include "tsdbLog.h"
H
refact  
Hongze Cheng 已提交
35
#include "tsdbMemTable.h"
H
Hongze Cheng 已提交
36
#include "tsdbMemory.h"
H
refact  
Hongze Cheng 已提交
37
#include "tsdbOptions.h"
H
Hongze Cheng 已提交
38
#include "tsdbReadImpl.h"
C
Cary Xu 已提交
39
#include "tsdbSma.h"
H
refact  
Hongze Cheng 已提交
40

41

H
refact  
Hongze Cheng 已提交
42 43 44 45
#ifdef __cplusplus
extern "C" {
#endif

H
refact  
Hongze Cheng 已提交
46
struct STsdb {
H
Hongze Cheng 已提交
47
  int32_t               vgId;
C
Cary Xu 已提交
48
  bool                  repoLocked;
C
Cary Xu 已提交
49
  TdThreadMutex         mutex;
H
refact  
Hongze Cheng 已提交
50
  char *                path;
H
Hongze Cheng 已提交
51
  STsdbCfg              config;
H
Hongze Cheng 已提交
52 53
  STsdbMemTable *       mem;
  STsdbMemTable *       imem;
H
Hongze Cheng 已提交
54
  SRtn                  rtn;
H
refact  
Hongze Cheng 已提交
55
  SMemAllocatorFactory *pmaf;
H
more  
Hongze Cheng 已提交
56
  STsdbFS *             fs;
H
more  
Hongze Cheng 已提交
57
  SMeta *               pMeta;
S
Shengliang Guan 已提交
58
  STfs *                pTfs;
C
Cary Xu 已提交
59
  SSmaEnvs              smaEnvs;
H
refact  
Hongze Cheng 已提交
60 61
};

C
Cary Xu 已提交
62 63 64 65 66 67 68 69 70 71
#define REPO_ID(r)        ((r)->vgId)
#define REPO_CFG(r)       (&(r)->config)
#define REPO_FS(r)        ((r)->fs)
#define REPO_META(r)      ((r)->pMeta)
#define REPO_TFS(r)       ((r)->pTfs)
#define IS_REPO_LOCKED(r) ((r)->repoLocked)
#define REPO_TSMA_NUM(r)  ((r)->smaEnvs.nTSma)
#define REPO_RSMA_NUM(r)  ((r)->smaEnvs.nRSma)
#define REPO_TSMA_ENV(r)  ((r)->smaEnvs.pTSmaEnv)
#define REPO_RSMA_ENV(r)  ((r)->smaEnvs.pRSmaEnv)
C
Cary Xu 已提交
72 73 74

int tsdbLockRepo(STsdb *pTsdb);
int tsdbUnlockRepo(STsdb *pTsdb);
H
Hongze Cheng 已提交
75

H
Hongze Cheng 已提交
76 77 78 79
static FORCE_INLINE STSchema *tsdbGetTableSchemaImpl(STable *pTable, bool lock, bool copy, int32_t version) {
  return pTable->pSchema;
}

H
refact  
Hongze Cheng 已提交
80 81 82 83
#ifdef __cplusplus
}
#endif

L
Liu Jicong 已提交
84
#endif /*_TD_TSDB_DEF_H_*/