From 288904e901c691f68c1fb651307d2726f9b22499 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 15 Jun 2022 08:04:26 +0000 Subject: [PATCH] more work --- source/dnode/vnode/src/inc/tsdb.h | 2 ++ source/dnode/vnode/src/tsdb/tsdbCommit.c | 20 ++++++++++++++++++++ source/dnode/vnode/src/tsdb/tsdbMemTable.c | 3 +++ source/dnode/vnode/src/tsdb/tsdbUtil.c | 14 ++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 0045778842..0b2e3da304 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -151,6 +151,8 @@ int32_t tPutBlockIdx(uint8_t *p, void *ph); int32_t tGetBlockIdx(uint8_t *p, void *ph); // SBlock +int32_t tPutBlock(uint8_t *p, void *ph); +int32_t tGetBlock(uint8_t *p, void *ph); int32_t tBlockCmprFn(const void *p1, const void *p2); // SDelIdx diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index ca6513b7f4..ee147d929e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -355,6 +355,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData, SBl int32_t iBlock; int32_t nBlock; SBlock *pBlock; + SBlock block; // check if (pTbData) { @@ -389,6 +390,25 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData, SBl blockIdx.size = -1; // impl (todo) + iBlock = 0; + nBlock = pCommitter->oBlock.nItem; + do { + pRow = tsdbTbDataIterGet(pIter); + if (iBlock < nBlock) { + pBlock = █ + code = tMapDataGetItemByIdx(&pCommitter->oBlock, iBlock, pBlock, tGetBlock); + if (code) goto _err; + } else { + pBlock == NULL; + } + + if ((pRow == NULL || pRow->pTSRow->ts > pCommitter->maxKey) && pBlock == NULL) break; + + code = tsdbMergeData(pCommitter, pIter, pBlock); + if (code) goto _err; + + if (iBlock < nBlock) iBlock++; + } while (true); // end code = tsdbWriteBlock(pCommitter->pWriter, &pCommitter->nBlock, NULL, &blockIdx); diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index 3108c14c0d..d7d0559139 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -273,6 +273,9 @@ bool tsdbTbDataIterNext(STbDataIter *pIter) { } TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) { + // we add here for commit usage + if (pIter == NULL) return NULL; + if (pIter->pRow) { goto _exit; } diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index 4d3e890095..992cd9f4e1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -281,6 +281,20 @@ int32_t tGetBlockIdx(uint8_t *p, void *ph) { } // SBlock ====================================================== +int32_t tPutBlock(uint8_t *p, void *ph) { + int32_t n = 0; + ASSERT(0); + // TODO + return n; +} + +int32_t tGetBlock(uint8_t *p, void *ph) { + int32_t n = 0; + ASSERT(0); + // TODO + return n; +} + int32_t tBlockCmprFn(const void *p1, const void *p2) { int32_t c; SBlock *pBlock1 = (SBlock *)p1;