From 11e00e56de6c6acc2656b080ff5c2f0cc683808f Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Sun, 26 Sep 2021 15:33:40 +0800 Subject: [PATCH] code optimization --- src/tsdb/src/tsdbFS.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/tsdb/src/tsdbFS.c b/src/tsdb/src/tsdbFS.c index 971ade1322..99050c42a1 100644 --- a/src/tsdb/src/tsdbFS.c +++ b/src/tsdb/src/tsdbFS.c @@ -1299,6 +1299,17 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { } #endif +// update the function if the DFileSet definition updates +static bool tsdbIsDFileSetValid(int nFiles) { + switch (nFiles) { + case TSDB_FILE_MIN: + case TSDB_FILE_MAX: + return true; + default: + return false; + } +} + #if 1 static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { const TFILE *pf = NULL; @@ -1359,13 +1370,13 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { ++nDFiles; pDFile->f = *pf; // (1) the array ends - if ((index == fArraySize - 1) && (nDFiles >= TSDB_FILE_MIN)) { + if ((index == fArraySize - 1) && tsdbIsDFileSetValid(nDFiles)) { tsdbInfo("vgId:%d DFileSet %d is fetched, nDFiles=%" PRIu8, REPO_ID(pRepo), fset.fid, nDFiles); isOneFSetFinish = true; } } else { // (2) encounter different fid - if (nDFiles >= TSDB_FILE_MIN) { + if (tsdbIsDFileSetValid(nDFiles)) { tsdbInfo("vgId:%d DFileSet %d is fetched, nDFiles=%" PRIu8, REPO_ID(pRepo), fset.fid, nDFiles); isOneFSetFinish = true; } else { -- GitLab