sdbInt.h 2.5 KB
Newer Older
S
Shengliang Guan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * 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_SDB_INT_H_
#define _TD_SDB_INT_H_

#include "os.h"
S
Shengliang Guan 已提交
20

S
Shengliang Guan 已提交
21 22 23 24
#include "sdb.h"
#include "thash.h"
#include "tlockfree.h"
#include "tlog.h"
S
Shengliang Guan 已提交
25
#include "tmsg.h"
S
Shengliang Guan 已提交
26 27 28 29 30

#ifdef __cplusplus
extern "C" {
#endif

31 32 33 34 35 36
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define mWarn(...)  { if (mDebugFlag & DEBUG_WARN)  { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define mInfo(...)  { if (mDebugFlag & DEBUG_INFO)  { taosPrintLog("MND ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
S
Shengliang Guan 已提交
37

S
Shengliang Guan 已提交
38
#define SDB_MAX_SIZE (32 * 1024)
S
Shengliang Guan 已提交
39

S
Shengliang Guan 已提交
40
typedef struct SSdbRaw {
S
Shengliang Guan 已提交
41
  int8_t  type;
S
Shengliang Guan 已提交
42
  int8_t  status;
S
Shengliang Guan 已提交
43
  int8_t  sver;
S
Shengliang Guan 已提交
44
  int8_t  reserved;
S
Shengliang Guan 已提交
45 46 47 48 49
  int32_t dataLen;
  char    pData[];
} SSdbRaw;

typedef struct SSdbRow {
S
Shengliang Guan 已提交
50
  ESdbType   type;
S
Shengliang Guan 已提交
51 52 53 54 55
  ESdbStatus status;
  int32_t    refCount;
  char       pObj[];
} SSdbRow;

S
Shengliang Guan 已提交
56
typedef struct SSdb {
S
Shengliang Guan 已提交
57
  SMnode     *pMnode;
S
Shengliang Guan 已提交
58 59 60 61 62
  char       *currDir;
  char       *syncDir;
  char       *tmpDir;
  int64_t     lastCommitVer;
  int64_t     curVer;
S
Shengliang Guan 已提交
63
  int64_t     tableVer[SDB_MAX];
S
Shengliang Guan 已提交
64
  int64_t     maxId[SDB_MAX];
S
Shengliang Guan 已提交
65 66 67 68 69 70 71 72 73
  EKeyType    keyTypes[SDB_MAX];
  SHashObj   *hashObjs[SDB_MAX];
  SRWLatch    locks[SDB_MAX];
  SdbInsertFp insertFps[SDB_MAX];
  SdbUpdateFp updateFps[SDB_MAX];
  SdbDeleteFp deleteFps[SDB_MAX];
  SdbDeployFp deployFps[SDB_MAX];
  SdbEncodeFp encodeFps[SDB_MAX];
  SdbDecodeFp decodeFps[SDB_MAX];
S
Shengliang Guan 已提交
74
} SSdb;
S
Shengliang Guan 已提交
75

S
Shengliang Guan 已提交
76 77
const char *sdbTableName(ESdbType type);
void        sdbPrintOper(SSdb *pSdb, SSdbRow *pRow, const char *oper);
S
Shengliang Guan 已提交
78

S
Shengliang Guan 已提交
79 80 81 82 83
#ifdef __cplusplus
}
#endif

#endif /*_TD_SDB_INT_H_*/