Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3b940a6b
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
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 {
...
@@ -29,7 +29,7 @@ typedef struct {
// Submit message for one table
// Submit message for one table
typedef
struct
{
typedef
struct
{
STableId
t
i
d
;
STableId
t
ableI
d
;
int32_t
sversion
;
// data schema version
int32_t
sversion
;
// data schema version
int32_t
numOfRows
;
// number of rows data
int32_t
numOfRows
;
// number of rows data
char
data
[];
char
data
[];
...
@@ -47,20 +47,20 @@ typedef struct {
...
@@ -47,20 +47,20 @@ typedef struct {
}
STsdbCfg
;
}
STsdbCfg
;
// the TSDB repository info
// the TSDB repository info
typedef
struct
ST
SDB
RepoInfo
{
typedef
struct
ST
sdb
RepoInfo
{
STsdbCfg
tsdbCfg
;
STsdbCfg
tsdbCfg
;
int64_t
version
;
// version of the repository
int64_t
version
;
// version of the repository
int64_t
tsdbTotalDataSize
;
// the original inserted data size
int64_t
tsdbTotalDataSize
;
// the original inserted data size
int64_t
tsdbTotalDiskSize
;
// the total disk size taken by this TSDB repository
int64_t
tsdbTotalDiskSize
;
// the total disk size taken by this TSDB repository
// TODO: Other informations to add
// TODO: Other informations to add
}
ST
SDB
RepoInfo
;
}
ST
sdb
RepoInfo
;
// the meter configuration
// the meter configuration
typedef
struct
{
typedef
struct
{
char
*
tableName
;
char
*
tableName
;
STableId
tableId
;
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.
// table exists in this TSDB.
int64_t
stableUid
;
int64_t
stableUid
;
...
@@ -83,6 +83,7 @@ typedef struct {
...
@@ -83,6 +83,7 @@ typedef struct {
/**
/**
* Create a new TSDB repository
* Create a new TSDB repository
* @param rootDir the TSDB repository root directory
* @param pCfg the TSDB repository configuration, upper layer to free the pointer
* @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
* @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);
...
@@ -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
* @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
* 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
// -- For table manipulation
...
...
src/vnode/tsdb/inc/tsdbMeta.h
浏览文件 @
3b940a6b
...
@@ -16,7 +16,7 @@ typedef enum {
...
@@ -16,7 +16,7 @@ typedef enum {
}
TSDB_TABLE_TYPE
;
}
TSDB_TABLE_TYPE
;
typedef
struct
STable
{
typedef
struct
STable
{
int32_t
tableId
;
int32_t
tableId
;
int64_t
uid
;
int64_t
uid
;
char
*
tableName
;
char
*
tableName
;
TSDB_TABLE_TYPE
type
;
TSDB_TABLE_TYPE
type
;
...
@@ -51,17 +51,16 @@ typedef struct STable {
...
@@ -51,17 +51,16 @@ typedef struct STable {
// A handle to deal with stream
// A handle to deal with stream
void
*
streamHandle
;
void
*
streamHandle
;
struct
STable
*
next
;
}
STable
;
}
STable
;
typedef
struct
{
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)
int32_t
numOfSuperTables
;
// Number of super tables (#TSDB_SUPER_TABLE)
// An array of tables (TSDB_NTABLE and TSDB_STABLE) in this TSDB repository
STable
**
tables
;
// array of normal tables
STable
**
pTables
;
STable
*
stables
;
// linked list of super tables
void
*
tableMap
;
// table map of name ==> table
// A map of tableName->tableId
// TODO: May use hash table
void
*
pNameTableMap
;
}
STsdbMeta
;
}
STsdbMeta
;
// ---- Operation on STable
// ---- Operation on STable
...
@@ -84,10 +83,10 @@ SSchema *tsdbGetTableSchema(STable *pTable);
...
@@ -84,10 +83,10 @@ SSchema *tsdbGetTableSchema(STable *pTable);
#define TSDB_GET_TABLE_OF_NAME(pHandle, name)
/* TODO */
#define TSDB_GET_TABLE_OF_NAME(pHandle, name)
/* TODO */
// Create a new meta handle with configuration
// Create a new meta handle with configuration
STsdbMeta
*
tsdbCreateMeta
(
int32_t
maxTables
);
STsdbMeta
*
tsdbCreateMeta
(
int32_t
maxTables
);
int32_t
tsdbFreeMeta
(
STsdbMeta
*
pMeta
);
int32_t
tsdbFreeMeta
(
STsdbMeta
*
pMeta
);
// Recover the meta handle from the file
// Recover the meta handle from the file
STsdbMeta
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
);
STsdbMeta
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
);
int32_t
tsdbCreateTableImpl
(
STsdbMeta
*
pHandle
,
STableCfg
*
pCfg
);
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) {
...
@@ -175,7 +175,7 @@ int32_t tsdbConfigRepo(tsdb_repo_t *repo, STsdbCfg *pCfg) {
return
0
;
return
0
;
}
}
ST
SDB
RepoInfo
*
tsdbGetStatus
(
tsdb_repo_t
*
pRepo
)
{
ST
sdb
RepoInfo
*
tsdbGetStatus
(
tsdb_repo_t
*
pRepo
)
{
// TODO
// TODO
}
}
...
...
src/vnode/tsdb/src/tsdbMeta.c
浏览文件 @
3b940a6b
...
@@ -4,24 +4,34 @@
...
@@ -4,24 +4,34 @@
#include "tsdb.h"
#include "tsdb.h"
#include "tsdbMeta.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
)
{
STsdbMeta
*
tsdbCreateMeta
(
int32_t
maxTables
)
{
if
(
!
IS_VALID_MAX_TABLES
(
maxTables
))
return
NULL
;
STsdbMeta
*
pMeta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
STsdbMeta
*
pMeta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
pMeta
->
numOfTables
=
0
;
pMeta
->
maxTables
=
maxTables
;
pMeta
->
numOfSuperTables
=
0
;
pMeta
->
numOfSuperTables
=
0
;
pMeta
->
pTables
=
calloc
(
sizeof
(
STable
*
),
maxTables
);
pMeta
->
stables
=
NULL
;
if
(
pMeta
->
pTables
==
NULL
)
{
pMeta
->
tables
=
(
STable
**
)
calloc
(
maxTables
,
sizeof
(
STable
*
));
if
(
pMeta
->
tables
==
NULL
)
{
free
(
pMeta
);
free
(
pMeta
);
return
NULL
;
return
NULL
;
}
}
// TODO : initialize the map
// TODO : initialize the map
// pMetahandle->pNameTableMap = ;
if
(
pMeta
->
tableMap
==
NULL
)
{
if
(
pMeta
->
pNameTableMap
==
NULL
)
{
free
(
pMeta
->
tables
);
free
(
pMeta
->
pTables
);
free
(
pMeta
);
free
(
pMeta
);
return
NULL
;
return
NULL
;
}
}
...
@@ -30,11 +40,32 @@ STsdbMeta *tsdbCreateMeta(int32_t maxTables) {
...
@@ -30,11 +40,32 @@ STsdbMeta *tsdbCreateMeta(int32_t maxTables) {
}
}
int32_t
tsdbFreeMeta
(
STsdbMeta
*
pMeta
)
{
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
;
}
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
)
{
if
(
tsdbCheckTableCfg
(
pCfg
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -45,19 +76,21 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pHandle, STableCfg *pCfg) {
...
@@ -45,19 +76,21 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pHandle, STableCfg *pCfg) {
return
-
1
;
return
-
1
;
}
}
p
Handle
->
pT
ables
[
pCfg
->
tableId
.
tid
]
=
pTable
;
p
Meta
->
t
ables
[
pCfg
->
tableId
.
tid
]
=
pTable
;
// TODO: add name to it
// TODO: add name to it
return
0
;
return
0
;
}
}
STsdbMeta
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
)
{
STsdbMeta
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
)
{
// Open meta file for reading
// Open meta file for reading
STsdbMeta
*
p
Handle
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
STsdbMeta
*
p
Meta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
p
Handle
==
NULL
)
{
if
(
p
Meta
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
return
pHandle
;
return
pMeta
;
}
}
\ No newline at end of file
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录