diff --git a/source/dnode/vnode/tsdb/inc/tsdbDef.h b/source/dnode/vnode/tsdb/inc/tsdbDef.h index 882a62e097..7c593cb4c7 100644 --- a/source/dnode/vnode/tsdb/inc/tsdbDef.h +++ b/source/dnode/vnode/tsdb/inc/tsdbDef.h @@ -18,7 +18,9 @@ #include "mallocator.h" #include "taosmsg.h" +#include "tdlist.h" #include "thash.h" +#include "tskiplist.h" #include "tsdb.h" #include "tsdbMemTable.h" diff --git a/source/dnode/vnode/tsdb/src/tsdbMemTable.c b/source/dnode/vnode/tsdb/src/tsdbMemTable.c index e13b881ee5..e3d1f8673e 100644 --- a/source/dnode/vnode/tsdb/src/tsdbMemTable.c +++ b/source/dnode/vnode/tsdb/src/tsdbMemTable.c @@ -15,14 +15,32 @@ #include "tsdbDef.h" +#if 1 +typedef struct STbData { + TD_SLIST_NODE(STbData); + SSubmitMsg *pMsg; +} STbData; +#else +typedef struct STbData { + TD_SLIST_NODE(STbData); + uint64_t uid; // TODO: change here as tb_uid_t + TSKEY keyMin; + TSKEY keyMax; + uint64_t nRows; + SSkipList *pData; // Here need a container, may not use the SL + T_REF_DECLARE() +} STbData; +#endif + struct STsdbMemTable { T_REF_DECLARE() SRWLatch latch; TSKEY keyMin; TSKEY keyMax; - uint32_t nRow; - SHashObj * pHash; + uint64_t nRow; SMemAllocator *pMA; + // Container + TD_SLIST(STbData) list; }; STsdbMemTable *tsdbNewMemTable(SMemAllocatorFactory *pMAF) { @@ -43,8 +61,8 @@ STsdbMemTable *tsdbNewMemTable(SMemAllocatorFactory *pMAF) { pMemTable->keyMin = TSKEY_MAX; pMemTable->keyMax = TSKEY_MIN; pMemTable->nRow = 0; - pMemTable->pHash = NULL; /// TODO pMemTable->pMA = pMA; + tSListInit(&(pMemTable->list)); // TODO return pMemTable; @@ -62,6 +80,15 @@ void tsdbFreeMemTable(SMemAllocatorFactory *pMAF, STsdbMemTable *pMemTable) { } int tsdbInsertDataToMemTable(STsdbMemTable *pMemTable, SSubmitMsg *pMsg) { - // TODO + SMemAllocator *pMA = pMemTable->pMA; + STbData * pTbData = (STbData *)((*pMA->malloc)(pMA, sizeof(*pTbData))); + if (pTbData == NULL) { + // TODO + } + + tSListPush(&(pMemTable->list), pTbData); + return 0; -} \ No newline at end of file +} + +/* ------------------------ STATIC METHODS ------------------------ */ \ No newline at end of file