remove Idx file
This commit is contained in:
parent
1df8e2d9fa
commit
17e1c19b81
|
@ -151,18 +151,10 @@ typedef struct {
|
||||||
// ------------------ tsdbFile.c
|
// ------------------ tsdbFile.c
|
||||||
extern const char* tsdbFileSuffix[];
|
extern const char* tsdbFileSuffix[];
|
||||||
typedef enum {
|
typedef enum {
|
||||||
#ifdef TSDB_IDX
|
|
||||||
TSDB_FILE_TYPE_IDX = 0,
|
|
||||||
TSDB_FILE_TYPE_HEAD,
|
|
||||||
#else
|
|
||||||
TSDB_FILE_TYPE_HEAD = 0,
|
TSDB_FILE_TYPE_HEAD = 0,
|
||||||
#endif
|
|
||||||
TSDB_FILE_TYPE_DATA,
|
TSDB_FILE_TYPE_DATA,
|
||||||
TSDB_FILE_TYPE_LAST,
|
TSDB_FILE_TYPE_LAST,
|
||||||
TSDB_FILE_TYPE_MAX,
|
TSDB_FILE_TYPE_MAX,
|
||||||
#ifdef TSDB_IDX
|
|
||||||
TSDB_FILE_TYPE_NIDX,
|
|
||||||
#endif
|
|
||||||
TSDB_FILE_TYPE_NHEAD,
|
TSDB_FILE_TYPE_NHEAD,
|
||||||
TSDB_FILE_TYPE_NLAST
|
TSDB_FILE_TYPE_NLAST
|
||||||
} TSDB_FILE_TYPE;
|
} TSDB_FILE_TYPE;
|
||||||
|
@ -281,9 +273,6 @@ typedef struct {
|
||||||
TSKEY minKey;
|
TSKEY minKey;
|
||||||
TSKEY maxKey;
|
TSKEY maxKey;
|
||||||
SFileGroup fGroup;
|
SFileGroup fGroup;
|
||||||
#ifdef TSDB_IDX
|
|
||||||
SFile nIdxF;
|
|
||||||
#endif
|
|
||||||
SFile nHeadF;
|
SFile nHeadF;
|
||||||
SFile nLastF;
|
SFile nLastF;
|
||||||
} SHelperFile;
|
} SHelperFile;
|
||||||
|
@ -497,10 +486,6 @@ void tsdbGetFidKeyRange(int daysPerFile, int8_t precision, int fileId, TS
|
||||||
#define helperState(h) (h)->state
|
#define helperState(h) (h)->state
|
||||||
#define TSDB_NLAST_FILE_OPENED(h) ((h)->files.nLastF.fd > 0)
|
#define TSDB_NLAST_FILE_OPENED(h) ((h)->files.nLastF.fd > 0)
|
||||||
#define helperFileId(h) ((h)->files.fGroup.fileId)
|
#define helperFileId(h) ((h)->files.fGroup.fileId)
|
||||||
#ifdef TSDB_IDX
|
|
||||||
#define helperIdxF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_IDX]))
|
|
||||||
#define helperNewIdxF(h) (&((h)->files.nIdxF))
|
|
||||||
#endif
|
|
||||||
#define helperHeadF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_HEAD]))
|
#define helperHeadF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_HEAD]))
|
||||||
#define helperDataF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_DATA]))
|
#define helperDataF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_DATA]))
|
||||||
#define helperLastF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_LAST]))
|
#define helperLastF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_LAST]))
|
||||||
|
|
|
@ -20,11 +20,7 @@
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#define TAOS_RANDOM_FILE_FAIL_TEST
|
#define TAOS_RANDOM_FILE_FAIL_TEST
|
||||||
|
|
||||||
#ifdef TSDB_IDX
|
|
||||||
const char *tsdbFileSuffix[] = {".idx", ".head", ".data", ".last", "", ".i", ".h", ".l"};
|
|
||||||
#else
|
|
||||||
const char *tsdbFileSuffix[] = {".head", ".data", ".last", "", ".h", ".l"};
|
const char *tsdbFileSuffix[] = {".head", ".data", ".last", "", ".h", ".l"};
|
||||||
#endif
|
|
||||||
|
|
||||||
static int tsdbInitFile(SFile *pFile, STsdbRepo *pRepo, int fid, int type);
|
static int tsdbInitFile(SFile *pFile, STsdbRepo *pRepo, int fid, int type);
|
||||||
static void tsdbDestroyFile(SFile *pFile);
|
static void tsdbDestroyFile(SFile *pFile);
|
||||||
|
|
|
@ -683,11 +683,6 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
|
||||||
|
|
||||||
pthread_rwlock_wrlock(&(pFileH->fhlock));
|
pthread_rwlock_wrlock(&(pFileH->fhlock));
|
||||||
|
|
||||||
#ifdef TSDB_IDX
|
|
||||||
rename(helperNewIdxF(pHelper)->fname, helperIdxF(pHelper)->fname);
|
|
||||||
pGroup->files[TSDB_FILE_TYPE_IDX].info = helperNewIdxF(pHelper)->info;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rename(helperNewHeadF(pHelper)->fname, helperHeadF(pHelper)->fname);
|
rename(helperNewHeadF(pHelper)->fname, helperHeadF(pHelper)->fname);
|
||||||
pGroup->files[TSDB_FILE_TYPE_HEAD].info = helperNewHeadF(pHelper)->info;
|
pGroup->files[TSDB_FILE_TYPE_HEAD].info = helperNewHeadF(pHelper)->info;
|
||||||
|
|
||||||
|
|
|
@ -110,31 +110,16 @@ int tsdbSetAndOpenHelperFile(SRWHelper *pHelper, SFileGroup *pGroup) {
|
||||||
// Set the files
|
// Set the files
|
||||||
pHelper->files.fGroup = *pGroup;
|
pHelper->files.fGroup = *pGroup;
|
||||||
if (helperType(pHelper) == TSDB_WRITE_HELPER) {
|
if (helperType(pHelper) == TSDB_WRITE_HELPER) {
|
||||||
#ifdef TSDB_IDX
|
|
||||||
tsdbGetDataFileName(pHelper->pRepo, pGroup->fileId, TSDB_FILE_TYPE_NIDX, helperNewIdxF(pHelper)->fname);
|
|
||||||
#endif
|
|
||||||
tsdbGetDataFileName(pHelper->pRepo, pGroup->fileId, TSDB_FILE_TYPE_NHEAD, helperNewHeadF(pHelper)->fname);
|
tsdbGetDataFileName(pHelper->pRepo, pGroup->fileId, TSDB_FILE_TYPE_NHEAD, helperNewHeadF(pHelper)->fname);
|
||||||
tsdbGetDataFileName(pHelper->pRepo, pGroup->fileId, TSDB_FILE_TYPE_NLAST, helperNewLastF(pHelper)->fname);
|
tsdbGetDataFileName(pHelper->pRepo, pGroup->fileId, TSDB_FILE_TYPE_NLAST, helperNewLastF(pHelper)->fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the files
|
// Open the files
|
||||||
#ifdef TSDB_IDX
|
|
||||||
if (tsdbOpenFile(helperIdxF(pHelper), O_RDONLY) < 0) return -1;
|
|
||||||
#endif
|
|
||||||
if (tsdbOpenFile(helperHeadF(pHelper), O_RDONLY) < 0) return -1;
|
if (tsdbOpenFile(helperHeadF(pHelper), O_RDONLY) < 0) return -1;
|
||||||
if (helperType(pHelper) == TSDB_WRITE_HELPER) {
|
if (helperType(pHelper) == TSDB_WRITE_HELPER) {
|
||||||
if (tsdbOpenFile(helperDataF(pHelper), O_RDWR) < 0) return -1;
|
if (tsdbOpenFile(helperDataF(pHelper), O_RDWR) < 0) return -1;
|
||||||
if (tsdbOpenFile(helperLastF(pHelper), O_RDWR) < 0) return -1;
|
if (tsdbOpenFile(helperLastF(pHelper), O_RDWR) < 0) return -1;
|
||||||
|
|
||||||
#ifdef TSDB_IDX
|
|
||||||
// Create and open .i file
|
|
||||||
pFile = helperNewIdxF(pHelper);
|
|
||||||
if (tsdbOpenFile(pFile, O_WRONLY | O_CREAT) < 0) return -1;
|
|
||||||
pFile->info.size = TSDB_FILE_HEAD_SIZE;
|
|
||||||
pFile->info.magic = TSDB_FILE_INIT_MAGIC;
|
|
||||||
if (tsdbUpdateFileHeader(pFile) < 0) return -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Create and open .h
|
// Create and open .h
|
||||||
pFile = helperNewHeadF(pHelper);
|
pFile = helperNewHeadF(pHelper);
|
||||||
if (tsdbOpenFile(pFile, O_WRONLY | O_CREAT) < 0) return -1;
|
if (tsdbOpenFile(pFile, O_WRONLY | O_CREAT) < 0) return -1;
|
||||||
|
@ -164,11 +149,6 @@ int tsdbSetAndOpenHelperFile(SRWHelper *pHelper, SFileGroup *pGroup) {
|
||||||
int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
|
int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
|
||||||
SFile *pFile = NULL;
|
SFile *pFile = NULL;
|
||||||
|
|
||||||
#ifdef TSDB_IDX
|
|
||||||
pFile = helperIdxF(pHelper);
|
|
||||||
tsdbCloseFile(pFile);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pFile = helperHeadF(pHelper);
|
pFile = helperHeadF(pHelper);
|
||||||
tsdbCloseFile(pFile);
|
tsdbCloseFile(pFile);
|
||||||
|
|
||||||
|
@ -199,18 +179,6 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (helperType(pHelper) == TSDB_WRITE_HELPER) {
|
if (helperType(pHelper) == TSDB_WRITE_HELPER) {
|
||||||
#ifdef TSDB_IDX
|
|
||||||
pFile = helperNewIdxF(pHelper);
|
|
||||||
if (pFile->fd > 0) {
|
|
||||||
if (!hasError) {
|
|
||||||
tsdbUpdateFileHeader(pFile);
|
|
||||||
fsync(pFile->fd);
|
|
||||||
}
|
|
||||||
tsdbCloseFile(pFile);
|
|
||||||
if (hasError) (void)remove(pFile->fname);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pFile = helperNewHeadF(pHelper);
|
pFile = helperNewHeadF(pHelper);
|
||||||
if (pFile->fd > 0) {
|
if (pFile->fd > 0) {
|
||||||
if (!hasError) {
|
if (!hasError) {
|
||||||
|
@ -412,10 +380,6 @@ int tsdbWriteCompInfo(SRWHelper *pHelper) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TSDB_IDX
|
|
||||||
pFile = helperNewIdxF(pHelper);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (taosTSizeof(pHelper->pWIdx) < pFile->info.len + sizeof(SCompIdx) + 12) {
|
if (taosTSizeof(pHelper->pWIdx) < pFile->info.len + sizeof(SCompIdx) + 12) {
|
||||||
pHelper->pWIdx = taosTRealloc(pHelper->pWIdx, taosTSizeof(pHelper->pWIdx) == 0 ? 1024 : taosTSizeof(pHelper->pWIdx) * 2);
|
pHelper->pWIdx = taosTRealloc(pHelper->pWIdx, taosTSizeof(pHelper->pWIdx) == 0 ? 1024 : taosTSizeof(pHelper->pWIdx) * 2);
|
||||||
if (pHelper->pWIdx == NULL) {
|
if (pHelper->pWIdx == NULL) {
|
||||||
|
@ -435,11 +399,7 @@ int tsdbWriteCompIdx(SRWHelper *pHelper) {
|
||||||
ASSERT(helperType(pHelper) == TSDB_WRITE_HELPER);
|
ASSERT(helperType(pHelper) == TSDB_WRITE_HELPER);
|
||||||
off_t offset = 0;
|
off_t offset = 0;
|
||||||
|
|
||||||
#ifdef TSDB_IDX
|
|
||||||
SFile *pFile = helperNewIdxF(pHelper);
|
|
||||||
#else
|
|
||||||
SFile *pFile = helperNewHeadF(pHelper);
|
SFile *pFile = helperNewHeadF(pHelper);
|
||||||
#endif
|
|
||||||
|
|
||||||
pFile->info.len += sizeof(TSCKSUM);
|
pFile->info.len += sizeof(TSCKSUM);
|
||||||
if (taosTSizeof(pHelper->pWIdx) < pFile->info.len) {
|
if (taosTSizeof(pHelper->pWIdx) < pFile->info.len) {
|
||||||
|
@ -474,11 +434,7 @@ int tsdbWriteCompIdx(SRWHelper *pHelper) {
|
||||||
|
|
||||||
int tsdbLoadCompIdx(SRWHelper *pHelper, void *target) {
|
int tsdbLoadCompIdx(SRWHelper *pHelper, void *target) {
|
||||||
ASSERT(pHelper->state == TSDB_HELPER_FILE_SET_AND_OPEN);
|
ASSERT(pHelper->state == TSDB_HELPER_FILE_SET_AND_OPEN);
|
||||||
#ifdef TSDB_IDX
|
|
||||||
SFile *pFile = helperIdxF(pHelper);
|
|
||||||
#else
|
|
||||||
SFile *pFile = helperHeadF(pHelper);
|
SFile *pFile = helperHeadF(pHelper);
|
||||||
#endif
|
|
||||||
int fd = pFile->fd;
|
int fd = pFile->fd;
|
||||||
|
|
||||||
if (!helperHasState(pHelper, TSDB_HELPER_IDX_LOAD)) {
|
if (!helperHasState(pHelper, TSDB_HELPER_IDX_LOAD)) {
|
||||||
|
@ -1052,10 +1008,6 @@ static void tsdbResetHelperFileImpl(SRWHelper *pHelper) {
|
||||||
helperLastF(pHelper)->fd = -1;
|
helperLastF(pHelper)->fd = -1;
|
||||||
helperNewHeadF(pHelper)->fd = -1;
|
helperNewHeadF(pHelper)->fd = -1;
|
||||||
helperNewLastF(pHelper)->fd = -1;
|
helperNewLastF(pHelper)->fd = -1;
|
||||||
#ifdef TSDB_IDX
|
|
||||||
helperIdxF(pHelper)->fd = -1;
|
|
||||||
helperNewIdxF(pHelper)->fd = -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbInitHelperFile(SRWHelper *pHelper) {
|
static int tsdbInitHelperFile(SRWHelper *pHelper) {
|
||||||
|
|
Loading…
Reference in New Issue