提交 dc5d4d52 编写于 作者: C Cary Xu

code optimization

上级 e4f41ef3
...@@ -327,7 +327,7 @@ static FORCE_INLINE uint8_t tsdbGetNFiles(SDFileSet* pSet) { ...@@ -327,7 +327,7 @@ static FORCE_INLINE uint8_t tsdbGetNFiles(SDFileSet* pSet) {
#define TSDB_FSET_ID(s) TSDB_FILE_ID(TSDB_DFILE_IN_SET(s, 0)) #define TSDB_FSET_ID(s) TSDB_FILE_ID(TSDB_DFILE_IN_SET(s, 0))
#define TSDB_FSET_SET_CLOSED(s) \ #define TSDB_FSET_SET_CLOSED(s) \
do { \ do { \
for (TSDB_FILE_T ftype = TSDB_FILE_HEAD; ftype < tsdbGetNFiles(s); ftype++) { \ for (TSDB_FILE_T ftype = TSDB_FILE_HEAD; ftype < TSDB_FILE_MAX; ftype++) { \
TSDB_FILE_SET_CLOSED(TSDB_DFILE_IN_SET(s, ftype)); \ TSDB_FILE_SET_CLOSED(TSDB_DFILE_IN_SET(s, ftype)); \
} \ } \
} while (0); } while (0);
...@@ -337,12 +337,6 @@ static FORCE_INLINE uint8_t tsdbGetNFiles(SDFileSet* pSet) { ...@@ -337,12 +337,6 @@ static FORCE_INLINE uint8_t tsdbGetNFiles(SDFileSet* pSet) {
TSDB_FILE_FSYNC(TSDB_DFILE_IN_SET(s, ftype)); \ TSDB_FILE_FSYNC(TSDB_DFILE_IN_SET(s, ftype)); \
} \ } \
} while (0); } while (0);
#define TSDB_FSET_SET_INIT(s) \
do { \
for (TSDB_FILE_T ftype = TSDB_FILE_HEAD; ftype < TSDB_FILE_MAX; ftype++) { \
TSDB_FILE_SET_CLOSED(TSDB_DFILE_IN_SET(s, ftype)); \
} \
} while (0);
void tsdbInitDFileSet(SDFileSet* pSet, SDiskID did, int vid, int fid, uint32_t ver, uint8_t fsetVer); void tsdbInitDFileSet(SDFileSet* pSet, SDiskID did, int vid, int fid, uint32_t ver, uint8_t fsetVer);
void tsdbInitDFileSetEx(SDFileSet* pSet, SDFileSet* pOSet); void tsdbInitDFileSetEx(SDFileSet* pSet, SDFileSet* pOSet);
......
...@@ -844,7 +844,7 @@ static int tsdbInitCommitH(SCommitH *pCommith, STsdbRepo *pRepo) { ...@@ -844,7 +844,7 @@ static int tsdbInitCommitH(SCommitH *pCommith, STsdbRepo *pRepo) {
memset(pCommith, 0, sizeof(*pCommith)); memset(pCommith, 0, sizeof(*pCommith));
tsdbGetRtnSnap(pRepo, &(pCommith->rtn)); tsdbGetRtnSnap(pRepo, &(pCommith->rtn));
TSDB_FSET_SET_INIT(TSDB_COMMIT_WRITE_FSET(pCommith)); TSDB_FSET_SET_CLOSED(TSDB_COMMIT_WRITE_FSET(pCommith));
// Init read handle // Init read handle
if (tsdbInitReadH(&(pCommith->readh), pRepo) < 0) { if (tsdbInitReadH(&(pCommith->readh), pRepo) < 0) {
......
...@@ -274,7 +274,7 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) { ...@@ -274,7 +274,7 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
memset(pComph, 0, sizeof(*pComph)); memset(pComph, 0, sizeof(*pComph));
TSDB_FSET_SET_INIT(TSDB_COMPACT_WSET(pComph)); TSDB_FSET_SET_CLOSED(TSDB_COMPACT_WSET(pComph));
tsdbGetRtnSnap(pRepo, &(pComph->rtn)); tsdbGetRtnSnap(pRepo, &(pComph->rtn));
tsdbFSIterInit(&(pComph->fsIter), REPO_FS(pRepo), TSDB_FS_ITER_FORWARD); tsdbFSIterInit(&(pComph->fsIter), REPO_FS(pRepo), TSDB_FS_ITER_FORWARD);
......
...@@ -1200,7 +1200,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { ...@@ -1200,7 +1200,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
SDFileSet fset = {0}; SDFileSet fset = {0};
TSDB_FSET_SET_INIT(&fset); TSDB_FSET_SET_CLOSED(&fset);
// Loop to recover ONE fset // Loop to recover ONE fset
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) { for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
...@@ -1355,7 +1355,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { ...@@ -1355,7 +1355,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
if (index == 0) { if (index == 0) {
memset(&fset, 0, sizeof(SDFileSet)); memset(&fset, 0, sizeof(SDFileSet));
TSDB_FSET_SET_INIT(&fset); TSDB_FSET_SET_CLOSED(&fset);
nDFiles = 1; nDFiles = 1;
fset.fid = tfid; fset.fid = tfid;
pDFile->f = *pf; pDFile->f = *pf;
...@@ -1377,7 +1377,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { ...@@ -1377,7 +1377,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
} else { } else {
// next FSet // next FSet
memset(&fset, 0, sizeof(SDFileSet)); memset(&fset, 0, sizeof(SDFileSet));
TSDB_FSET_SET_INIT(&fset); TSDB_FSET_SET_CLOSED(&fset);
nDFiles = 1; nDFiles = 1;
fset.fid = tfid; fset.fid = tfid;
pDFile->f = *pf; pDFile->f = *pf;
...@@ -1437,7 +1437,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { ...@@ -1437,7 +1437,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
// next FSet // next FSet
memset(&fset, 0, sizeof(SDFileSet)); memset(&fset, 0, sizeof(SDFileSet));
TSDB_FSET_SET_INIT(&fset); TSDB_FSET_SET_CLOSED(&fset);
nDFiles = 1; nDFiles = 1;
fset.fid = tfid; fset.fid = tfid;
pDFile->f = *pf; pDFile->f = *pf;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册