From 724a3710039edb583ce7d5bd36b106a847dbafdc Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Sat, 8 Jan 2022 06:28:01 +0000 Subject: [PATCH] more --- source/dnode/vnode/tsdb/inc/tsdbMemTable.h | 7 ++++ source/dnode/vnode/tsdb/src/tsdbCommit.c | 40 +++++++++++----------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/source/dnode/vnode/tsdb/inc/tsdbMemTable.h b/source/dnode/vnode/tsdb/inc/tsdbMemTable.h index eea322006e..00ae8ab958 100644 --- a/source/dnode/vnode/tsdb/inc/tsdbMemTable.h +++ b/source/dnode/vnode/tsdb/inc/tsdbMemTable.h @@ -67,6 +67,13 @@ static FORCE_INLINE SMemRow tsdbNextIterRow(SSkipListIterator *pIter) { return (SMemRow)SL_GET_NODE_DATA(node); } +static FORCE_INLINE TSKEY tsdbNextIterKey(SSkipListIterator *pIter) { + SMemRow row = tsdbNextIterRow(pIter); + if (row == NULL) return TSDB_DATA_TIMESTAMP_NULL; + + return memRowKey(row); +} + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/tsdb/src/tsdbCommit.c b/source/dnode/vnode/tsdb/src/tsdbCommit.c index 0bf7b63307..c16d10414e 100644 --- a/source/dnode/vnode/tsdb/src/tsdbCommit.c +++ b/source/dnode/vnode/tsdb/src/tsdbCommit.c @@ -138,10 +138,10 @@ int tsdbCommit(STsdb *pRepo) { break; } } -#if 0 // Loop to commit to each file fid = tsdbNextCommitFid(&(commith)); +#if 0 while (true) { // Loop over both on disk and memory if (pSet == NULL && fid == TSDB_IVLD_FID) break; @@ -281,28 +281,28 @@ static void tsdbSeekCommitIter(SCommitH *pCommith, TSKEY key) { } } -// static int tsdbNextCommitFid(SCommitH *pCommith) { -// STsdb * pRepo = TSDB_COMMIT_REPO(pCommith); -// STsdbCfg *pCfg = REPO_CFG(pRepo); -// int fid = TSDB_IVLD_FID; +static int tsdbNextCommitFid(SCommitH *pCommith) { + STsdb * pRepo = TSDB_COMMIT_REPO(pCommith); + STsdbCfg *pCfg = REPO_CFG(pRepo); + int fid = TSDB_IVLD_FID; -// for (int i = 0; i < pCommith->niters; i++) { -// SCommitIter *pIter = pCommith->iters + i; -// if (pIter->pTable == NULL || pIter->pIter == NULL) continue; + for (int i = 0; i < pCommith->niters; i++) { + SCommitIter *pIter = pCommith->iters + i; + // if (pIter->pTable == NULL || pIter->pIter == NULL) continue; -// TSKEY nextKey = tsdbNextIterKey(pIter->pIter); -// if (nextKey == TSDB_DATA_TIMESTAMP_NULL) { -// continue; -// } else { -// int tfid = (int)(TSDB_KEY_FID(nextKey, pCfg->daysPerFile, pCfg->precision)); -// if (fid == TSDB_IVLD_FID || fid > tfid) { -// fid = tfid; -// } -// } -// } + TSKEY nextKey = tsdbNextIterKey(pIter->pIter); + if (nextKey == TSDB_DATA_TIMESTAMP_NULL) { + continue; + } else { + int tfid = (int)(TSDB_KEY_FID(nextKey, pCfg->daysPerFile, pCfg->precision)); + if (fid == TSDB_IVLD_FID || fid > tfid) { + fid = tfid; + } + } + } -// return fid; -// } + return fid; +} static void tsdbDestroyCommitH(SCommitH *pCommith) { pCommith->pDataCols = tdFreeDataCols(pCommith->pDataCols);