Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
3b940a6b
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,发现更多精彩内容 >>
提交
3b940a6b
编写于
3月 03, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
b2e18917
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
64 addition
and
31 deletion
+64
-31
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+6
-5
src/vnode/tsdb/inc/tsdbMeta.h
src/vnode/tsdb/inc/tsdbMeta.h
+11
-12
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+1
-1
src/vnode/tsdb/src/tsdbMeta.c
src/vnode/tsdb/src/tsdbMeta.c
+46
-13
未找到文件。
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
3b940a6b
...
...
@@ -29,7 +29,7 @@ typedef struct {
// Submit message for one table
typedef
struct
{
STableId
t
i
d
;
STableId
t
ableI
d
;
int32_t
sversion
;
// data schema version
int32_t
numOfRows
;
// number of rows data
char
data
[];
...
...
@@ -47,20 +47,20 @@ typedef struct {
}
STsdbCfg
;
// the TSDB repository info
typedef
struct
ST
SDB
RepoInfo
{
typedef
struct
ST
sdb
RepoInfo
{
STsdbCfg
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
// TODO: Other informations to add
}
ST
SDB
RepoInfo
;
}
ST
sdb
RepoInfo
;
// the meter configuration
typedef
struct
{
char
*
tableName
;
STableId
tableId
;
char
*
s
tableNam
e
;
// if not NULL, the table is created from a super table, need to make sure the super
char
*
s
uperTabl
e
;
// if not NULL, the table is created from a super table, need to make sure the super
// table exists in this TSDB.
int64_t
stableUid
;
...
...
@@ -83,6 +83,7 @@ typedef struct {
/**
* Create a new TSDB repository
* @param rootDir the TSDB repository root directory
* @param pCfg the TSDB repository configuration, upper layer to free the pointer
*
* @return a TSDB repository handle on success, NULL for failure and the error number is set
...
...
@@ -131,7 +132,7 @@ int32_t tsdbConfigRepo(tsdb_repo_t *repo, STsdbCfg *pCfg);
* @return a info struct handle on success, NULL for failure and the error number is set. The upper
* layers should free the info handle themselves or memory leak will occur
*/
ST
SDB
RepoInfo
*
tsdbGetStatus
(
tsdb_repo_t
*
pRepo
);
ST
sdb
RepoInfo
*
tsdbGetStatus
(
tsdb_repo_t
*
pRepo
);
// -- For table manipulation
...
...
src/vnode/tsdb/inc/tsdbMeta.h
浏览文件 @
3b940a6b
...
...
@@ -51,17 +51,16 @@ typedef struct STable {
// A handle to deal with stream
void
*
streamHandle
;
struct
STable
*
next
;
}
STable
;
typedef
struct
{
int32_t
numOfTables
;
// Number of tables not including TSDB_SUPER_TABLE (#TSDB_NTABLE + #TSDB_STABLE)
int32_t
maxTables
;
int32_t
numOfSuperTables
;
// Number of super tables (#TSDB_SUPER_TABLE)
// An array of tables (TSDB_NTABLE and TSDB_STABLE) in this TSDB repository
STable
**
pTables
;
// A map of tableName->tableId
// TODO: May use hash table
void
*
pNameTableMap
;
STable
**
tables
;
// array of normal tables
STable
*
stables
;
// linked list of super tables
void
*
tableMap
;
// table map of name ==> table
}
STsdbMeta
;
// ---- Operation on STable
...
...
@@ -84,10 +83,10 @@ SSchema *tsdbGetTableSchema(STable *pTable);
#define TSDB_GET_TABLE_OF_NAME(pHandle, name)
/* TODO */
// Create a new meta handle with configuration
STsdbMeta
*
tsdbCreateMeta
(
int32_t
maxTables
);
STsdbMeta
*
tsdbCreateMeta
(
int32_t
maxTables
);
int32_t
tsdbFreeMeta
(
STsdbMeta
*
pMeta
);
// Recover the meta handle from the file
STsdbMeta
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
);
STsdbMeta
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
);
int32_t
tsdbCreateTableImpl
(
STsdbMeta
*
pHandle
,
STableCfg
*
pCfg
);
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
3b940a6b
...
...
@@ -175,7 +175,7 @@ int32_t tsdbConfigRepo(tsdb_repo_t *repo, STsdbCfg *pCfg) {
return
0
;
}
ST
SDB
RepoInfo
*
tsdbGetStatus
(
tsdb_repo_t
*
pRepo
)
{
ST
sdb
RepoInfo
*
tsdbGetStatus
(
tsdb_repo_t
*
pRepo
)
{
// TODO
}
...
...
src/vnode/tsdb/src/tsdbMeta.c
浏览文件 @
3b940a6b
...
...
@@ -4,24 +4,34 @@
#include "tsdb.h"
#include "tsdbMeta.h"
#define TSDB_MIN_TABLES 10
#define TSDB_MAX_TABLES 100000
#define TSDB_DEFAULT_NSTABLES 10
#define IS_VALID_MAX_TABLES(maxTables) (((maxTables) >= TSDB_MIN_TABLES) && ((maxTables) >= TSDB_MAX_TABLES))
static
int
tsdbFreeTable
(
STable
*
pTable
);
STsdbMeta
*
tsdbCreateMeta
(
int32_t
maxTables
)
{
if
(
!
IS_VALID_MAX_TABLES
(
maxTables
))
return
NULL
;
STsdbMeta
*
pMeta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
pMeta
==
NULL
)
{
return
NULL
;
}
pMeta
->
numOfTables
=
0
;
pMeta
->
maxTables
=
maxTables
;
pMeta
->
numOfSuperTables
=
0
;
pMeta
->
pTables
=
calloc
(
sizeof
(
STable
*
),
maxTables
);
if
(
pMeta
->
pTables
==
NULL
)
{
pMeta
->
stables
=
NULL
;
pMeta
->
tables
=
(
STable
**
)
calloc
(
maxTables
,
sizeof
(
STable
*
));
if
(
pMeta
->
tables
==
NULL
)
{
free
(
pMeta
);
return
NULL
;
}
// TODO : initialize the map
// pMetahandle->pNameTableMap = ;
if
(
pMeta
->
pNameTableMap
==
NULL
)
{
free
(
pMeta
->
pTables
);
if
(
pMeta
->
tableMap
==
NULL
)
{
free
(
pMeta
->
tables
);
free
(
pMeta
);
return
NULL
;
}
...
...
@@ -30,11 +40,32 @@ STsdbMeta *tsdbCreateMeta(int32_t maxTables) {
}
int32_t
tsdbFreeMeta
(
STsdbMeta
*
pMeta
)
{
if
(
pMeta
==
NULL
)
return
0
;
for
(
int
i
=
0
;
i
<
pMeta
->
maxTables
;
i
++
)
{
if
(
pMeta
->
tables
[
i
]
!=
NULL
)
{
tsdbFreeTable
(
pMeta
->
tables
[
i
]);
}
}
free
(
pMeta
->
tables
);
STable
*
pTable
=
pMeta
->
stables
;
while
(
pTable
!=
NULL
)
{
STable
*
pTemp
=
pTable
;
pTable
=
pTemp
->
next
;
tsdbFreeTable
(
pTemp
);
}
// TODO close the map
free
(
pMeta
);
return
0
;
}
static
int32_t
tsdbCheckTableCfg
(
STableCfg
*
pCfg
)
{
return
0
;
}
int32_t
tsdbCreateTableImpl
(
STsdbMeta
*
p
Handle
,
STableCfg
*
pCfg
)
{
int32_t
tsdbCreateTableImpl
(
STsdbMeta
*
p
Meta
,
STableCfg
*
pCfg
)
{
if
(
tsdbCheckTableCfg
(
pCfg
)
<
0
)
{
return
-
1
;
}
...
...
@@ -45,19 +76,21 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pHandle, STableCfg *pCfg) {
return
-
1
;
}
p
Handle
->
pT
ables
[
pCfg
->
tableId
.
tid
]
=
pTable
;
p
Meta
->
t
ables
[
pCfg
->
tableId
.
tid
]
=
pTable
;
// TODO: add name to it
return
0
;
}
STsdbMeta
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
)
{
STsdbMeta
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
)
{
// Open meta file for reading
STsdbMeta
*
p
Handle
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
p
Handle
==
NULL
)
{
STsdbMeta
*
p
Meta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
p
Meta
==
NULL
)
{
return
NULL
;
}
return
p
Handle
;
return
p
Meta
;
}
static
int
tsdbFreeTable
(
STable
*
pTable
)
{
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录