diff --git a/src/vnode/common/inc/schema.h b/src/vnode/common/inc/schema.h index 46610135b91545aeeda4a5294ef3055d1c78fc6b..ed9b0e34134147ad520a2c1f25213cb5138040ce 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 0f1923dbcaaf493bacb712cbe1973736901505ec..8fa15ccc0e12a20248da40dd01031858e57ccee9 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 3cf4b7727dca7358f2a91ad14b2acf4ebc4e9ff3..a7d558d38c5ae585f8be4610d96d252522f1319e 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 d942bf3a8e05a32d44751d0a72cbeab6a873355f..a780deb7df40d887ec7b7b2db6c2cd32addcc959 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