catalogInt.h 3.3 KB
Newer Older
H
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * 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_CATALOG_INT_H_
#define _TD_CATALOG_INT_H_

#ifdef __cplusplus
extern "C" {
#endif

H
Haojun Liao 已提交
23
#include "catalog.h"
D
dapan1121 已提交
24 25
#include "common.h"
#include "tlog.h"
H
Haojun Liao 已提交
26

D
dapan1121 已提交
27 28 29 30
#define CTG_DEFAULT_CACHE_CLUSTER_NUMBER 6
#define CTG_DEFAULT_CACHE_VGROUP_NUMBER 100
#define CTG_DEFAULT_CACHE_DB_NUMBER 20
#define CTG_DEFAULT_CACHE_TABLEMETA_NUMBER 100000
D
dapan1121 已提交
31 32

#define CTG_DEFAULT_INVALID_VERSION (-1)
D
dapan 已提交
33

D
dapan1121 已提交
34 35
typedef struct SVgroupListCache {
  int32_t vgroupVersion;
D
dapan1121 已提交
36
  SHashObj *cache;        // key:vgId, value:SVgroupInfo
D
dapan1121 已提交
37 38 39 40 41
} SVgroupListCache;

typedef struct SDBVgroupCache {
  SHashObj *cache;      //key:dbname, value:SDBVgroupInfo
} SDBVgroupCache;
D
dapan1121 已提交
42

D
dapan1121 已提交
43
typedef struct STableMetaCache {
D
dapan1121 已提交
44 45
  SHashObj *cache;           //key:fulltablename, value:STableMeta
  SHashObj *stableCache;     //key:suid, value:STableMeta*
D
dapan1121 已提交
46 47 48 49
} STableMetaCache;

typedef struct SCatalog {
  SVgroupListCache vgroupCache;
D
dapan1121 已提交
50 51
  SDBVgroupCache   dbCache;
  STableMetaCache  tableCache;
H
Haojun Liao 已提交
52 53
} SCatalog;

D
dapan1121 已提交
54 55
typedef struct SCatalogMgmt {
  void       *pMsgSender;   // used to send messsage to mnode to fetch necessary metadata
D
dapan 已提交
56
  SHashObj   *pCluster;     // items cached for each cluster, the hash key is the cluster-id got from mgmt node
D
dapan1121 已提交
57
  SCatalogCfg cfg;
D
dapan1121 已提交
58 59
} SCatalogMgmt;

D
dapan1121 已提交
60
typedef uint32_t (*tableNameHashFp)(const char *, uint32_t);
D
dapan 已提交
61

D
dapan1121 已提交
62 63 64 65 66 67 68
#define ctgFatal(...)  do { if (ctgDebugFlag & DEBUG_FATAL) { taosPrintLog("CTG FATAL ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgError(...)  do { if (ctgDebugFlag & DEBUG_ERROR) { taosPrintLog("CTG ERROR ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgWarn(...)   do { if (ctgDebugFlag & DEBUG_WARN)  { taosPrintLog("CTG WARN ", ctgDebugFlag, __VA_ARGS__); }}  while(0)
#define ctgInfo(...)   do { if (ctgDebugFlag & DEBUG_INFO)  { taosPrintLog("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgDebug(...)  do { if (ctgDebugFlag & DEBUG_DEBUG) { taosPrintLog("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgTrace(...)  do { if (ctgDebugFlag & DEBUG_TRACE) { taosPrintLog("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgDebugL(...) do { if (ctgDebugFlag & DEBUG_DEBUG) { taosPrintLongString("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
D
dapan 已提交
69 70


D
dapan1121 已提交
71 72 73 74
#define CTG_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define CTG_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define CTG_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { ctgError(__VA_ARGS__); terrno = _code; return _code; } } while (0)
#define CTG_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
D
dapan 已提交
75

H
Hongze Cheng 已提交
76 77 78 79
#ifdef __cplusplus
}
#endif

D
dapan 已提交
80
#endif /*_TD_CATALOG_INT_H_*/