diff --git a/source/dnode/vnode/src/tsdb/dev/inc/tsdbIter.h b/source/dnode/vnode/src/tsdb/dev/inc/tsdbIter.h index ed46bfe8841af1347d8b84edf660cb88d0781787..41f0c76adee8490a200591f4d1962854c5d92aa6 100644 --- a/source/dnode/vnode/src/tsdb/dev/inc/tsdbIter.h +++ b/source/dnode/vnode/src/tsdb/dev/inc/tsdbIter.h @@ -55,12 +55,13 @@ int32_t tsdbIterClose(STsdbIter **iter); int32_t tsdbIterNext(STsdbIter *iter); // SIterMerger =============== -int32_t tsdbIterMergerOpen(const TTsdbIterArray *iterArray, SIterMerger **merger, bool isTomb); -int32_t tsdbIterMergerClose(SIterMerger **merger); -int32_t tsdbIterMergerNext(SIterMerger *merger); -SRowInfo *tsdbIterMergerGet(SIterMerger *merger); +int32_t tsdbIterMergerOpen(const TTsdbIterArray *iterArray, SIterMerger **merger, bool isTomb); +int32_t tsdbIterMergerClose(SIterMerger **merger); +int32_t tsdbIterMergerNext(SIterMerger *merger); +int32_t tsdbIterMergerSkipTableData(SIterMerger *merger, const TABLEID *tbid); + +SRowInfo *tsdbIterMergerGetData(SIterMerger *merger); STombRecord *tsdbIterMergerGetTombRecord(SIterMerger *merger); -int32_t tsdbIterMergerSkipTableData(SIterMerger *merger, const TABLEID *tbid); #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c b/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c index 6a43f13d0127f43a440b3645d896ab7ff615e744..9c7d05138e0cec1868a16a23cc1e02b88272863a 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c @@ -178,7 +178,7 @@ static int32_t tsdbCommitTSData(SCommitter2 *committer) { TSDB_CHECK_CODE(code, lino, _exit); // loop iter - while ((row = tsdbIterMergerGet(committer->iterMerger)) != NULL) { + while ((row = tsdbIterMergerGetData(committer->iterMerger)) != NULL) { if (row->uid != committer->ctx->tbid->uid) { committer->ctx->tbid->suid = row->suid; committer->ctx->tbid->uid = row->uid; diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbIter.c b/source/dnode/vnode/src/tsdb/dev/tsdbIter.c index f0078f93f05b420b43dfd1c64b06a317dab9bd77..6b614d7e84013bac5264878ba29391f14b7d6e12 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbIter.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbIter.c @@ -544,6 +544,7 @@ static int32_t tsdbTombIterCmprFn(const SRBTreeNode *n1, const SRBTreeNode *n2) // SIterMerger ================ struct SIterMerger { + bool isTomb; STsdbIter *iter; SRBTree iterTree[1]; }; @@ -553,8 +554,11 @@ int32_t tsdbIterMergerOpen(const TTsdbIterArray *iterArray, SIterMerger **merger SRBTreeNode *node; merger[0] = taosMemoryCalloc(1, sizeof(*merger[0])); - if (!merger[0]) return TSDB_CODE_OUT_OF_MEMORY; + if (merger[0] == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + merger[0]->isTomb = isTomb; if (isTomb) { tRBTreeCreate(merger[0]->iterTree, tsdbTombIterCmprFn); } else { @@ -599,15 +603,22 @@ int32_t tsdbIterMergerNext(SIterMerger *merger) { } } - if (!merger->iter && (node = tRBTreeDropMin(merger->iterTree))) { + if (merger->iter == NULL && (node = tRBTreeDropMin(merger->iterTree))) { merger->iter = TCONTAINER_OF(node, STsdbIter, node); } return 0; } -SRowInfo *tsdbIterMergerGet(SIterMerger *merger) { return merger->iter ? merger->iter->row : NULL; } -STombRecord *tsdbIterMergerGetTombRecord(SIterMerger *merger) { return merger->iter ? merger->iter->record : NULL; } +SRowInfo *tsdbIterMergerGetData(SIterMerger *merger) { + ASSERT(!merger->isTomb); + return merger->iter ? merger->iter->row : NULL; +} + +STombRecord *tsdbIterMergerGetTombRecord(SIterMerger *merger) { + ASSERT(merger->isTomb); + return merger->iter ? merger->iter->record : NULL; +} int32_t tsdbIterMergerSkipTableData(SIterMerger *merger, const TABLEID *tbid) { int32_t code; diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbMerge.c b/source/dnode/vnode/src/tsdb/dev/tsdbMerge.c index 3f45301efe3d3b257670b1bc507d1f903f9699e9..eb4fb18ddd82fb92b042ad4ae5097aff49ed949d 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbMerge.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbMerge.c @@ -199,7 +199,7 @@ static int32_t tsdbMergeToDataLevel(SMerger *merger) { int32_t lino = 0; // data - for (SRowInfo *row; (row = tsdbIterMergerGet(merger->dataIterMerger)) != NULL;) { + for (SRowInfo *row; (row = tsdbIterMergerGetData(merger->dataIterMerger)) != NULL;) { if (row->uid != merger->ctx->tbid->uid) { code = tsdbMergeToDataTableEnd(merger); TSDB_CHECK_CODE(code, lino, _exit); @@ -273,7 +273,7 @@ static int32_t tsdbMergeToUpperLevel(SMerger *merger) { // data SRowInfo *row; - while ((row = tsdbIterMergerGet(merger->dataIterMerger))) { + while ((row = tsdbIterMergerGetData(merger->dataIterMerger))) { code = tsdbSttFileWriteRow(merger->sttWriter, row); TSDB_CHECK_CODE(code, lino, _exit);