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

code optimization

上级 d6d1c1e2
......@@ -235,20 +235,4 @@ static FORCE_INLINE int tsdbMakeRoom(void **ppBuf, size_t size) {
return 0;
}
FORCE_INLINE int tsdbInitReadHBlkIdx(SReadH *pReadh, STsdbRepo *pRepo) {
ASSERT(pReadh != NULL && pRepo != NULL);
memset((void *)pReadh, 0, sizeof(*pReadh));
pReadh->pRepo = pRepo;
TSDB_FSET_SET_INIT(TSDB_READ_FSET(pReadh));
pReadh->aBlkIdx = taosArrayInit(1024, sizeof(SBlockIdx));
if (pReadh->aBlkIdx == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return -1;
}
return 0;
}
#endif /*_TD_TSDB_READ_IMPL_H_*/
......@@ -1322,7 +1322,8 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
// Loop to recover each file set
SDFileSet fset = {0};
bool isOneFSetFinish = false;
bool isOneFSetFinish = true;
int lastFType = -1;
// one fileset ends when (1) the array ends or (2) encounter different fid
for (size_t index = 0; index < fArraySize; ++index) {
int tvid = -1, tfid = -1;
......@@ -1332,13 +1333,17 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
pf = taosArrayGet(fArray, index);
tfsbasename(pf, bname);
tsdbParseDFilename(bname, &tvid, &tfid, &ttype, &tversion);
tsdbParseDFilename(bname, &tvid, &tfid, &ttype, &tversion);
ASSERT(tvid == REPO_ID(pRepo));
SDFile *pDFile = TSDB_DFILE_IN_SET(&fset, ttype);
if (tfid < pRepo->rtn.minFid) { // skip the file expired
continue;
}
if ((isOneFSetFinish == false) && (lastFType == ttype)) { // only fetch the 1st file with same fid and type.
continue;
}
lastFType = ttype;
if (index == 0) {
memset(&fset, 0, sizeof(SDFileSet));
......@@ -1477,7 +1482,13 @@ static int tsdbComparTFILE(const void *arg1, const void *arg2) {
} else if (ftype1 > ftype2) {
return 1;
} else {
return 0;
if (version1 < version2) {
return -1;
} else if (version1 > version2) {
return 1;
} else {
return 0;
}
}
}
}
......
......@@ -454,7 +454,7 @@ static int tsdbScanAndTryFixDFile(STsdbRepo *pRepo, SDFile *pDFile) {
}
if (pDFile->info.size < dfstat.st_size) {
if (tsdbOpenDFile(&df, O_RDWR) < 0) {
if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
return -1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册