提交 a04663b7 编写于 作者: H hzcheng

add more

上级 38d1d0e9
......@@ -22,7 +22,7 @@ typedef struct {
int32_t numOfCols;
int32_t numOfTags;
int32_t colIdCounter;
SColumn *columns;
SColumn columns[];
} SSchema;
/* Inline schema definition
......
......@@ -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);
......
......@@ -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
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册