提交 2bdccc20 编写于 作者: S Shengliang Guan

minor changes

上级 c7f4f9d4
...@@ -121,11 +121,11 @@ typedef struct { ...@@ -121,11 +121,11 @@ typedef struct {
SdbInsertFp insertFp; SdbInsertFp insertFp;
SdbUpdateFp updateFp; SdbUpdateFp updateFp;
SdbDeleteFp deleteFp; SdbDeleteFp deleteFp;
} SSdbDesc; } SSdbHandle;
int32_t sdbInit(); int32_t sdbInit();
void sdbCleanup(); void sdbCleanup();
void sdbSetHandler(SSdbDesc desc); void sdbSetHandle(SSdbHandle handle);
int32_t sdbRead(); int32_t sdbRead();
int32_t sdbWrite(SSdbRaw *pRaw); int32_t sdbWrite(SSdbRaw *pRaw);
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
extern "C" { extern "C" {
#endif #endif
typedef void (*MnodeRpcFp[TSDB_MSG_TYPE_MAX])(SMnodeMsg *pMsg); typedef void (*MnodeRpcFp)(SMnodeMsg *pMsg);
tmr_h mnodeGetTimer(); tmr_h mnodeGetTimer();
int32_t mnodeGetDnodeId(); int32_t mnodeGetDnodeId();
......
...@@ -42,7 +42,7 @@ static struct { ...@@ -42,7 +42,7 @@ static struct {
SSteps *pInitSteps; SSteps *pInitSteps;
SSteps *pStartSteps; SSteps *pStartSteps;
SMnodePara para; SMnodePara para;
MnodeRpcFp msgFp; MnodeRpcFp msgFp[TSDB_MSG_TYPE_MAX];
} tsMint; } tsMint;
int32_t mnodeGetDnodeId() { return tsMint.para.dnodeId; } int32_t mnodeGetDnodeId() { return tsMint.para.dnodeId; }
......
...@@ -106,7 +106,7 @@ static int32_t mnodeCreateDefaultAcct() { ...@@ -106,7 +106,7 @@ static int32_t mnodeCreateDefaultAcct() {
.accessState = TSDB_VN_ALL_ACCCESS}; .accessState = TSDB_VN_ALL_ACCCESS};
SSdbRaw *pRaw = mnodeAcctActionEncode(&acctObj); SSdbRaw *pRaw = mnodeAcctActionEncode(&acctObj);
if (pRaw != NULL) { if (pRaw == NULL) {
return -1; return -1;
} }
...@@ -114,15 +114,15 @@ static int32_t mnodeCreateDefaultAcct() { ...@@ -114,15 +114,15 @@ static int32_t mnodeCreateDefaultAcct() {
} }
int32_t mnodeInitAcct() { int32_t mnodeInitAcct() {
SSdbDesc desc = {.sdbType = SDB_ACCT, SSdbHandle handle = {.sdbType = SDB_ACCT,
.keyType = SDB_KEY_BINARY, .keyType = SDB_KEY_BINARY,
.deployFp = (SdbDeployFp)mnodeCreateDefaultAcct, .deployFp = (SdbDeployFp)mnodeCreateDefaultAcct,
.encodeFp = (SdbEncodeFp)mnodeAcctActionEncode, .encodeFp = (SdbEncodeFp)mnodeAcctActionEncode,
.decodeFp = (SdbDecodeFp)mnodeAcctActionDecode, .decodeFp = (SdbDecodeFp)mnodeAcctActionDecode,
.insertFp = (SdbInsertFp)mnodeAcctActionInsert, .insertFp = (SdbInsertFp)mnodeAcctActionInsert,
.updateFp = (SdbUpdateFp)mnodeAcctActionUpdate, .updateFp = (SdbUpdateFp)mnodeAcctActionUpdate,
.deleteFp = (SdbDeleteFp)mnodeAcctActionDelete}; .deleteFp = (SdbDeleteFp)mnodeAcctActionDelete};
sdbSetHandler(desc); sdbSetHandle(handle);
return 0; return 0;
} }
......
...@@ -234,15 +234,15 @@ static int32_t mnodeProcessCreateUserMsg(SMnodeMsg *pMsg) { ...@@ -234,15 +234,15 @@ static int32_t mnodeProcessCreateUserMsg(SMnodeMsg *pMsg) {
} }
int32_t mnodeInitUser() { int32_t mnodeInitUser() {
SSdbDesc desc = {.sdbType = SDB_USER, SSdbHandle handle = {.sdbType = SDB_USER,
.keyType = SDB_KEY_BINARY, .keyType = SDB_KEY_BINARY,
.deployFp = (SdbDeployFp)mnodeCreateDefaultUsers, .deployFp = (SdbDeployFp)mnodeCreateDefaultUsers,
.encodeFp = (SdbEncodeFp)mnodeUserActionEncode, .encodeFp = (SdbEncodeFp)mnodeUserActionEncode,
.decodeFp = (SdbDecodeFp)mnodeUserActionDecode, .decodeFp = (SdbDecodeFp)mnodeUserActionDecode,
.insertFp = (SdbInsertFp)mnodeUserActionInsert, .insertFp = (SdbInsertFp)mnodeUserActionInsert,
.updateFp = (SdbUpdateFp)mnodeUserActionUpdate, .updateFp = (SdbUpdateFp)mnodeUserActionUpdate,
.deleteFp = (SdbDeleteFp)mnodeUserActionDelete}; .deleteFp = (SdbDeleteFp)mnodeUserActionDelete};
sdbSetHandler(desc); sdbSetHandle(handle);
return 0; return 0;
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "os.h" #include "os.h"
#include "sdb.h" #include "sdb.h"
#include "taosmsg.h" #include "taosmsg.h"
#include "tglobal.h"
#include "thash.h" #include "thash.h"
#include "tlockfree.h" #include "tlockfree.h"
#include "tlog.h" #include "tlog.h"
...@@ -35,7 +34,7 @@ extern "C" { ...@@ -35,7 +34,7 @@ extern "C" {
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }} #define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }} #define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
#define SDB_MAX_SIZE (32*1024) #define SDB_MAX_SIZE (32 * 1024)
typedef struct { typedef struct {
char *currDir; char *currDir;
...@@ -52,13 +51,13 @@ typedef struct { ...@@ -52,13 +51,13 @@ typedef struct {
SdbDeployFp deployFps[SDB_MAX]; SdbDeployFp deployFps[SDB_MAX];
SdbEncodeFp encodeFps[SDB_MAX]; SdbEncodeFp encodeFps[SDB_MAX];
SdbDecodeFp decodeFps[SDB_MAX]; SdbDecodeFp decodeFps[SDB_MAX];
} SSdbObj; } SSdbMgr;
typedef struct { typedef struct {
ESdbStatus status; ESdbStatus status;
int32_t refCount; int32_t refCount;
int32_t dataLen; int32_t dataLen;
char *data[]; char pData[];
} SSdbRow; } SSdbRow;
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -15,8 +15,9 @@ ...@@ -15,8 +15,9 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "sdbInt.h" #include "sdbInt.h"
#include "tglobal.h"
static SSdbObj tsSdb = {0}; static SSdbMgr tsSdb = {0};
static int32_t sdbCreateDir() { static int32_t sdbCreateDir() {
if (!taosMkDir(tsSdb.currDir)) { if (!taosMkDir(tsSdb.currDir)) {
...@@ -153,7 +154,7 @@ static int32_t sdbWriteDataFile() { ...@@ -153,7 +154,7 @@ static int32_t sdbWriteDataFile() {
SSdbRow *pRow = taosHashIterate(hash, NULL); SSdbRow *pRow = taosHashIterate(hash, NULL);
while (pRow != NULL) { while (pRow != NULL) {
if (pRow->status == SDB_STATUS_READY) continue; if (pRow->status == SDB_STATUS_READY) continue;
SSdbRaw *pRaw = (*encodeFp)(pRow->data); SSdbRaw *pRaw = (*encodeFp)(pRow->pData);
if (pRaw != NULL) { if (pRaw != NULL) {
taosWriteFile(fd, pRaw, sizeof(SSdbRaw) + pRaw->dataLen); taosWriteFile(fd, pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
} else { } else {
...@@ -292,15 +293,15 @@ void sdbCleanup() { ...@@ -292,15 +293,15 @@ void sdbCleanup() {
} }
} }
void sdbSetHandler(SSdbDesc desc) { void sdbSetHandle(SSdbHandle handle) {
ESdbType sdb = desc.sdbType; ESdbType sdb = handle.sdbType;
tsSdb.keyTypes[sdb] = desc.keyType; tsSdb.keyTypes[sdb] = handle.keyType;
tsSdb.insertFps[sdb] = desc.insertFp; tsSdb.insertFps[sdb] = handle.insertFp;
tsSdb.updateFps[sdb] = desc.updateFp; tsSdb.updateFps[sdb] = handle.updateFp;
tsSdb.deleteFps[sdb] = desc.deleteFp; tsSdb.deleteFps[sdb] = handle.deleteFp;
tsSdb.deployFps[sdb] = desc.deployFp; tsSdb.deployFps[sdb] = handle.deployFp;
tsSdb.encodeFps[sdb] = desc.encodeFp; tsSdb.encodeFps[sdb] = handle.encodeFp;
tsSdb.decodeFps[sdb] = desc.decodeFp; tsSdb.decodeFps[sdb] = handle.decodeFp;
} }
#if 0 #if 0
...@@ -370,7 +371,7 @@ void *sdbAcquire(ESdbType sdb, void *pKey) { ...@@ -370,7 +371,7 @@ void *sdbAcquire(ESdbType sdb, void *pKey) {
if (pRow->status == SDB_STATUS_READY) { if (pRow->status == SDB_STATUS_READY) {
atomic_add_fetch_32(&pRow->refCount, 1); atomic_add_fetch_32(&pRow->refCount, 1);
return pRow->data; return pRow->pData;
} else { } else {
terrno = -1; // todo terrno = -1; // todo
return NULL; return NULL;
......
...@@ -223,14 +223,14 @@ int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) { ...@@ -223,14 +223,14 @@ int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
} }
int32_t trnInit() { int32_t trnInit() {
SSdbDesc desc = {.sdbType = SDB_TRANS, SSdbHandle handle = {.sdbType = SDB_TRANS,
.keyType = SDB_KEY_INT32, .keyType = SDB_KEY_INT32,
.encodeFp = (SdbEncodeFp)trnActionEncode, .encodeFp = (SdbEncodeFp)trnActionEncode,
.decodeFp = (SdbDecodeFp)trnActionDecode, .decodeFp = (SdbDecodeFp)trnActionDecode,
.insertFp = (SdbInsertFp)trnActionInsert, .insertFp = (SdbInsertFp)trnActionInsert,
.updateFp = (SdbUpdateFp)trnActionUpdate, .updateFp = (SdbUpdateFp)trnActionUpdate,
.deleteFp = (SdbDeleteFp)trnActionDelete}; .deleteFp = (SdbDeleteFp)trnActionDelete};
sdbSetHandler(desc); sdbSetHandle(handle);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册