提交 83f9c368 编写于 作者: H hzcheng

TD-166

上级 e242b4fd
...@@ -158,7 +158,7 @@ static int tsdbRestoreInfo(STsdbRepo *pRepo) { ...@@ -158,7 +158,7 @@ static int tsdbRestoreInfo(STsdbRepo *pRepo) {
tsdbInitFileGroupIter(pFileH, &iter, TSDB_ORDER_ASC); tsdbInitFileGroupIter(pFileH, &iter, TSDB_ORDER_ASC);
while ((pFGroup = tsdbGetFileGroupNext(&iter)) != NULL) { while ((pFGroup = tsdbGetFileGroupNext(&iter)) != NULL) {
if (tsdbSetAndOpenHelperFile(&rhelper, pFGroup) < 0) goto _err; if (tsdbSetAndOpenHelperFile(&rhelper, pFGroup) < 0) goto _err;
for (int i = 0; i < pRepo->config.maxTables; i++) { for (int i = 1; i < pRepo->config.maxTables; i++) {
STable * pTable = pMeta->tables[i]; STable * pTable = pMeta->tables[i];
SCompIdx *pIdx = &rhelper.pCompIdx[i]; SCompIdx *pIdx = &rhelper.pCompIdx[i];
...@@ -260,7 +260,7 @@ int32_t tsdbCloseRepo(TsdbRepoT *repo) { ...@@ -260,7 +260,7 @@ int32_t tsdbCloseRepo(TsdbRepoT *repo) {
} }
pRepo->commit = 1; pRepo->commit = 1;
// Loop to move pData to iData // Loop to move pData to iData
for (int i = 0; i < pRepo->config.maxTables; i++) { for (int i = 1; i < pRepo->config.maxTables; i++) {
STable *pTable = pRepo->tsdbMeta->tables[i]; STable *pTable = pRepo->tsdbMeta->tables[i];
if (pTable != NULL && pTable->mem != NULL) { if (pTable != NULL && pTable->mem != NULL) {
pTable->imem = pTable->mem; pTable->imem = pTable->mem;
...@@ -313,7 +313,7 @@ int32_t tsdbTriggerCommit(TsdbRepoT *repo) { ...@@ -313,7 +313,7 @@ int32_t tsdbTriggerCommit(TsdbRepoT *repo) {
} }
pRepo->commit = 1; pRepo->commit = 1;
// Loop to move pData to iData // Loop to move pData to iData
for (int i = 0; i < pRepo->config.maxTables; i++) { for (int i = 1; i < pRepo->config.maxTables; i++) {
STable *pTable = pRepo->tsdbMeta->tables[i]; STable *pTable = pRepo->tsdbMeta->tables[i];
if (pTable != NULL && pTable->mem != NULL) { if (pTable != NULL && pTable->mem != NULL) {
pTable->imem = pTable->mem; pTable->imem = pTable->mem;
...@@ -611,6 +611,10 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) { ...@@ -611,6 +611,10 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) {
if (pCfg->maxTables < TSDB_MIN_TABLES || pCfg->maxTables > TSDB_MAX_TABLES) return -1; if (pCfg->maxTables < TSDB_MIN_TABLES || pCfg->maxTables > TSDB_MAX_TABLES) return -1;
} }
// Since tableId starts from 1, we increase maxTables by 1
// TODO: take a fancier way to do this
pCfg->maxTables++;
// Check daysPerFile // Check daysPerFile
if (pCfg->daysPerFile == -1) { if (pCfg->daysPerFile == -1) {
pCfg->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE; pCfg->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE;
...@@ -833,7 +837,7 @@ static int tsdbReadRowsFromCache(SSkipListIterator *pIter, TSKEY maxKey, int max ...@@ -833,7 +837,7 @@ static int tsdbReadRowsFromCache(SSkipListIterator *pIter, TSKEY maxKey, int max
static void tsdbDestroyTableIters(SSkipListIterator **iters, int maxTables) { static void tsdbDestroyTableIters(SSkipListIterator **iters, int maxTables) {
if (iters == NULL) return; if (iters == NULL) return;
for (int tid = 0; tid < maxTables; tid++) { for (int tid = 1; tid < maxTables; tid++) {
if (iters[tid] == NULL) continue; if (iters[tid] == NULL) continue;
tSkipListDestroyIter(iters[tid]); tSkipListDestroyIter(iters[tid]);
} }
...@@ -845,7 +849,7 @@ static SSkipListIterator **tsdbCreateTableIters(STsdbMeta *pMeta, int maxTables) ...@@ -845,7 +849,7 @@ static SSkipListIterator **tsdbCreateTableIters(STsdbMeta *pMeta, int maxTables)
SSkipListIterator **iters = (SSkipListIterator **)calloc(maxTables, sizeof(SSkipListIterator *)); SSkipListIterator **iters = (SSkipListIterator **)calloc(maxTables, sizeof(SSkipListIterator *));
if (iters == NULL) return NULL; if (iters == NULL) return NULL;
for (int tid = 0; tid < maxTables; tid++) { for (int tid = 1; tid < maxTables; tid++) {
STable *pTable = pMeta->tables[tid]; STable *pTable = pMeta->tables[tid];
if (pTable == NULL || pTable->imem == NULL) continue; if (pTable == NULL || pTable->imem == NULL) continue;
...@@ -912,7 +916,7 @@ _exit: ...@@ -912,7 +916,7 @@ _exit:
free(pCache->imem); free(pCache->imem);
pCache->imem = NULL; pCache->imem = NULL;
pRepo->commit = 0; pRepo->commit = 0;
for (int i = 0; i < pCfg->maxTables; i++) { for (int i = 1; i < pCfg->maxTables; i++) {
STable *pTable = pMeta->tables[i]; STable *pTable = pMeta->tables[i];
if (pTable && pTable->imem) { if (pTable && pTable->imem) {
tsdbFreeMemTable(pTable->imem); tsdbFreeMemTable(pTable->imem);
...@@ -946,7 +950,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters ...@@ -946,7 +950,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
if (tsdbSetAndOpenHelperFile(pHelper, pGroup) < 0) goto _err; if (tsdbSetAndOpenHelperFile(pHelper, pGroup) < 0) goto _err;
// Loop to commit data in each table // Loop to commit data in each table
for (int tid = 0; tid < pCfg->maxTables; tid++) { for (int tid = 1; tid < pCfg->maxTables; tid++) {
STable * pTable = pMeta->tables[tid]; STable * pTable = pMeta->tables[tid];
if (pTable == NULL) continue; if (pTable == NULL) continue;
...@@ -984,7 +988,6 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters ...@@ -984,7 +988,6 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
// Write the SCompBlock part // Write the SCompBlock part
if (tsdbWriteCompInfo(pHelper) < 0) goto _err; if (tsdbWriteCompInfo(pHelper) < 0) goto _err;
} }
if (tsdbWriteCompIdx(pHelper) < 0) goto _err; if (tsdbWriteCompIdx(pHelper) < 0) goto _err;
......
...@@ -129,7 +129,7 @@ int tsdbRestoreTable(void *pHandle, void *cont, int contLen) { ...@@ -129,7 +129,7 @@ int tsdbRestoreTable(void *pHandle, void *cont, int contLen) {
void tsdbOrgMeta(void *pHandle) { void tsdbOrgMeta(void *pHandle) {
STsdbMeta *pMeta = (STsdbMeta *)pHandle; STsdbMeta *pMeta = (STsdbMeta *)pHandle;
for (int i = 0; i < pMeta->maxTables; i++) { for (int i = 1; i < pMeta->maxTables; i++) {
STable *pTable = pMeta->tables[i]; STable *pTable = pMeta->tables[i];
if (pTable != NULL && pTable->type == TSDB_CHILD_TABLE) { if (pTable != NULL && pTable->type == TSDB_CHILD_TABLE) {
tsdbAddTableIntoIndex(pMeta, pTable); tsdbAddTableIntoIndex(pMeta, pTable);
...@@ -179,7 +179,7 @@ int32_t tsdbFreeMeta(STsdbMeta *pMeta) { ...@@ -179,7 +179,7 @@ int32_t tsdbFreeMeta(STsdbMeta *pMeta) {
tsdbCloseMetaFile(pMeta->mfh); tsdbCloseMetaFile(pMeta->mfh);
for (int i = 0; i < pMeta->maxTables; i++) { for (int i = 1; i < pMeta->maxTables; i++) {
if (pMeta->tables[i] != NULL) { if (pMeta->tables[i] != NULL) {
tsdbFreeTable(pMeta->tables[i]); tsdbFreeTable(pMeta->tables[i]);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册