diff --git a/src/vnode/common/inc/schema.h b/src/vnode/common/inc/schema.h index 46610135b9..ed9b0e3413 100644 --- a/src/vnode/common/inc/schema.h +++ b/src/vnode/common/inc/schema.h @@ -22,7 +22,7 @@ typedef struct { int32_t numOfCols; int32_t numOfTags; int32_t colIdCounter; - SColumn *columns; + SColumn columns[]; } SSchema; /* Inline schema definition diff --git a/src/vnode/common/src/schema.c b/src/vnode/common/src/schema.c index 0f1923dbca..8fa15ccc0e 100644 --- a/src/vnode/common/src/schema.c +++ b/src/vnode/common/src/schema.c @@ -60,7 +60,7 @@ SISchema tdConvertSchemaToInline(SSchema *pSchema) { TD_ISCHEMA_LEN(pISchema) = (int32_t)len; memcpy((void *)TD_ISCHEMA_SCHEMA(pISchema), (void *)pSchema, sizeof(SSchema)); - TD_SCHEMA_COLS(TD_ISCHEMA_SCHEMA(pISchema)) = (SColumn *)(pISchema + TD_ISCHEMA_HEADER_SIZE); + // TD_SCHEMA_COLS(TD_ISCHEMA_SCHEMA(pISchema)) = (SColumn *)(pISchema + TD_ISCHEMA_HEADER_SIZE); memcpy((void *)TD_SCHEMA_COLS(TD_ISCHEMA_SCHEMA(pISchema)), (void *)TD_SCHEMA_COLS(pSchema), sizeof(SColumn) * totalCols); diff --git a/src/vnode/tests/tsdb/tsdbTests.cpp b/src/vnode/tests/tsdb/tsdbTests.cpp index 3cf4b7727d..a7d558d38c 100644 --- a/src/vnode/tests/tsdb/tsdbTests.cpp +++ b/src/vnode/tests/tsdb/tsdbTests.cpp @@ -13,5 +13,25 @@ TEST(TsdbTest, createTsdbRepo) { ASSERT_NE(pRepo, nullptr); + STableCfg config; + config.tableId.tid = 0; + config.tableId.uid = 10889498868728187539; + config.numOfCols = 2; + config.schema = (SSchema *)malloc(sizeof(SSchema) + sizeof(SColumn) * config.numOfCols); + config.schema->version = 0; + config.schema->numOfCols = 2; + config.schema->numOfTags = 0; + config.schema->colIdCounter = 1; + for (int i = 0; i < config.numOfCols; i++) { + SColumn *pCol = config.schema->columns + i; + pCol->type = TD_DATATYPE_BIGINT; + pCol->colId = config.schema->colIdCounter++; + pCol->offset = 10; + pCol->colName = strdup("col1"); + } + config.tagValues = NULL; + + tsdbCreateTable(pRepo, &config); + tsdbCloseRepo(pRepo); } \ No newline at end of file diff --git a/src/vnode/tsdb/src/tsdbMeta.c b/src/vnode/tsdb/src/tsdbMeta.c index d942bf3a8e..a780deb7df 100644 --- a/src/vnode/tsdb/src/tsdbMeta.c +++ b/src/vnode/tsdb/src/tsdbMeta.c @@ -17,7 +17,6 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable); static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable); static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable); static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable); -static int tsdbInsertRowToTable(STable *pTable, SDataRow row); STsdbMeta *tsdbCreateMeta(int32_t maxTables) { STsdbMeta *pMeta = (STsdbMeta *)malloc(sizeof(STsdbMeta)); @@ -95,10 +94,10 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) { 0, NULL); // Allow duplicate key, no lock if (pSTable->content.pIndex == NULL) { free(pSTable); - return NULL; + return -1; } } else { - if (pSTable->type != TSDB_SUPER_TABLE) return NULL; + if (pSTable->type != TSDB_SUPER_TABLE) return -1; } } @@ -173,6 +172,8 @@ int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) { tsdbFreeTable(pTable); } + + return 0; } int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable) { @@ -235,6 +236,7 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable) { static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) { // TODO + return 0; } static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable) { @@ -254,18 +256,5 @@ static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable) { static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) { assert(pTable->type == TSDB_STABLE); // TODO - return 0; -} - -static int tsdbInsertRowToTable(STable *pTable, SDataRow row) { - int32_t headSize; - int32_t level; - tSkipListRandNodeInfo(pTable->content.pIndex, &level, &headSize); - - // SSkipListNode *pNode = tsdbAllocFromCache(p); - // if (pNode == NULL) { - // return -1; - // } - return 0; } \ No newline at end of file