From 3eefc938302af19e06fe24cead3ae6ec77967120 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 31 May 2022 07:34:39 +0000 Subject: [PATCH] more code --- source/dnode/vnode/src/inc/tsdb.h | 10 ++++ source/dnode/vnode/src/tsdb/tsdbMemTable2.c | 65 ++++++++++++--------- 2 files changed, 46 insertions(+), 29 deletions(-) diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index e5f163a03b..2283f919bc 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -32,6 +32,11 @@ extern "C" { #define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSDB ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0) // clang-format on +typedef struct TSDBKEY TSDBKEY; + +// tsdbMemTable2.c ============================================================================================== +typedef struct SMemTable SMemTable; + // tsdbMemTable ================ typedef struct STsdbRow STsdbRow; typedef struct STbData STbData; @@ -851,6 +856,11 @@ struct STsdbRow { STSRow row; }; +struct TSDBKEY { + int64_t version; + TSKEY ts; +}; + #endif #ifdef __cplusplus diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable2.c b/source/dnode/vnode/src/tsdb/tsdbMemTable2.c index 690e1baf73..f8304be783 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable2.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable2.c @@ -15,27 +15,45 @@ #include "tsdb.h" -typedef struct SMemTable SMemTable; -typedef struct SMemData SMemData; -typedef struct SMemSkipList SMemSkipList; -typedef struct SMemSkipListNode SMemSkipListNode; -typedef struct SMemSkipListCurosr SMemSkipListCurosr; +typedef struct SMemData SMemData; +// typedef struct SMemSkipList SMemSkipList; +// typedef struct SMemSkipListNode SMemSkipListNode; +// typedef struct SMemSkipListCurosr SMemSkipListCurosr; -#define SL_MAX_LEVEL 5 +struct SMemData { + tb_uid_t suid; + tb_uid_t uid; + TSDBKEY minKey; + TSDBKEY maxKey; + int64_t nRows; + SMemData *pHashNext; +}; struct SMemTable { - STsdb *pTsdb; - TSKEY minKey; - TSKEY maxKey; - int64_t minVer; - int64_t maxVer; - int64_t nRows; - int32_t nHash; - int32_t nBucket; - SMemData **pBuckets; - SMemSkipListCurosr *pSlc; + STsdb *pTsdb; + int32_t nRef; + TSDBKEY minKey; + TSDBKEY maxKey; + int64_t nRows; + SArray *pArray; }; +int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable) { + int32_t code = 0; + // TODO + return code; +} + +int32_t tsdbMemTableDestroy(SMemTable *pMemTable) { + int32_t code = 0; + // TODO + return code; +} + +#if 0 + +#define SL_MAX_LEVEL 5 + struct SMemSkipListNode { int8_t level; SMemSkipListNode *forwards[1]; // Windows does not allow 0 @@ -49,18 +67,6 @@ struct SMemSkipList { SMemSkipListNode pHead[1]; // Windows does not allow 0 }; -struct SMemData { - SMemData *pHashNext; - tb_uid_t suid; - tb_uid_t uid; - TSKEY minKey; - TSKEY maxKey; - int64_t minVer; - int64_t maxVer; - int64_t nRows; - SMemSkipList sl; -}; - struct SMemSkipListCurosr { SMemSkipList *pSl; SMemSkipListNode *pNodes[SL_MAX_LEVEL]; @@ -377,4 +383,5 @@ static SMemSkipListNode *tsdbMemSkipListNodeCreate(SVBufPool *pPool, SMemSkipLis } return pNode; -} \ No newline at end of file +} +#endif \ No newline at end of file -- GitLab