Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
a4ee9d7c
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,发现更多精彩内容 >>
提交
a4ee9d7c
编写于
3月 02, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor
上级
9f0c0151
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
47 addition
and
53 deletion
+47
-53
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+1
-3
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
+28
-32
src/vnode/tsdb/src/tsdbMeta.c
src/vnode/tsdb/src/tsdbMeta.c
+16
-16
未找到文件。
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
a4ee9d7c
...
...
@@ -37,7 +37,6 @@ typedef struct {
// the TSDB repository configuration
typedef
struct
{
char
*
rootDir
;
// TSDB repository root directory, TODO: need to adjust here
int32_t
tsdbId
;
int32_t
maxTables
;
// maximum number of tables this repository can have
int32_t
daysPerFile
;
// day per file sharding policy
...
...
@@ -45,7 +44,6 @@ typedef struct {
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
void
*
cachePool
;
// the cache pool the repository to use
}
STsdbCfg
;
// the TSDB repository info
...
...
@@ -89,7 +87,7 @@ typedef struct {
*
* @return a TSDB repository handle on success, NULL for failure and the error number is set
*/
tsdb_repo_t
*
tsdbCreateRepo
(
STsdbCfg
*
pCfg
);
tsdb_repo_t
*
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
);
/**
* Close and free all resources taken by the repository
...
...
src/vnode/tsdb/inc/tsdbMeta.h
浏览文件 @
a4ee9d7c
...
...
@@ -62,7 +62,7 @@ typedef struct {
// A map of tableName->tableId
// TODO: May use hash table
void
*
pNameTableMap
;
}
S
MetaHandle
;
}
S
TsdbMeta
;
// ---- Operation on STable
#define TSDB_TABLE_ID(pTable) ((pTable)->tableId)
...
...
@@ -84,7 +84,7 @@ SSchema *tsdbGetTableSchema(STable *pTable);
#define TSDB_GET_TABLE_OF_NAME(pHandle, name)
/* TODO */
// Create a new meta handle with configuration
SMetaHandle
*
tsdbCreateMeta
Handle
(
int32_t
numOfTables
);
SMetaHandle
*
tsdbCreateMeta
(
int32_t
numOfTables
);
int32_t
tsdbFreeMetaHandle
(
SMetaHandle
*
pMetaHandle
);
// Recover the meta handle from the file
...
...
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
a4ee9d7c
#include <fcntl.h>
#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
// #include "taosdef.h"
// #include "disk.h"
#include "tsdbFile.h"
#include "tsdb.h"
#include "tsdbCache.h"
#include "tsdbFile.h"
#include "tsdbMeta.h"
enum
{
TSDB_REPO_STATE_ACTIVE
,
TSDB_REPO_STATE_CLOSED
,
TSDB_REPO_STATE_CONFIGURING
};
enum
{
TSDB_REPO_STATE_ACTIVE
,
TSDB_REPO_STATE_CLOSED
,
TSDB_REPO_STATE_CONFIGURING
};
typedef
struct
_tsdb_repo
{
// TSDB configuration
STsdbCfg
*
pCf
g
;
STsdbCfg
confi
g
;
// The meter meta handle of this TSDB repository
SMetaHandle
*
tsdbMeta
;
...
...
@@ -37,31 +33,40 @@ typedef struct _tsdb_repo {
pthread_mutex_t
tsdbMutex
;
// A limiter to monitor the resources used by tsdb
void
*
limiter
;
int8_t
state
;
}
STsdbRepo
;
static
int32_t
tsdbCheckAndSetDefaultCfg
(
STsdbCfg
*
pCfg
);
static
int32_t
tsdbCreateRepoFiles
(
STsdbRepo
*
pRepo
);
#define TSDB_GET_TABLE_BY_ID(pRepo, sid) (((STSDBRepo *)pRepo)->pTableList)[sid]
#define TSDB_GET_TABLE_BY_NAME(pRepo, name)
#define TSDB_IS_REPO_ACTIVE(pRepo) ((pRepo)->state == TSDB_REPO_STATE_ACTIVE)
#define TSDB_IS_REPO_CLOSED(pRepo) ((pRepo)->state == TSDB_REPO_STATE_CLOSED)
tsdb_repo_t
*
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
)
{
if
(
rootDir
==
NULL
)
return
NULL
;
tsdb_repo_t
*
tsdbCreateRepo
(
STsdbCfg
*
pCfg
)
{
if
(
access
(
rootDir
,
F_OK
|
R_OK
|
W_OK
)
==
-
1
)
return
NULL
;
// Check the configuration
if
(
tsdbCheckCfg
(
pCfg
)
<
0
)
{
if
(
tsdbCheckAndSetDefaultCfg
(
pCfg
)
<
0
)
{
return
NULL
;
}
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
malloc
(
sizeof
(
STsdbRepo
));
if
(
pRepo
==
NULL
)
{
// TODO: deal with error
return
NULL
;
}
// TODO: Initailize pMetahandle
pRepo
->
tsdbMeta
=
tsdbCreateMetaHandle
(
pCfg
->
maxTables
);
pRepo
->
config
=
*
pCfg
;
pRepo
->
limiter
=
limiter
;
pRepo
->
tsdbMeta
=
tsdbCreateMeta
(
pCfg
->
maxTables
);
if
(
pRepo
->
tsdbMeta
==
NULL
)
{
// TODO: deal with error
free
(
pRepo
);
...
...
@@ -77,11 +82,8 @@ tsdb_repo_t *tsdbCreateRepo(STsdbCfg *pCfg) {
return
NULL
;
}
// Set configuration
pRepo
->
pCfg
=
pCfg
;
// Create the Meta data file and data directory
if
(
tsdbCreateFiles
(
pRepo
)
<
0
)
{
if
(
tsdbCreate
Repo
Files
(
pRepo
)
<
0
)
{
// Failed to create and save files
tsdbFreeMetaHandle
(
pRepo
->
tsdbCache
);
free
(
pRepo
);
...
...
@@ -110,8 +112,7 @@ int32_t tsdbDropRepo(tsdb_repo_t *repo) {
}
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
)
{
if
(
access
(
tsdbDir
,
F_OK
|
W_OK
|
R_OK
)
<
0
)
{
if
(
access
(
tsdbDir
,
F_OK
|
W_OK
|
R_OK
)
<
0
)
{
return
NULL
;
}
...
...
@@ -159,7 +160,7 @@ int32_t tsdbCloseRepo(tsdb_repo_t *repo) {
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
STsdbCfg
*
pCfg
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
pRepo
->
pCf
g
=
pCfg
;
pRepo
->
confi
g
=
pCfg
;
// TODO
return
0
;
}
...
...
@@ -185,18 +186,13 @@ int32_t tsdbInsertData(tsdb_repo_t *pRepo, STableId tid, char *pData, int32_t *e
// TODO
}
// Check the correctness of the TSDB configuration
static
int32_t
tsdbCheckCfg
(
STsdbCfg
*
pCfg
)
{
if
(
pCfg
->
rootDir
==
NULL
)
return
-
1
;
if
(
access
(
pCfg
->
rootDir
,
F_OK
|
R_OK
|
W_OK
)
==
-
1
)
{
return
-
1
;
}
// Check the configuration and set default options
static
int32_t
tsdbCheckAndSetDefaultCfg
(
STsdbCfg
*
pCfg
)
{
// TODO
return
0
;
}
static
int32_t
tsdbCreateFiles
(
STsdbRepo
*
pRepo
)
{
static
int32_t
tsdbCreate
Repo
Files
(
STsdbRepo
*
pRepo
)
{
// TODO
}
...
...
src/vnode/tsdb/src/tsdbMeta.c
浏览文件 @
a4ee9d7c
...
...
@@ -4,39 +4,39 @@
#include "tsdb.h"
#include "tsdbMeta.h"
S
MetaHandle
*
tsdbCreateMetaHandle
(
int32_t
n
umOfTables
)
{
S
MetaHandle
*
pMetahandle
=
(
SMetaHandle
*
)
malloc
(
sizeof
(
SMetaHandle
));
if
(
pMeta
handle
==
NULL
)
{
S
TsdbMeta
*
tsdbCreateMeta
(
int32_t
maxN
umOfTables
)
{
S
TsdbMeta
*
pMeta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
pMeta
==
NULL
)
{
return
NULL
;
}
pMeta
handle
->
numOfTables
=
0
;
pMeta
handle
->
numOfSuperTables
=
0
;
pMeta
handle
->
pTables
=
calloc
(
sizeof
(
STable
*
),
numOfTables
);
if
(
pMeta
handle
->
pTables
==
NULL
)
{
free
(
pMeta
handle
);
pMeta
->
numOfTables
=
0
;
pMeta
->
numOfSuperTables
=
0
;
pMeta
->
pTables
=
calloc
(
sizeof
(
STable
*
),
numOfTables
);
if
(
pMeta
->
pTables
==
NULL
)
{
free
(
pMeta
);
return
NULL
;
}
// TODO : initialize the map
// pMetahandle->pNameTableMap = ;
if
(
pMeta
handle
->
pNameTableMap
==
NULL
)
{
free
(
pMeta
handle
->
pTables
);
free
(
pMeta
handle
);
if
(
pMeta
->
pNameTableMap
==
NULL
)
{
free
(
pMeta
->
pTables
);
free
(
pMeta
);
return
NULL
;
}
return
pMeta
handle
;
return
pMeta
;
}
int32_t
tsdbFreeMetaHandle
(
S
MetaHandle
*
pMetaHandle
)
{
int32_t
tsdbFreeMetaHandle
(
S
TsdbMeta
*
pMetaHandle
)
{
// TODO
}
static
int32_t
tsdbCheckTableCfg
(
STableCfg
*
pCfg
)
{
return
0
;
}
int32_t
tsdbCreateTableImpl
(
S
MetaHandle
*
pHandle
,
STableCfg
*
pCfg
)
{
int32_t
tsdbCreateTableImpl
(
S
TsdbMeta
*
pHandle
,
STableCfg
*
pCfg
)
{
if
(
tsdbCheckTableCfg
(
pCfg
)
<
0
)
{
return
-
1
;
}
...
...
@@ -53,10 +53,10 @@ int32_t tsdbCreateTableImpl(SMetaHandle *pHandle, STableCfg *pCfg) {
return
0
;
}
S
MetaHandle
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
)
{
S
TsdbMeta
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
)
{
// Open meta file for reading
S
MetaHandle
*
pHandle
=
(
SMetaHandle
*
)
malloc
(
sizeof
(
SMetaHandle
));
S
TsdbMeta
*
pHandle
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
pHandle
==
NULL
)
{
return
NULL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录