From d4cb8e981d2304cdca11a927abb374ab4b5a0b20 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 9 Feb 2022 02:22:46 +0000 Subject: [PATCH] more TDB --- source/dnode/vnode/inc/vnode.h | 23 ++++++++++++----------- source/dnode/vnode/src/inc/vnd.h | 3 +-- source/libs/tdb/inc/tdb.h | 7 +++++++ source/libs/tdb/src/db/tdb.c | 31 +++++++++++++++++++++++++++++++ source/libs/tdb/src/inc/btree.h | 3 +++ 5 files changed, 54 insertions(+), 13 deletions(-) diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 7549772613..26e10f9c5c 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -42,8 +42,9 @@ typedef struct STqCfg { typedef struct SVnodeCfg { int32_t vgId; - SDnode *pDnode; - STfs *pTfs; + int64_t dbId; + SDnode * pDnode; + STfs * pTfs; uint64_t wsize; uint64_t ssize; uint64_t lsize; @@ -59,9 +60,9 @@ typedef struct SVnodeCfg { typedef struct { int32_t sver; - const char *timezone; - const char *locale; - const char *charset; + const char * timezone; + const char * locale; + const char * charset; uint16_t nthreads; // number of commit threads. 0 for no threads and a schedule queue should be given (TODO) PutReqToVQueryQFp putReqToVQueryQFp; SendReqToDnodeFp sendReqToDnodeFp; @@ -70,16 +71,16 @@ typedef struct { typedef struct STqReadHandle { int64_t ver; uint64_t tbUid; - SHashObj *tbIdHash; + SHashObj * tbIdHash; const SSubmitMsg *pMsg; - SSubmitBlk *pBlock; + SSubmitBlk * pBlock; SSubmitMsgIter msgIter; SSubmitBlkIter blkIter; - SMeta *pVnodeMeta; - SArray *pColIdList; // SArray + SMeta * pVnodeMeta; + SArray * pColIdList; // SArray int32_t sver; - SSchemaWrapper *pSchemaWrapper; - STSchema *pSchema; + SSchemaWrapper * pSchemaWrapper; + STSchema * pSchema; } STqReadHandle; /* ------------------------ SVnode ------------------------ */ diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index f442697fb0..fb81ddbc5c 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -23,8 +23,8 @@ #include "tlist.h" #include "tlockfree.h" #include "tmacro.h" -#include "wal.h" #include "tq.h" +#include "wal.h" #include "vnode.h" @@ -175,7 +175,6 @@ void* vmaMalloc(SVMemAllocator* pVMA, uint64_t size); void vmaFree(SVMemAllocator* pVMA, void* ptr); bool vmaIsFull(SVMemAllocator* pVMA); - #ifdef __cplusplus } #endif diff --git a/source/libs/tdb/inc/tdb.h b/source/libs/tdb/inc/tdb.h index 71ac3d97ed..de83824170 100644 --- a/source/libs/tdb/inc/tdb.h +++ b/source/libs/tdb/inc/tdb.h @@ -22,6 +22,13 @@ extern "C" { #endif +typedef struct STDb TDB; + +int tdbCreate(TDB **ppDb); +int tdbDestroy(TDB *pDb); +int tdbOpen(TDB **pDb); +int tdbClose(TDB *pDb); + #ifdef __cplusplus } #endif diff --git a/source/libs/tdb/src/db/tdb.c b/source/libs/tdb/src/db/tdb.c index e75c6da00b..ea819b34e7 100644 --- a/source/libs/tdb/src/db/tdb.c +++ b/source/libs/tdb/src/db/tdb.c @@ -19,3 +19,34 @@ struct STDb { // TODO SBTree *pBt; }; + +int tdbCreate(TDB **ppDb) { + TDB *pDb; + + pDb = (TDB *)calloc(1, sizeof(*pDb)); + if (pDb == NULL) { + return -1; + } + + /* TODO */ + + return 0; +} + +int tdbDestroy(TDB *pDb) { + if (pDb) { + free(pDb); + } + /* TODO */ + return 0; +} + +int tdbOpen(TDB **pDb) { + // TODO + return 0; +} + +int tdbClose(TDB *pDb) { + // TODO + return 0; +} \ No newline at end of file diff --git a/source/libs/tdb/src/inc/btree.h b/source/libs/tdb/src/inc/btree.h index de143fa3a5..4b6fe589a9 100644 --- a/source/libs/tdb/src/inc/btree.h +++ b/source/libs/tdb/src/inc/btree.h @@ -28,6 +28,9 @@ int btreeOpen(SBTree **ppBt); int btreeClose(SBTree *pBt); // SBtCursor +int btreeCursorOpen(SBtCursor *pBtCur, SBTree *pBt); +int btreeCursorClose(SBtCursor *pBtCur); +int btreeCursorMoveTo(SBtCursor *pBtCur); #ifdef __cplusplus } -- GitLab