sdbInt.h 2.3 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
#include "sdb.h"
S
Shengliang Guan 已提交
21
#include "taosmsg.h"
S
Shengliang Guan 已提交
22 23 24
#include "thash.h"
#include "tlockfree.h"
#include "tlog.h"
S
Shengliang Guan 已提交
25 26 27 28 29 30 31 32 33 34 35 36

#ifdef __cplusplus
extern "C" {
#endif

#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", 255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", 255, __VA_ARGS__); }}
#define mWarn(...)  { if (mDebugFlag & DEBUG_WARN)  { taosPrintLog("MND WARN ", 255, __VA_ARGS__); }}
#define mInfo(...)  { if (mDebugFlag & DEBUG_INFO)  { taosPrintLog("MND ", 255, __VA_ARGS__); }}
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}

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

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

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

S
Shengliang Guan 已提交
55
typedef struct SSdb {
S
Shengliang Guan 已提交
56
  SMnode     *pMnode;
S
Shengliang Guan 已提交
57 58 59 60 61
  char       *currDir;
  char       *syncDir;
  char       *tmpDir;
  int64_t     lastCommitVer;
  int64_t     curVer;
S
Shengliang Guan 已提交
62
  int32_t     maxId[SDB_MAX];
S
Shengliang Guan 已提交
63 64 65 66 67 68 69 70 71
  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 已提交
72
} SSdb;
S
Shengliang Guan 已提交
73

S
Shengliang Guan 已提交
74
int32_t sdbWriteFile(SSdb *pSdb);
S
Shengliang Guan 已提交
75

S
Shengliang Guan 已提交
76 77 78 79 80
#ifdef __cplusplus
}
#endif

#endif /*_TD_SDB_INT_H_*/