提交 192e33db 编写于 作者: H hzcheng

refactor and adjust some code

上级 6656c118
#if !defined(_TD_TYPE_H_)
#ifndef _TD_TYPE_H_
#define _TD_TYPE_H_
#include <stdint.h>
......@@ -11,6 +11,7 @@ typedef enum {
TD_DATATYPE_BIGINT,
TD_DATATYPE_FLOAT,
TD_DATATYPE_DOUBLE,
TD_DATATYPE_TIMESTAMP,
TD_DATATYPE_VARCHAR,
TD_DATATYPE_NCHAR,
TD_DATATYPE_BINARY
......@@ -26,6 +27,7 @@ extern const int32_t rowDataLen[];
#define TD_DATATYPE_BIGINT_NULL
#define TD_DATATYPE_FLOAT_NULL
#define TD_DATATYPE_DOUBLE_NULL
#define TD_DATATYPE_TIMESTAMP_NULL
#define TD_DATATYPE_VARCHAR_NULL
#define TD_DATATYPE_NCHAR_NULL
#define TD_DATATYPE_BINARY_NULL
......
......@@ -58,6 +58,7 @@ int32_t tdAppendColVal(SDataRow row, void *value, SColumn *pCol, int32_t suffixO
case TD_DATATYPE_BIGINT:
case TD_DATATYPE_FLOAT:
case TD_DATATYPE_DOUBLE:
case TD_DATATYPE_TIMESTAMP:
memcpy(dataRowIdx(row, pCol->offset + sizeof(int32_t)), value, rowDataLen[pCol->type]);
if (dataRowLen(row) > suffixOffset + sizeof(int32_t))
dataRowSetLen(row, dataRowLen(row) + rowDataLen[pCol->type]);
......
......@@ -10,6 +10,7 @@ const int32_t rowDataLen[] = {
sizeof(int64_t), // TD_DATATYPE_BIGINT,
sizeof(float), // TD_DATATYPE_FLOAT,
sizeof(double), // TD_DATATYPE_DOUBLE,
sizeof(int64_t), // TD_DATATYPE_TIMESTAMP
sizeof(int32_t), // TD_DATATYPE_VARCHAR,
sizeof(int32_t), // TD_DATATYPE_NCHAR,
sizeof(int32_t) // TD_DATATYPE_BINARY
......
......@@ -206,7 +206,8 @@ static int32_t tsdbCheckTableCfg(STableCfg *pCfg) {
}
STable *tsdbGetTableByUid(STsdbMeta *pMeta, int64_t uid) {
return *(STable **)taosGetDataFromHashTable(pMeta->tableMap, (char *)(&uid), sizeof(uid));
STable *pTable = *(STable **)taosGetDataFromHashTable(pMeta->tableMap, (char *)(&uid), sizeof(uid));
return pTable;
}
static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable) {
......
#include <gtest/gtest.h>
#include <stdlib.h>
#include "tsdb.h"
#include "tsdbMeta.h"
TEST(TsdbTest, createTable) {
TEST(TsdbTest, DISABLED_createTable) {
STsdbMeta *pMeta = tsdbCreateMeta(100);
ASSERT_NE(pMeta, nullptr);
......@@ -23,4 +24,31 @@ TEST(TsdbTest, createTable) {
STable *pTable = tsdbGetTableByUid(pMeta, config.tableId.uid);
ASSERT_NE(pTable, nullptr);
}
TEST(TsdbTest, createRepo) {
STsdbCfg *pCfg = tsdbCreateDefaultCfg();
tsdb_repo_t *pRepo = tsdbCreateRepo("/root/mnt/test/vnode0", pCfg, NULL);
ASSERT_NE(pRepo, nullptr);
tsdbFreeCfg(pCfg);
STableCfg config;
config.tableId.tid = 0;
config.tableId.uid = 98868728187539L;
config.numOfCols = 5;
config.schema = tdNewSchema(config.numOfCols);
SColumn *pCol = tdNewCol(TD_DATATYPE_TIMESTAMP, 0, 0);
tdColCpy(schemaColAt(config.schema, 0), pCol);
tdFreeCol(pCol);
for (int i = 1; i < schemaNCols(config.schema); i++) {
pCol = tdNewCol(TD_DATATYPE_BIGINT, i, 0);
tdColCpy(schemaColAt(config.schema, i), pCol);
tdFreeCol(pCol);
}
tsdbCreateTable(pRepo, &config);
tdFreeSchema(config.schema);
tsdbDropRepo(pRepo);
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册