Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a6166565
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a6166565
编写于
3月 02, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
d4e6aef5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
46 deletion
+40
-46
src/vnode/tests/tsdb/tsdbTests.cpp
src/vnode/tests/tsdb/tsdbTests.cpp
+1
-1
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+14
-20
src/vnode/tsdb/inc/tsdbMeta.h
src/vnode/tsdb/inc/tsdbMeta.h
+2
-2
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+23
-23
未找到文件。
src/vnode/tests/tsdb/tsdbTests.cpp
浏览文件 @
a6166565
...
...
@@ -4,7 +4,7 @@
#include "tsdb.h"
TEST
(
TsdbTest
,
createTsdbRepo
)
{
ST
SDBCfg
*
pCfg
=
(
STSDBCfg
*
)
malloc
(
sizeof
(
STSDB
Cfg
));
ST
sdbCfg
*
pCfg
=
(
STsdbCfg
*
)
malloc
(
sizeof
(
STsdb
Cfg
));
free
(
pCfg
);
...
...
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
a6166565
...
...
@@ -8,17 +8,19 @@
#include <stdbool.h>
#include <stdint.h>
// #include "cache.h"
#include "schema.h"
#define TSDB_VERSION_MAJOR 1
#define TSDB_VERSION_MINOR 0
typedef
void
tsdb_repo_t
;
// use void to hide implementation details from outside
typedef
int32_t
table_id_t
;
// table ID type in this repository
typedef
int16_t
tsdb_id_t
;
// TSDB repository ID
typedef
void
tsdb_repo_t
;
// use void to hide implementation details from outside
// Submit message
typedef
struct
{
int64_t
uid
;
// the unique table ID
int32_t
tableId
;
// the table ID in the repository.
}
STableId
;
// Submit message for this TSDB
typedef
struct
{
int32_t
numOfTables
;
int32_t
compressed
;
...
...
@@ -27,10 +29,9 @@ typedef struct {
// Submit message for one table
typedef
struct
{
table_id_t
tableId
;
// table ID to insert
STableId
tid
;
int32_t
sversion
;
// data schema version
int32_t
numOfRows
;
// number of rows data
int64_t
uid
;
// table UID to insert
char
data
[];
}
SSubmitBlock
;
...
...
@@ -55,27 +56,20 @@ typedef struct {
int32_t
maxRowsPerFileBlock
;
}
SBlockRowsPolicy
;
// Applications trying to manipulate a table should provide both uid and tableId.
// tableId is used for table quick access and uid for verification.
typedef
struct
{
int64_t
uid
;
// the unique table ID
table_id_t
tableId
;
// the table ID in the repository.
}
STableId
;
// the TSDB repository configuration
typedef
struct
{
char
*
rootDir
;
// TSDB repository root directory, TODO: need to adjust here
tsdb_id
_t
tsdbId
;
int32
_t
tsdbId
;
int32_t
maxTables
;
// maximum number of tables this repository can have
SDataShardPolicy
dataShardPolicy
;
SBlockRowsPolicy
blockRowsPolicy
;
SRetentionPolicy
retentionPlicy
;
// retention configuration
void
*
cachePool
;
// the cache pool the repository to use
}
ST
SDB
Cfg
;
}
ST
sdb
Cfg
;
// the TSDB repository info
typedef
struct
STSDBRepoInfo
{
ST
SDB
Cfg
tsdbCfg
;
ST
sdb
Cfg
tsdbCfg
;
int64_t
version
;
// version of the repository
int64_t
tsdbTotalDataSize
;
// the original inserted data size
int64_t
tsdbTotalDiskSize
;
// the total disk size taken by this TSDB repository
...
...
@@ -86,7 +80,7 @@ typedef struct STSDBRepoInfo {
typedef
struct
{
char
*
tableName
;
int64_t
uid
;
// uid given by upper layer
table_id
_t
tableId
;
// table ID allocated from upper layer
int32
_t
tableId
;
// table ID allocated from upper layer
char
*
stableName
;
// if not NULL, the table is created from a super table, need to make sure the super
// table exists in this TSDB.
...
...
@@ -115,7 +109,7 @@ typedef struct {
*
* @return a TSDB repository handle on success, NULL for failure and the error number is set
*/
tsdb_repo_t
*
tsdbCreateRepo
(
ST
SDB
Cfg
*
pCfg
);
tsdb_repo_t
*
tsdbCreateRepo
(
ST
sdb
Cfg
*
pCfg
);
/**
* Close and free all resources taken by the repository
...
...
@@ -149,7 +143,7 @@ int32_t tsdbCloseRepo(tsdb_repo_t *repo);
*
* @return 0 for success, -1 for failure and the error number is set
*/
int32_t
tsdbConfigRepo
(
tsdb_repo_t
repo
,
ST
SDB
Cfg
*
pCfg
);
int32_t
tsdbConfigRepo
(
tsdb_repo_t
repo
,
ST
sdb
Cfg
*
pCfg
);
/**
* Get the TSDB repository information, including some statistics
...
...
src/vnode/tsdb/inc/tsdbMeta.h
浏览文件 @
a6166565
...
...
@@ -16,7 +16,7 @@ typedef enum {
}
TSDB_TABLE_TYPE
;
typedef
struct
STable
{
tsdb_id
_t
tableId
;
int32
_t
tableId
;
int64_t
uid
;
char
*
tableName
;
TSDB_TABLE_TYPE
type
;
...
...
@@ -24,7 +24,7 @@ typedef struct STable {
int64_t
createdTime
;
// super table UID
tsdb_id
_t
superTableId
;
int32
_t
superTableId
;
// Schema for this table
// For TSDB_SUPER_TABLE, it is the schema including tags
...
...
src/vnode/tsdb/src/tsdb.c
→
src/vnode/tsdb/src/tsdb
Main
.c
浏览文件 @
a6166565
...
...
@@ -21,19 +21,19 @@ enum {
typedef
struct
_tsdb_repo
{
// TSDB configuration
ST
SDB
Cfg
*
pCfg
;
ST
sdb
Cfg
*
pCfg
;
// The meter meta handle of this TSDB repository
SMetaHandle
*
pMetaHandle
;
SMetaHandle
*
tsdbMeta
;
// The cache Handle
SCacheHandle
*
pCacheHandl
e
;
SCacheHandle
*
tsdbCach
e
;
// Disk tier handle for multi-tier storage
void
*
pD
iskTier
;
void
*
d
iskTier
;
// File Store
void
*
pFileStore
;
void
*
tsdbFiles
;
pthread_mutex_t
tsdbMutex
;
...
...
@@ -47,7 +47,7 @@ typedef struct _tsdb_repo {
#define TSDB_IS_REPO_CLOSED(pRepo) ((pRepo)->state == TSDB_REPO_STATE_CLOSED)
// Check the correctness of the TSDB configuration
static
int32_t
tsdbCheckCfg
(
ST
SDB
Cfg
*
pCfg
)
{
static
int32_t
tsdbCheckCfg
(
ST
sdb
Cfg
*
pCfg
)
{
if
(
pCfg
->
rootDir
==
NULL
)
return
-
1
;
if
(
access
(
pCfg
->
rootDir
,
F_OK
|
R_OK
|
W_OK
)
==
-
1
)
{
...
...
@@ -65,7 +65,7 @@ static int32_t tsdbClearFiles(STSDBRepo *pRepo) {
// TODO
}
tsdb_repo_t
*
tsdbCreateRepo
(
ST
SDB
Cfg
*
pCfg
)
{
tsdb_repo_t
*
tsdbCreateRepo
(
ST
sdb
Cfg
*
pCfg
)
{
// Check the configuration
if
(
tsdbCheckCfg
(
pCfg
)
<
0
)
{
...
...
@@ -79,18 +79,18 @@ tsdb_repo_t *tsdbCreateRepo(STSDBCfg *pCfg) {
}
// TODO: Initailize pMetahandle
pRepo
->
pMetaHandle
=
tsdbCreateMetaHandle
(
pCfg
->
maxTables
);
if
(
pRepo
->
pMetaHandle
==
NULL
)
{
pRepo
->
tsdbMeta
=
tsdbCreateMetaHandle
(
pCfg
->
maxTables
);
if
(
pRepo
->
tsdbMeta
==
NULL
)
{
// TODO: deal with error
free
(
pRepo
);
return
NULL
;
}
// TODO: Initialize cache handle
pRepo
->
pCacheHandl
e
=
tsdbCreateCache
(
5
);
if
(
pRepo
->
pCacheHandl
e
==
NULL
)
{
pRepo
->
tsdbCach
e
=
tsdbCreateCache
(
5
);
if
(
pRepo
->
tsdbCach
e
==
NULL
)
{
// TODO: free the object and return error
tsdbFreeMetaHandle
(
pRepo
->
pCacheHandl
e
);
tsdbFreeMetaHandle
(
pRepo
->
tsdbCach
e
);
free
(
pRepo
);
return
NULL
;
}
...
...
@@ -101,7 +101,7 @@ tsdb_repo_t *tsdbCreateRepo(STSDBCfg *pCfg) {
// Create the Meta data file and data directory
if
(
tsdbCreateFiles
(
pRepo
)
<
0
)
{
// Failed to create and save files
tsdbFreeMetaHandle
(
pRepo
->
pCacheHandl
e
);
tsdbFreeMetaHandle
(
pRepo
->
tsdbCach
e
);
free
(
pRepo
);
return
NULL
;
}
...
...
@@ -117,10 +117,10 @@ int32_t tsdbDropRepo(tsdb_repo_t *repo) {
pRepo
->
state
=
TSDB_REPO_STATE_CLOSED
;
// Free the metaHandle
tsdbFreeMetaHandle
(
pRepo
->
pMetaHandle
);
tsdbFreeMetaHandle
(
pRepo
->
tsdbMeta
);
// Free the cache
tsdbFreeCache
(
pRepo
->
pCacheHandl
e
);
tsdbFreeCache
(
pRepo
->
tsdbCach
e
);
tsdbClearFiles
(
pRepo
);
...
...
@@ -139,14 +139,14 @@ tsdb_repo_t *tsdbOpenRepo(char *tsdbDir) {
}
// TODO: Initialize configuration from the file
pRepo
->
pMetaHandle
=
tsdbOpenMetaHandle
();
if
(
pRepo
->
pMetaHandle
==
NULL
)
{
pRepo
->
tsdbMeta
=
tsdbOpenMetaHandle
();
if
(
pRepo
->
tsdbMeta
==
NULL
)
{
free
(
pRepo
);
return
NULL
;
}
pRepo
->
pCacheHandl
e
=
tsdbCreateCache
(
5
);
if
(
pRepo
->
pCacheHandl
e
==
NULL
)
{
pRepo
->
tsdbCach
e
=
tsdbCreateCache
(
5
);
if
(
pRepo
->
tsdbCach
e
==
NULL
)
{
// TODO: deal with error
return
NULL
;
}
...
...
@@ -167,14 +167,14 @@ int32_t tsdbCloseRepo(tsdb_repo_t *repo) {
pRepo
->
state
=
TSDB_REPO_STATE_CLOSED
;
tsdbFreeMetaHandle
(
pRepo
->
pMetaHandle
);
tsdbFreeMetaHandle
(
pRepo
->
tsdbMeta
);
tsdbFreeCache
(
pRepo
->
pMetaHandle
);
tsdbFreeCache
(
pRepo
->
tsdbMeta
);
return
0
;
}
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
ST
SDB
Cfg
*
pCfg
)
{
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
ST
sdb
Cfg
*
pCfg
)
{
STSDBRepo
*
pRepo
=
(
STSDBRepo
*
)
repo
;
pRepo
->
pCfg
=
pCfg
;
...
...
@@ -188,7 +188,7 @@ STSDBRepoInfo *tsdbGetStatus(tsdb_repo_t *pRepo) {
int32_t
tsdbCreateTable
(
tsdb_repo_t
*
repo
,
STableCfg
*
pCfg
)
{
STSDBRepo
*
pRepo
=
(
STSDBRepo
*
)
repo
;
return
tsdbCreateTableImpl
(
pRepo
->
pMetaHandle
,
pCfg
);
return
tsdbCreateTableImpl
(
pRepo
->
tsdbMeta
,
pCfg
);
}
int32_t
tsdbAlterTable
(
tsdb_repo_t
*
pRepo
,
STableCfg
*
pCfg
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录