diff --git a/src/vnode/tsdb/inc/tsdbMeta.h b/src/vnode/tsdb/inc/tsdbMeta.h index 059ec87e914bbcfd416a3b160dfdeabe5e911065..aa25e0844456f6ebf8bea6fc40eacc179ffd9d7f 100644 --- a/src/vnode/tsdb/inc/tsdbMeta.h +++ b/src/vnode/tsdb/inc/tsdbMeta.h @@ -80,6 +80,7 @@ typedef struct { STsdbMeta *tsdbInitMeta(const char *rootDir, int32_t maxTables); int32_t tsdbFreeMeta(STsdbMeta *pMeta); +STSchema * tsdbGetTableSchema(STsdbMeta *pMeta, STable *pTable); // ---- Operation on STable #define TSDB_TABLE_ID(pTable) ((pTable)->tableId) diff --git a/src/vnode/tsdb/src/tsdbMain.c b/src/vnode/tsdb/src/tsdbMain.c index 6d675d300a418b521fd5595396c25f3dfac88d55..6510c0294024f9ff08aba279822f488a20a0576c 100644 --- a/src/vnode/tsdb/src/tsdbMain.c +++ b/src/vnode/tsdb/src/tsdbMain.c @@ -988,7 +988,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters if (tsdbLoadCompBlocks(pGroup, pIdx, (void *)pCompInfo) < 0) { /* TODO */ } - tdInitDataCols(pCols, pTable->schema); + tdInitDataCols(pCols, tsdbGetTableSchema(pMeta, pTable)); SCompBlock *pTBlock = TSDB_COMPBLOCK_AT(pCompInfo, pIdx->numOfSuperBlocks); int nBlocks = 0; @@ -1040,7 +1040,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters } } - tdInitDataCols(pCols, pTable->schema); + tdInitDataCols(pCols, tsdbGetTableSchema(pMeta, pTable)); int maxRowsToRead = pCfg->maxRowsPerFileBlock * 4 / 5; while (1) { diff --git a/src/vnode/tsdb/src/tsdbMeta.c b/src/vnode/tsdb/src/tsdbMeta.c index 22680a839b28db0d26723df94eedcb58a1758abe..12e2dbcb56cba5a070fff65bcb3b0a790501ac36 100644 --- a/src/vnode/tsdb/src/tsdbMeta.c +++ b/src/vnode/tsdb/src/tsdbMeta.c @@ -185,6 +185,18 @@ int32_t tsdbFreeMeta(STsdbMeta *pMeta) { return 0; } +STSchema *tsdbGetTableSchema(STsdbMeta *pMeta, STable *pTable) { + if (pTable->type == TSDB_NORMAL_TABLE || pTable->type == TSDB_SUPER_TABLE) { + return pTable->schema; + } else if (pTable->type == TSDB_CHILD_TABLE) { + STable *pSuper = tsdbGetTableByUid(pMeta, pTable->superUid); + if (pSuper == NULL) return NULL; + return pSuper->schema; + } else { + return NULL; + } +} + int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) { if (tsdbCheckTableCfg(pCfg) < 0) return -1; diff --git a/src/vnode/tsdb/tests/tsdbTests.cpp b/src/vnode/tsdb/tests/tsdbTests.cpp index 6cfe0e626dd217b70597c2f75f2f7a575472d1e3..9849ffe8fa7c8ec1b1fa160c8feff06371cb9c60 100644 --- a/src/vnode/tsdb/tests/tsdbTests.cpp +++ b/src/vnode/tsdb/tests/tsdbTests.cpp @@ -80,7 +80,7 @@ TEST(TsdbTest, createRepo) { // // 3. Loop to write some simple data int nRows = 10000000; - int rowsPerSubmit = 10; + int rowsPerSubmit = 100; int64_t start_time = 1584081000000; SSubmitMsg *pMsg = (SSubmitMsg *)malloc(sizeof(SSubmitMsg) + sizeof(SSubmitBlk) + tdMaxRowBytesFromSchema(schema) * rowsPerSubmit); @@ -96,7 +96,7 @@ TEST(TsdbTest, createRepo) { pBlock->len = 0; for (int i = 0; i < rowsPerSubmit; i++) { // start_time += 1000; - start_time -= 1000; + start_time += 1000; SDataRow row = (SDataRow)(pBlock->data + pBlock->len); tdInitDataRow(row, schema);