add more
This commit is contained in:
parent
38d1d0e94b
commit
a04663b7ee
|
@ -22,7 +22,7 @@ typedef struct {
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
int32_t numOfTags;
|
int32_t numOfTags;
|
||||||
int32_t colIdCounter;
|
int32_t colIdCounter;
|
||||||
SColumn *columns;
|
SColumn columns[];
|
||||||
} SSchema;
|
} SSchema;
|
||||||
|
|
||||||
/* Inline schema definition
|
/* Inline schema definition
|
||||||
|
|
|
@ -60,7 +60,7 @@ SISchema tdConvertSchemaToInline(SSchema *pSchema) {
|
||||||
|
|
||||||
TD_ISCHEMA_LEN(pISchema) = (int32_t)len;
|
TD_ISCHEMA_LEN(pISchema) = (int32_t)len;
|
||||||
memcpy((void *)TD_ISCHEMA_SCHEMA(pISchema), (void *)pSchema, sizeof(SSchema));
|
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),
|
memcpy((void *)TD_SCHEMA_COLS(TD_ISCHEMA_SCHEMA(pISchema)), (void *)TD_SCHEMA_COLS(pSchema),
|
||||||
sizeof(SColumn) * totalCols);
|
sizeof(SColumn) * totalCols);
|
||||||
|
|
||||||
|
|
|
@ -13,5 +13,25 @@ TEST(TsdbTest, createTsdbRepo) {
|
||||||
|
|
||||||
ASSERT_NE(pRepo, nullptr);
|
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);
|
tsdbCloseRepo(pRepo);
|
||||||
}
|
}
|
|
@ -17,7 +17,6 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable);
|
||||||
static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable);
|
static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable);
|
||||||
static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable);
|
static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable);
|
||||||
static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable);
|
static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable);
|
||||||
static int tsdbInsertRowToTable(STable *pTable, SDataRow row);
|
|
||||||
|
|
||||||
STsdbMeta *tsdbCreateMeta(int32_t maxTables) {
|
STsdbMeta *tsdbCreateMeta(int32_t maxTables) {
|
||||||
STsdbMeta *pMeta = (STsdbMeta *)malloc(sizeof(STsdbMeta));
|
STsdbMeta *pMeta = (STsdbMeta *)malloc(sizeof(STsdbMeta));
|
||||||
|
@ -95,10 +94,10 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
|
||||||
0, NULL); // Allow duplicate key, no lock
|
0, NULL); // Allow duplicate key, no lock
|
||||||
if (pSTable->content.pIndex == NULL) {
|
if (pSTable->content.pIndex == NULL) {
|
||||||
free(pSTable);
|
free(pSTable);
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
tsdbFreeTable(pTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable) {
|
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) {
|
static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) {
|
||||||
// TODO
|
// TODO
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable) {
|
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) {
|
static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
|
||||||
assert(pTable->type == TSDB_STABLE);
|
assert(pTable->type == TSDB_STABLE);
|
||||||
// TODO
|
// 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;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue