提交 2e53d7a4 编写于 作者: H Hongze Cheng

fix tsdbGetFileInfo

上级 dbdde975
...@@ -1208,55 +1208,34 @@ uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, uint32_t ...@@ -1208,55 +1208,34 @@ uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, uint32_t
tsdbTrace("vgId:%d name:%s index:%d eindex:%d", pRepo->config.tsdbId, name, *index, eindex); tsdbTrace("vgId:%d name:%s index:%d eindex:%d", pRepo->config.tsdbId, name, *index, eindex);
ASSERT(*index <= eindex); ASSERT(*index <= eindex);
if (name[0] == 0) { // get the file from index or after, but not larger than eindex if (name[0] == 0) { // get the file from index or after, but not larger than eindex
if (*index == 0) { // need to return the first file and set the *index if (*index == TSDB_META_FILE_INDEX) {
if (pFileH->numOfFGroups > 0) { tsdbGetMetaFileName(pRepo->rootDir, fname);
int fid = TSDB_MIN_FILE_ID(pFileH); } else { // to get a file in index or larger than index but
if (pFileH->numOfFGroups == 0) { // not found
if (fid * 3 <= eindex) { return 0;
strcpy(fname, pFileH->fGroup[fid].files[0].fname);
*index = fid * 3;
strcpy(name, fname+strlen(pRepo->rootDir));
} else { // no file found
return 0;
}
} else { } else {
if (TSDB_META_FILE_INDEX <= eindex) { int fid = (*index) / 3;
*index = TSDB_META_FILE_INDEX; SFileGroup *pFGroup =
tsdbGetMetaFileName(pRepo->rootDir, fname); taosbsearch(&fid, pFileH->fGroup, pFileH->numOfFGroups, sizeof(SFileGroup), compFGroupKey, TD_GE);
strcpy(name, fname+strlen(pRepo->rootDir)); if (pFGroup == NULL) {
} else { // no file found
return 0;
}
}
} else { // return a file name at *index
if (*index == TSDB_META_FILE_INDEX) {
tsdbGetMetaFileName(pRepo->rootDir, fname);
} else { // to get a file in index or larger than index but
if (pFileH->numOfFGroups == 0) { // not found
return 0; return 0;
} else { } else {
int fid = (*index) / 3; if (pFGroup->fileId == fid) {
SFileGroup *pFGroup = taosbsearch(&fid, pFileH->fGroup, pFileH->numOfFGroups, sizeof(SFileGroup), compFGroupKey, TD_GE); strcpy(fname, pFGroup->files[(*index) % 3].fname);
if (pFGroup == NULL) {
return 0;
} else { } else {
if (pFGroup->fileId == fid) { if (pFGroup->fileId * 3 + 2 < eindex) {
strcpy(fname, pFGroup->files[(*index)%3].fname); strcpy(fname, pFGroup->files[(*index) % 3].fname);
*index = pFGroup->fileId * 3 + (*index) % 3;
} else { } else {
if (pFGroup->fileId * 3 + 2 < eindex) { return 0;
strcpy(fname, pFGroup->files[(*index)%3].fname);
*index = pFGroup->fileId * 3 + (*index) % 3;
} else {
return 0;
}
} }
} }
} }
} }
strcpy(name, fname);
} }
} else { // get the named file at the specified index. If not there, return 0 strcpy(name, fname);
} else { // get the named file at the specified index. If not there, return 0
if (*index == TSDB_META_FILE_INDEX) { // get meta file if (*index == TSDB_META_FILE_INDEX) { // get meta file
tsdbGetMetaFileName(pRepo->rootDir, fname); tsdbGetMetaFileName(pRepo->rootDir, fname);
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册