Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
d352819f
T
TDengine
项目概览
loser646
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d352819f
编写于
3月 11, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor code
上级
798d2171
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
78 addition
and
68 deletion
+78
-68
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+18
-22
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+17
-3
src/vnode/tsdb/tests/tsdbTests.cpp
src/vnode/tsdb/tests/tsdbTests.cpp
+43
-43
未找到文件。
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
d352819f
...
...
@@ -32,6 +32,24 @@ extern "C" {
typedef
void
tsdb_repo_t
;
// use void to hide implementation details from outside
// --------- TSDB REPOSITORY CONFIGURATION DEFINITION
typedef
struct
{
int8_t
precision
;
int32_t
tsdbId
;
int32_t
maxTables
;
// maximum number of tables this repository can have
int32_t
daysPerFile
;
// day per file sharding policy
int32_t
minRowsPerFileBlock
;
// minimum rows per file block
int32_t
maxRowsPerFileBlock
;
// maximum rows per file block
int32_t
keep
;
// day of data to keep
int64_t
maxCacheSize
;
// maximum cache size this TSDB can use
}
STsdbCfg
;
void
tsdbSetDefaultCfg
(
STsdbCfg
*
pCfg
);
STsdbCfg
*
tsdbCreateDefaultCfg
();
void
tsdbFreeCfg
(
STsdbCfg
*
pCfg
);
// --------- TSDB REPOSITORY DEFINITION
typedef
struct
{
int64_t
uid
;
// the unique table ID
int32_t
tid
;
// the table ID in the repository.
...
...
@@ -55,18 +73,6 @@ typedef struct {
enum
{
TSDB_PRECISION_MILLI
,
TSDB_PRECISION_MICRO
,
TSDB_PRECISION_NANO
};
// the TSDB repository configuration
typedef
struct
{
int8_t
precision
;
int32_t
tsdbId
;
int32_t
maxTables
;
// maximum number of tables this repository can have
int32_t
daysPerFile
;
// day per file sharding policy
int32_t
minRowsPerFileBlock
;
// minimum rows per file block
int32_t
maxRowsPerFileBlock
;
// maximum rows per file block
int32_t
keep
;
// day of data to keep
int64_t
maxCacheSize
;
// maximum cache size this TSDB can use
}
STsdbCfg
;
// the TSDB repository info
typedef
struct
STsdbRepoInfo
{
STsdbCfg
tsdbCfg
;
...
...
@@ -100,16 +106,6 @@ typedef struct {
int64_t
tableTotalDiskSize
;
// In bytes
}
STableInfo
;
/**
* Create a configuration for TSDB default
* @return a pointer to a configuration. the configuration must call tsdbFreeCfg to free memory after usage
*/
STsdbCfg
*
tsdbCreateDefaultCfg
();
/**
* Free
*/
void
tsdbFreeCfg
(
STsdbCfg
*
pCfg
);
/**
* Create a new TSDB repository
...
...
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
d352819f
...
...
@@ -82,9 +82,11 @@ static int32_t tsdbInsertDataToTable(tsdb_repo_t *repo, SSubmitBlock *pBlock);
#define TSDB_IS_REPO_ACTIVE(pRepo) ((pRepo)->state == TSDB_REPO_STATE_ACTIVE)
#define TSDB_IS_REPO_CLOSED(pRepo) ((pRepo)->state == TSDB_REPO_STATE_CLOSED)
STsdbCfg
*
tsdbCreateDefaultCfg
()
{
STsdbCfg
*
pCfg
=
(
STsdbCfg
*
)
malloc
(
sizeof
(
STsdbCfg
));
if
(
pCfg
==
NULL
)
return
NULL
;
/**
* Set the default TSDB configuration
*/
void
tsdbSetDefaultCfg
(
STsdbCfg
*
pCfg
)
{
if
(
pCfg
==
NULL
)
return
;
pCfg
->
precision
=
-
1
;
pCfg
->
tsdbId
=
0
;
...
...
@@ -94,6 +96,18 @@ STsdbCfg *tsdbCreateDefaultCfg() {
pCfg
->
maxRowsPerFileBlock
=
-
1
;
pCfg
->
keep
=
-
1
;
pCfg
->
maxCacheSize
=
-
1
;
}
/**
* Create a configuration for TSDB default
* @return a pointer to a configuration. the configuration object
* must call tsdbFreeCfg to free memory after usage
*/
STsdbCfg
*
tsdbCreateDefaultCfg
()
{
STsdbCfg
*
pCfg
=
(
STsdbCfg
*
)
malloc
(
sizeof
(
STsdbCfg
));
if
(
pCfg
==
NULL
)
return
NULL
;
tsdbSetDefaultCfg
(
pCfg
);
return
pCfg
;
}
...
...
src/vnode/tsdb/tests/tsdbTests.cpp
浏览文件 @
d352819f
...
...
@@ -5,52 +5,30 @@
#include "dataformat.h"
#include "tsdbMeta.h"
TEST
(
TsdbTest
,
createTable
)
{
STsdbMeta
*
pMeta
=
tsdbCreateMeta
(
100
);
ASSERT_NE
(
pMeta
,
nullptr
);
STableCfg
config
;
config
.
tableId
.
tid
=
0
;
config
.
tableId
.
uid
=
98868728187539L
;
config
.
numOfCols
=
5
;
config
.
schema
=
tdNewSchema
(
config
.
numOfCols
);
for
(
int
i
=
0
;
i
<
schemaNCols
(
config
.
schema
);
i
++
)
{
STColumn
*
pCol
=
tdNewCol
(
TSDB_DATA_TYPE_BIGINT
,
i
,
0
);
tdColCpy
(
schemaColAt
(
config
.
schema
,
i
),
pCol
);
tdFreeCol
(
pCol
);
}
config
.
tagValues
=
nullptr
;
tsdbCreateTableImpl
(
pMeta
,
&
config
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
config
.
tableId
.
uid
);
ASSERT_NE
(
pTable
,
nullptr
);
}
TEST
(
TsdbTest
,
createRepo
)
{
STsdbCfg
*
pCfg
=
tsdbCreateDefaultCfg
()
;
STsdbCfg
config
;
// Create a tsdb repository
tsdb_repo_t
*
pRepo
=
tsdbCreateRepo
(
"/root/mnt/test/vnode0"
,
pCfg
,
NULL
);
tsdbSetDefaultCfg
(
&
config
);
tsdb_repo_t
*
pRepo
=
tsdbCreateRepo
(
"/home/ubuntu/work/ttest/vnode0"
,
&
config
,
NULL
);
ASSERT_NE
(
pRepo
,
nullptr
);
tsdbFreeCfg
(
pCfg
);
// create a normal table in this repository
STableCfg
config
;
config
.
tableId
.
tid
=
0
;
config
.
tableId
.
uid
=
98868728187539L
;
config
.
numOfCols
=
5
;
config
.
schema
=
tdNewSchema
(
config
.
numOfCols
);
STColumn
*
pCol
=
tdNewCol
(
TSDB_DATA_TYPE_TIMESTAMP
,
0
,
0
);
tdColCpy
(
schemaColAt
(
config
.
schema
,
0
),
pCol
);
tdFreeCol
(
pCol
);
for
(
int
i
=
1
;
i
<
schemaNCols
(
config
.
schema
);
i
++
)
{
pCol
=
tdNewCol
(
TSDB_DATA_TYPE_BIGINT
,
i
,
0
);
tdColCpy
(
schemaColAt
(
config
.
schema
,
i
),
pCol
);
tdFreeCol
(
pCol
);
}
//
//
create a normal table in this repository
//
STableCfg config;
//
config.tableId.tid = 0;
//
config.tableId.uid = 98868728187539L;
//
config.numOfCols = 5;
//
config.schema = tdNewSchema(config.numOfCols);
//
STColumn *pCol = tdNewCol(TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
//
tdColCpy(schemaColAt(config.schema, 0), pCol);
//
tdFreeCol(pCol);
//
for (int i = 1; i < schemaNCols(config.schema); i++) {
//
pCol = tdNewCol(TSDB_DATA_TYPE_BIGINT, i, 0);
//
tdColCpy(schemaColAt(config.schema, i), pCol);
//
tdFreeCol(pCol);
//
}
tsdbCreateTable
(
pRepo
,
&
config
);
//
tsdbCreateTable(pRepo, &config);
// Write some data
// int32_t size = sizeof(SSubmitMsg) + sizeof(SSubmitBlock) + tdMaxRowDataBytes(config.schema) * 10 + sizeof(int32_t);
...
...
@@ -89,6 +67,28 @@ TEST(TsdbTest, createRepo) {
// tdFreeDataRow(row);
tdFreeSchema
(
config
.
schema
);
tsdbDropRepo
(
pRepo
);
}
\ No newline at end of file
// tdFreeSchema(config.schema);
// tsdbDropRepo(pRepo);
}
TEST
(
TsdbTest
,
DISABLED_createTable
)
{
STsdbMeta
*
pMeta
=
tsdbCreateMeta
(
100
);
ASSERT_NE
(
pMeta
,
nullptr
);
STableCfg
config
;
config
.
tableId
.
tid
=
0
;
config
.
tableId
.
uid
=
98868728187539L
;
config
.
numOfCols
=
5
;
config
.
schema
=
tdNewSchema
(
config
.
numOfCols
);
for
(
int
i
=
0
;
i
<
schemaNCols
(
config
.
schema
);
i
++
)
{
STColumn
*
pCol
=
tdNewCol
(
TSDB_DATA_TYPE_BIGINT
,
i
,
0
);
tdColCpy
(
schemaColAt
(
config
.
schema
,
i
),
pCol
);
tdFreeCol
(
pCol
);
}
config
.
tagValues
=
nullptr
;
tsdbCreateTableImpl
(
pMeta
,
&
config
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
config
.
tableId
.
uid
);
ASSERT_NE
(
pTable
,
nullptr
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录