From 9fa0685bbf43edc137476c575d0b11c0f8f1e438 Mon Sep 17 00:00:00 2001 From: hzcheng Date: Wed, 4 Mar 2020 06:20:26 +0000 Subject: [PATCH] correct some error --- src/CMakeLists.txt | 12 ++++++------ src/vnode/tests/tsdb/tsdbTests.cpp | 1 + src/vnode/tsdb/inc/tsdbFile.h | 8 ++------ src/vnode/tsdb/src/tsdbFileStore.c | 18 ++++++++++++++++-- src/vnode/tsdb/src/tsdbMain.c | 2 +- src/vnode/tsdb/src/tsdbMeta.c | 4 ++-- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34768b00df..91670d3e7a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,11 +4,11 @@ PROJECT(TDengine) ADD_SUBDIRECTORY(os) ADD_SUBDIRECTORY(util) ADD_SUBDIRECTORY(rpc) -ADD_SUBDIRECTORY(client) -ADD_SUBDIRECTORY(kit) -ADD_SUBDIRECTORY(plugins) -ADD_SUBDIRECTORY(sdb) -ADD_SUBDIRECTORY(mnode) +# ADD_SUBDIRECTORY(client) +# ADD_SUBDIRECTORY(kit) +# ADD_SUBDIRECTORY(plugins) +# ADD_SUBDIRECTORY(sdb) +# ADD_SUBDIRECTORY(mnode) ADD_SUBDIRECTORY(vnode) -ADD_SUBDIRECTORY(dnode) +# ADD_SUBDIRECTORY(dnode) #ADD_SUBDIRECTORY(connector/jdbc) diff --git a/src/vnode/tests/tsdb/tsdbTests.cpp b/src/vnode/tests/tsdb/tsdbTests.cpp index 8e1b37b191..3e7a7cca5f 100644 --- a/src/vnode/tests/tsdb/tsdbTests.cpp +++ b/src/vnode/tests/tsdb/tsdbTests.cpp @@ -10,6 +10,7 @@ TEST(TsdbTest, createTsdbRepo) { config.tsdbId = 0; config.maxTables = 100; config.daysPerFile = 10; + config.keep = 3650; config.minRowsPerFileBlock = 100; config.maxRowsPerFileBlock = 4096; config.maxCacheSize = 4 * 1024 * 1024; diff --git a/src/vnode/tsdb/inc/tsdbFile.h b/src/vnode/tsdb/inc/tsdbFile.h index 39d1b0b3c2..dbcec49651 100644 --- a/src/vnode/tsdb/inc/tsdbFile.h +++ b/src/vnode/tsdb/inc/tsdbFile.h @@ -32,12 +32,6 @@ typedef enum { } TSDB_FILE_TYPE; extern const char *tsdbFileSuffix[]; -// const char *tsdbFileSuffix[] = { -// ".head", // TSDB_FILE_TYPE_HEAD -// ".data", // TSDB_FILE_TYPE_DATA -// ".last", // TSDB_FILE_TYPE_LAST -// ".meta" // TSDB_FILE_TYPE_META -// }; typedef struct { int64_t fileSize; @@ -55,6 +49,8 @@ typedef struct { // int16_t numOfBlocks; // } SDataBlock; +#define IS_VALID_TSDB_FILE_TYPE(type) ((type) >= TSDB_FILE_TYPE_HEAD && (type) <= TSDB_FILE_TYPE_META) + char *tsdbGetFileName(char *dirName, char *fname, TSDB_FILE_TYPE type); #ifdef __cplusplus diff --git a/src/vnode/tsdb/src/tsdbFileStore.c b/src/vnode/tsdb/src/tsdbFileStore.c index 79e6e6170a..5c0702e296 100644 --- a/src/vnode/tsdb/src/tsdbFileStore.c +++ b/src/vnode/tsdb/src/tsdbFileStore.c @@ -1,8 +1,22 @@ +#include #include +#include #include "tsdbFile.h" +const char *tsdbFileSuffix[] = { + ".head", // TSDB_FILE_TYPE_HEAD + ".data", // TSDB_FILE_TYPE_DATA + ".last", // TSDB_FILE_TYPE_LAST + ".meta" // TSDB_FILE_TYPE_META +}; + char *tsdbGetFileName(char *dirName, char *fname, TSDB_FILE_TYPE type) { - // TODO - return NULL; + if (!IS_VALID_TSDB_FILE_TYPE(type)) return NULL; + + char *fileName = (char *)malloc(strlen(dirName) + strlen(fname) + strlen(tsdbFileSuffix[type]) + 5); + if (fileName == NULL) return NULL; + + sprintf(fileName, "%s/%s%s", dirName, fname, tsdbFileSuffix[type]); + return fileName; } \ No newline at end of file diff --git a/src/vnode/tsdb/src/tsdbMain.c b/src/vnode/tsdb/src/tsdbMain.c index f1a0701669..cf217f0771 100644 --- a/src/vnode/tsdb/src/tsdbMain.c +++ b/src/vnode/tsdb/src/tsdbMain.c @@ -241,7 +241,7 @@ static int32_t tsdbSetRepoEnv(STsdbRepo *pRepo) { return -1; } - sprintf(dirName, "%s/%s", pRepo->rootDir, dirName); + sprintf(dirName, "%s/%s", pRepo->rootDir, "tsdb"); if (mkdir(dirName, 0755) < 0) { free(dirName); return -1; diff --git a/src/vnode/tsdb/src/tsdbMeta.c b/src/vnode/tsdb/src/tsdbMeta.c index eb348fafae..76801b1ddc 100644 --- a/src/vnode/tsdb/src/tsdbMeta.c +++ b/src/vnode/tsdb/src/tsdbMeta.c @@ -90,7 +90,7 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) { pSTable->stableUid = -1; pSTable->numOfCols = pCfg->numOfCols; pSTable->pSchema = tdDupSchema(pCfg->schema); - pSTable->content.pIndex = tSkipListCreate(5, 0, 10); // TODO: change here + // pSTable->content.pIndex = tSkipListCreate(5, 0, 10); // TODO: change here tsdbAddTable(pMeta, pSTable); } else { if (pSTable->type != TSDB_SUPER_TABLE) return NULL; @@ -113,7 +113,7 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) { pTable->stableUid = -1; pTable->pSchema = tdDupSchema(pCfg->schema); } - pTable->content.pData = tSkipListCreate(5, 0, 10); // TODO: change here + // pTable->content.pData = tSkipListCreate(5, 0, 10); // TODO: change here tsdbAddTable(pMeta, pTable); -- GitLab