diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 648188cdae62ae99798b532a94bdd6a1b4657fb2..9a97c773c4bad80955aed39e659a0b57666d5e0a 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -282,6 +282,8 @@ int32_t tsdbConfigRepo(TsdbRepoT *repo, STsdbCfg *pCfg) { int32_t tsdbTriggerCommit(TsdbRepoT *repo) { STsdbRepo *pRepo = (STsdbRepo *)repo; + + if (pRepo->appH.walCallBack) pRepo->appH.walCallBack(pRepo->appH.appH); tsdbLockRepo(repo); if (pRepo->commit) { @@ -387,7 +389,7 @@ int tsdbInitTableCfg(STableCfg *config, ETableType type, int64_t uid, int32_t ti config->superUid = TSDB_INVALID_SUPER_TABLE_ID; config->tableId.uid = uid; config->tableId.tid = tid; - config->name = strdup("test1"); + config->name = NULL; return 0; } @@ -854,8 +856,6 @@ static void *tsdbCommitData(void *arg) { SRWHelper whelper = {0}; if (pCache->imem == NULL) return NULL; - if (pRepo->appH.walCallBack) pRepo->appH.walCallBack(pRepo->appH.appH); - // Create the iterator to read from cache SSkipListIterator **iters = tsdbCreateTableIters(pMeta, pCfg->maxTables); if (iters == NULL) { @@ -880,6 +880,7 @@ static void *tsdbCommitData(void *arg) { _exit: tdFreeDataCols(pDataCols); tsdbDestroyTableIters(iters, pCfg->maxTables); + tsdbDestroyHelper(&whelper); tsdbLockRepo(arg); tdListMove(pCache->imem->list, pCache->pool.memPool); diff --git a/src/tsdb/src/tsdbRWHelper.c b/src/tsdb/src/tsdbRWHelper.c index c0f509d1f2f4eacb819e2c44204429c06307dba6..8b5364e36202976da09c957301fa409004dfd27b 100644 --- a/src/tsdb/src/tsdbRWHelper.c +++ b/src/tsdb/src/tsdbRWHelper.c @@ -403,6 +403,7 @@ int tsdbWriteCompInfo(SRWHelper *pHelper) { } else { pHelper->pCompInfo->delimiter = TSDB_FILE_DELIMITER; pHelper->pCompInfo->uid = pHelper->tableInfo.uid; + pHelper->pCompInfo->checksum = 0; ASSERT((pIdx->len - sizeof(SCompInfo) - sizeof(TSCKSUM)) % sizeof(SCompBlock) == 0); taosCalcChecksumAppend(0, (uint8_t *)pHelper->pCompInfo, pIdx->len); pIdx->offset = lseek(pHelper->files.nHeadF.fd, 0, SEEK_END); diff --git a/src/tsdb/tests/tsdbTests.cpp b/src/tsdb/tests/tsdbTests.cpp index 8c59d63cb2882b3c8d8cef521ec4633e6653b13f..84711b07f866017dd518120976febe5daa68109e 100644 --- a/src/tsdb/tests/tsdbTests.cpp +++ b/src/tsdb/tests/tsdbTests.cpp @@ -4,6 +4,7 @@ #include "tdataformat.h" #include "tsdbMain.h" +#include "tskiplist.h" static double getCurTime() { struct timeval tv; @@ -141,6 +142,7 @@ TEST(TsdbTest, createRepo) { STableCfg tCfg; ASSERT_EQ(tsdbInitTableCfg(&tCfg, TSDB_SUPER_TABLE, 987607499877672L, 0), -1); ASSERT_EQ(tsdbInitTableCfg(&tCfg, TSDB_NORMAL_TABLE, 987607499877672L, 0), 0); + tsdbTableSetName(&tCfg, "test", false); int nCols = 5; STSchema *schema = tdNewSchema(nCols); @@ -167,7 +169,7 @@ TEST(TsdbTest, createRepo) { .sversion = tCfg.sversion, .startTime = 1584081000000, .interval = 1000, - .totalRows = 5000000, + .totalRows = 10000000, .rowsPerSubmit = 1, .pSchema = schema }; @@ -262,4 +264,47 @@ TEST(TsdbTest, DISABLED_createFileGroup) { // ASSERT_EQ(tsdbCreateFileGroup("/home/ubuntu/work/ttest/vnode0/data", 1820, &fGroup, 1000), 0); int k = 0; +} + +static char *getTKey(const void *data) { + return (char *)data; +} + +static void insertSkipList(bool isAscend) { + TSKEY start_time = 1587393453000; + TSKEY interval = 1000; + + SSkipList *pList = tSkipListCreate(5, TSDB_DATA_TYPE_TIMESTAMP, sizeof(TSKEY), 0, 0, 1, getTKey); + ASSERT_NE(pList, nullptr); + + for (size_t i = 0; i < 20000000; i++) + { + TSKEY time = isAscend ? (start_time + i * interval) : (start_time - i * interval); + int32_t level = 0; + int32_t headSize = 0; + + tSkipListNewNodeInfo(pList, &level, &headSize); + SSkipListNode *pNode = (SSkipListNode *)malloc(headSize + sizeof(TSKEY)); + ASSERT_NE(pNode, nullptr); + pNode->level = level; + *(TSKEY *)((char *)pNode + headSize) = time; + tSkipListPut(pList, pNode); + } + + tSkipListDestroy(pList); +} + +TEST(TsdbTest, DISABLED_testSkipList) { +// TEST(TsdbTest, testSkipList) { + double stime = getCurTime(); + insertSkipList(true); + double etime = getCurTime(); + + printf("Time used to insert 100000000 records takes %f seconds\n", etime-stime); + + stime = getCurTime(); + insertSkipList(false); + etime = getCurTime(); + + printf("Time used to insert 100000000 records takes %f seconds\n", etime-stime); } \ No newline at end of file