Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
d022f5e8
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
提交
d022f5e8
编写于
3月 11, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor
上级
21009436
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
118 addition
and
80 deletion
+118
-80
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+12
-57
src/vnode/tsdb/inc/tsdbCache.h
src/vnode/tsdb/inc/tsdbCache.h
+1
-1
src/vnode/tsdb/inc/tsdbMeta.h
src/vnode/tsdb/inc/tsdbMeta.h
+1
-1
src/vnode/tsdb/src/tsdbCache.c
src/vnode/tsdb/src/tsdbCache.c
+1
-1
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+101
-18
src/vnode/tsdb/src/tsdbMeta.c
src/vnode/tsdb/src/tsdbMeta.c
+1
-1
src/vnode/tsdb/tests/tsdbTests.cpp
src/vnode/tsdb/tests/tsdbTests.cpp
+1
-1
未找到文件。
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
d022f5e8
...
@@ -30,9 +30,9 @@ extern "C" {
...
@@ -30,9 +30,9 @@ extern "C" {
#define TSDB_VERSION_MAJOR 1
#define TSDB_VERSION_MAJOR 1
#define TSDB_VERSION_MINOR 0
#define TSDB_VERSION_MINOR 0
typedef
void
tsdb_repo_t
;
// use void to hide implementation details from outside
// --------- TSDB REPOSITORY CONFIGURATION DEFINITION
// --------- TSDB REPOSITORY CONFIGURATION DEFINITION
enum
{
TSDB_PRECISION_MILLI
,
TSDB_PRECISION_MICRO
,
TSDB_PRECISION_NANO
};
typedef
struct
{
typedef
struct
{
int8_t
precision
;
int8_t
precision
;
int32_t
tsdbId
;
int32_t
tsdbId
;
...
@@ -49,7 +49,15 @@ STsdbCfg *tsdbCreateDefaultCfg();
...
@@ -49,7 +49,15 @@ STsdbCfg *tsdbCreateDefaultCfg();
void
tsdbFreeCfg
(
STsdbCfg
*
pCfg
);
void
tsdbFreeCfg
(
STsdbCfg
*
pCfg
);
// --------- TSDB REPOSITORY DEFINITION
// --------- TSDB REPOSITORY DEFINITION
typedef
void
tsdb_repo_t
;
// use void to hide implementation details from outside
tsdb_repo_t
*
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
);
int32_t
tsdbDropRepo
(
tsdb_repo_t
*
repo
);
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
);
int32_t
tsdbCloseRepo
(
tsdb_repo_t
*
repo
);
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
STsdbCfg
*
pCfg
);
// --------- TSDB TABLE DEFINITION
typedef
struct
{
typedef
struct
{
int64_t
uid
;
// the unique table ID
int64_t
uid
;
// the unique table ID
int32_t
tid
;
// the table ID in the repository.
int32_t
tid
;
// the table ID in the repository.
...
@@ -71,7 +79,6 @@ typedef struct {
...
@@ -71,7 +79,6 @@ typedef struct {
char
data
[];
char
data
[];
}
SSubmitBlock
;
}
SSubmitBlock
;
enum
{
TSDB_PRECISION_MILLI
,
TSDB_PRECISION_MICRO
,
TSDB_PRECISION_NANO
};
// the TSDB repository info
// the TSDB repository info
typedef
struct
STsdbRepoInfo
{
typedef
struct
STsdbRepoInfo
{
...
@@ -82,6 +89,8 @@ typedef struct STsdbRepoInfo {
...
@@ -82,6 +89,8 @@ typedef struct STsdbRepoInfo {
// TODO: Other informations to add
// TODO: Other informations to add
}
STsdbRepoInfo
;
}
STsdbRepoInfo
;
STsdbRepoInfo
*
tsdbGetStatus
(
tsdb_repo_t
*
pRepo
);
// the meter configuration
// the meter configuration
typedef
struct
{
typedef
struct
{
STableId
tableId
;
STableId
tableId
;
...
@@ -106,60 +115,6 @@ typedef struct {
...
@@ -106,60 +115,6 @@ typedef struct {
int64_t
tableTotalDiskSize
;
// In bytes
int64_t
tableTotalDiskSize
;
// In bytes
}
STableInfo
;
}
STableInfo
;
/**
* 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
*/
tsdb_repo_t
*
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
);
/**
* Close and free all resources taken by the repository
* @param repo the TSDB repository handle. The interface will free the handle too, so upper
* layer do NOT need to free the repo handle again.
*
* @return 0 for success, -1 for failure and the error number is set
*/
int32_t
tsdbDropRepo
(
tsdb_repo_t
*
repo
);
/**
* Open an existing TSDB storage repository
* @param tsdbDir the existing TSDB root directory
*
* @return a TSDB repository handle on success, NULL for failure and the error number is set
*/
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
);
/**
* Close a TSDB repository. Only free memory resources, and keep the files.
* @param repo the opened TSDB repository handle. The interface will free the handle too, so upper
* layer do NOT need to free the repo handle again.
*
* @return 0 for success, -1 for failure and the error number is set
*/
int32_t
tsdbCloseRepo
(
tsdb_repo_t
*
repo
);
/**
* Change the configuration of a repository
* @param pCfg the repository configuration, the upper layer should free the pointer
*
* @return 0 for success, -1 for failure and the error number is set
*/
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
STsdbCfg
*
pCfg
);
/**
* Get the TSDB repository information, including some statistics
* @param pRepo the TSDB repository handle
* @param error the error number to set when failure occurs
*
* @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
*/
STsdbRepoInfo
*
tsdbGetStatus
(
tsdb_repo_t
*
pRepo
);
// -- For table manipulation
// -- For table manipulation
/**
/**
...
...
src/vnode/tsdb/inc/tsdbCache.h
浏览文件 @
d022f5e8
...
@@ -53,7 +53,7 @@ typedef struct STSDBCache {
...
@@ -53,7 +53,7 @@ typedef struct STSDBCache {
#define TSDB_NEXT_CACHE_BLOCK(pBlock) ((pBlock)->next)
#define TSDB_NEXT_CACHE_BLOCK(pBlock) ((pBlock)->next)
#define TSDB_PREV_CACHE_BLOCK(pBlock) ((pBlock)->prev)
#define TSDB_PREV_CACHE_BLOCK(pBlock) ((pBlock)->prev)
STsdbCache
*
tsdb
CreateCache
(
int32_t
numOfBlocks
);
STsdbCache
*
tsdb
InitCache
(
int64_t
maxSize
);
int32_t
tsdbFreeCache
(
STsdbCache
*
pCache
);
int32_t
tsdbFreeCache
(
STsdbCache
*
pCache
);
void
*
tsdbAllocFromCache
(
STsdbCache
*
pCache
,
int64_t
bytes
);
void
*
tsdbAllocFromCache
(
STsdbCache
*
pCache
,
int64_t
bytes
);
...
...
src/vnode/tsdb/inc/tsdbMeta.h
浏览文件 @
d022f5e8
...
@@ -106,7 +106,7 @@ STSchema *tsdbGetTableSchema(STable *pTable);
...
@@ -106,7 +106,7 @@ STSchema *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
*
tsdb
Create
Meta
(
int32_t
maxTables
);
STsdbMeta
*
tsdb
Init
Meta
(
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
...
...
src/vnode/tsdb/src/tsdbCache.c
浏览文件 @
d022f5e8
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#include "tsdbCache.h"
#include "tsdbCache.h"
STsdbCache
*
tsdb
CreateCache
(
int32_t
numOfBlocks
)
{
STsdbCache
*
tsdb
InitCache
(
int64_t
maxSize
)
{
STsdbCache
*
pCacheHandle
=
(
STsdbCache
*
)
malloc
(
sizeof
(
STsdbCache
));
STsdbCache
*
pCacheHandle
=
(
STsdbCache
*
)
malloc
(
sizeof
(
STsdbCache
));
if
(
pCacheHandle
==
NULL
)
{
if
(
pCacheHandle
==
NULL
)
{
// TODO : deal with the error
// TODO : deal with the error
...
...
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
d022f5e8
...
@@ -42,6 +42,9 @@
...
@@ -42,6 +42,9 @@
#define TSDB_MIN_CACHE_SIZE (4 * 1024 * 1024) // 4M
#define TSDB_MIN_CACHE_SIZE (4 * 1024 * 1024) // 4M
#define TSDB_MAX_CACHE_SIZE (1024 * 1024 * 1024) // 1G
#define TSDB_MAX_CACHE_SIZE (1024 * 1024 * 1024) // 1G
#define TSDB_CFG_FILE_NAME "CONFIG"
#define TSDB_DATA_DIR_NAME "data"
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
{
typedef
struct
_tsdb_repo
{
...
@@ -116,7 +119,15 @@ void tsdbFreeCfg(STsdbCfg *pCfg) {
...
@@ -116,7 +119,15 @@ void tsdbFreeCfg(STsdbCfg *pCfg) {
if
(
pCfg
!=
NULL
)
free
(
pCfg
);
if
(
pCfg
!=
NULL
)
free
(
pCfg
);
}
}
tsdb_repo_t
*
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
)
{
/**
* Create a new TSDB repository
* @param rootDir the TSDB repository root directory
* @param pCfg the TSDB repository configuration, upper layer need to free the pointer
* @param limiter the limitation tracker will implement in the future, make it void now
*
* @return a TSDB repository handle on success, NULL for failure
*/
tsdb_repo_t
*
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
/* TODO */
)
{
if
(
rootDir
==
NULL
)
return
NULL
;
if
(
rootDir
==
NULL
)
return
NULL
;
if
(
access
(
rootDir
,
F_OK
|
R_OK
|
W_OK
)
==
-
1
)
return
NULL
;
if
(
access
(
rootDir
,
F_OK
|
R_OK
|
W_OK
)
==
-
1
)
return
NULL
;
...
@@ -134,22 +145,26 @@ tsdb_repo_t *tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter) {
...
@@ -134,22 +145,26 @@ tsdb_repo_t *tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter) {
pRepo
->
config
=
*
pCfg
;
pRepo
->
config
=
*
pCfg
;
pRepo
->
limiter
=
limiter
;
pRepo
->
limiter
=
limiter
;
pRepo
->
tsdbMeta
=
tsdbCreateMeta
(
pCfg
->
maxTables
);
// Initialize meta
if
(
pRepo
->
tsdbMeta
==
NULL
)
{
STsdbMeta
*
pMeta
=
tsdbInitMeta
(
pCfg
->
maxTables
);
if
(
pMeta
==
NULL
)
{
free
(
pRepo
->
rootDir
);
free
(
pRepo
->
rootDir
);
free
(
pRepo
);
free
(
pRepo
);
return
NULL
;
return
NULL
;
}
}
pRepo
->
tsdbMeta
=
pMeta
;
pRepo
->
tsdbCache
=
tsdbCreateCache
(
5
);
// Initialize cache
if
(
pRepo
->
tsdbCache
==
NULL
)
{
STsdbCache
*
pCache
=
tsdbInitCache
(
pCfg
->
maxCacheSize
);
if
(
pCache
==
NULL
)
{
free
(
pRepo
->
rootDir
);
free
(
pRepo
->
rootDir
);
tsdbFreeMeta
(
pRepo
->
tsdbMeta
);
tsdbFreeMeta
(
pRepo
->
tsdbMeta
);
free
(
pRepo
);
free
(
pRepo
);
return
NULL
;
return
NULL
;
}
}
pRepo
->
tsdbCache
=
pCache
;
// Create the
Meta data file and data directory
// Create the
environment files and directories
if
(
tsdbSetRepoEnv
(
pRepo
)
<
0
)
{
if
(
tsdbSetRepoEnv
(
pRepo
)
<
0
)
{
free
(
pRepo
->
rootDir
);
free
(
pRepo
->
rootDir
);
tsdbFreeMeta
(
pRepo
->
tsdbMeta
);
tsdbFreeMeta
(
pRepo
->
tsdbMeta
);
...
@@ -163,6 +178,13 @@ tsdb_repo_t *tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter) {
...
@@ -163,6 +178,13 @@ tsdb_repo_t *tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter) {
return
(
tsdb_repo_t
*
)
pRepo
;
return
(
tsdb_repo_t
*
)
pRepo
;
}
}
/**
* Close and free all resources taken by the repository
* @param repo the TSDB repository handle. The interface will free the handle too, so upper
* layer do NOT need to free the repo handle again.
*
* @return 0 for success, -1 for failure and the error number is set
*/
int32_t
tsdbDropRepo
(
tsdb_repo_t
*
repo
)
{
int32_t
tsdbDropRepo
(
tsdb_repo_t
*
repo
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
...
@@ -183,6 +205,12 @@ int32_t tsdbDropRepo(tsdb_repo_t *repo) {
...
@@ -183,6 +205,12 @@ int32_t tsdbDropRepo(tsdb_repo_t *repo) {
return
0
;
return
0
;
}
}
/**
* Open an existing TSDB storage repository
* @param tsdbDir the existing TSDB root directory
*
* @return a TSDB repository handle on success, NULL for failure and the error number is set
*/
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
)
{
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
;
return
NULL
;
...
@@ -205,7 +233,7 @@ tsdb_repo_t *tsdbOpenRepo(char *tsdbDir) {
...
@@ -205,7 +233,7 @@ tsdb_repo_t *tsdbOpenRepo(char *tsdbDir) {
return
NULL
;
return
NULL
;
}
}
pRepo
->
tsdbCache
=
tsdb
Create
Cache
(
5
);
pRepo
->
tsdbCache
=
tsdb
Init
Cache
(
5
);
if
(
pRepo
->
tsdbCache
==
NULL
)
{
if
(
pRepo
->
tsdbCache
==
NULL
)
{
// TODO: deal with error
// TODO: deal with error
return
NULL
;
return
NULL
;
...
@@ -222,6 +250,13 @@ static int32_t tsdbFlushCache(STsdbRepo *pRepo) {
...
@@ -222,6 +250,13 @@ static int32_t tsdbFlushCache(STsdbRepo *pRepo) {
return
0
;
return
0
;
}
}
/**
* Close a TSDB repository. Only free memory resources, and keep the files.
* @param repo the opened TSDB repository handle. The interface will free the handle too, so upper
* layer do NOT need to free the repo handle again.
*
* @return 0 for success, -1 for failure and the error number is set
*/
int32_t
tsdbCloseRepo
(
tsdb_repo_t
*
repo
)
{
int32_t
tsdbCloseRepo
(
tsdb_repo_t
*
repo
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
if
(
pRepo
==
NULL
)
return
0
;
if
(
pRepo
==
NULL
)
return
0
;
...
@@ -237,6 +272,12 @@ int32_t tsdbCloseRepo(tsdb_repo_t *repo) {
...
@@ -237,6 +272,12 @@ int32_t tsdbCloseRepo(tsdb_repo_t *repo) {
return
0
;
return
0
;
}
}
/**
* Change the configuration of a repository
* @param pCfg the repository configuration, the upper layer should free the pointer
*
* @return 0 for success, -1 for failure and the error number is set
*/
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
STsdbCfg
*
pCfg
)
{
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
STsdbCfg
*
pCfg
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
...
@@ -245,6 +286,14 @@ int32_t tsdbConfigRepo(tsdb_repo_t *repo, STsdbCfg *pCfg) {
...
@@ -245,6 +286,14 @@ int32_t tsdbConfigRepo(tsdb_repo_t *repo, STsdbCfg *pCfg) {
return
0
;
return
0
;
}
}
/**
* Get the TSDB repository information, including some statistics
* @param pRepo the TSDB repository handle
* @param error the error number to set when failure occurs
*
* @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
*/
STsdbRepoInfo
*
tsdbGetStatus
(
tsdb_repo_t
*
pRepo
)
{
STsdbRepoInfo
*
tsdbGetStatus
(
tsdb_repo_t
*
pRepo
)
{
// TODO
// TODO
return
NULL
;
return
NULL
;
...
@@ -299,7 +348,7 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) {
...
@@ -299,7 +348,7 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) {
// Check tsdbId
// Check tsdbId
if
(
pCfg
->
tsdbId
<
0
)
return
-
1
;
if
(
pCfg
->
tsdbId
<
0
)
return
-
1
;
// Check
M
axTables
// Check
m
axTables
if
(
pCfg
->
maxTables
==
-
1
)
{
if
(
pCfg
->
maxTables
==
-
1
)
{
pCfg
->
maxTables
=
TSDB_DEFAULT_TABLES
;
pCfg
->
maxTables
=
TSDB_DEFAULT_TABLES
;
}
else
{
}
else
{
...
@@ -347,10 +396,18 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) {
...
@@ -347,10 +396,18 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) {
return
0
;
return
0
;
}
}
static
int32_t
tsdbSetRepoEnv
(
STsdbRepo
*
pRepo
)
{
static
int32_t
tsdbGetCfgFname
(
STsdbRepo
*
pRepo
,
char
*
fname
)
{
char
*
metaFname
=
tsdbGetFileName
(
pRepo
->
rootDir
,
"tsdb"
,
TSDB_FILE_TYPE_META
);
if
(
pRepo
==
NULL
)
return
-
1
;
sprintf
(
fname
,
"%s/%s"
,
pRepo
->
rootDir
,
TSDB_CFG_FILE_NAME
);
return
0
;
}
static
int32_t
tsdbSaveConfig
(
STsdbRepo
*
pRepo
)
{
char
fname
[
128
]
=
"
\0
"
;
// TODO: get rid of the literal 128
if
(
tsdbGetCfgFname
(
pRepo
,
fname
)
<
0
)
return
-
1
;
int
fd
=
open
(
metaFname
,
O_WRONLY
|
O_CREAT
);
int
fd
=
open
(
fname
,
O_WRONLY
|
O_CREAT
,
0755
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -359,19 +416,45 @@ static int32_t tsdbSetRepoEnv(STsdbRepo *pRepo) {
...
@@ -359,19 +416,45 @@ static int32_t tsdbSetRepoEnv(STsdbRepo *pRepo) {
return
-
1
;
return
-
1
;
}
}
// Create the data file
close
(
fd
);
char
*
dirName
=
calloc
(
1
,
strlen
(
pRepo
->
rootDir
)
+
strlen
(
"tsdb"
)
+
2
);
return
0
;
if
(
dirName
==
NULL
)
{
}
static
int32_t
tsdbRestoreCfg
(
STsdbRepo
*
pRepo
,
STsdbCfg
*
pCfg
)
{
char
fname
[
128
]
=
"
\0
"
;
if
(
tsdbGetCfgFname
(
pRepo
,
fname
)
<
0
)
return
-
1
;
int
fd
=
open
(
fname
,
O_RDONLY
);
if
(
fd
<
0
)
{
return
-
1
;
return
-
1
;
}
}
sprintf
(
dirName
,
"%s/%s"
,
pRepo
->
rootDir
,
"tsdb"
);
if
(
read
(
fd
,
(
void
*
)
pCfg
,
sizeof
(
STsdbCfg
))
<
sizeof
(
STsdbCfg
))
{
if
(
mkdir
(
dirName
,
0755
)
<
0
)
{
close
(
fd
);
free
(
dirName
);
return
-
1
;
return
-
1
;
}
}
free
(
dirName
);
close
(
fd
);
return
0
;
}
static
int32_t
tsdbGetDataDirName
(
STsdbRepo
*
pRepo
,
char
*
fname
)
{
if
(
pRepo
==
NULL
||
pRepo
->
rootDir
==
NULL
)
return
-
1
;
sprintf
(
fname
,
"%s/%s"
,
pRepo
->
rootDir
,
TSDB_DATA_DIR_NAME
);
return
0
;
}
static
int32_t
tsdbSetRepoEnv
(
STsdbRepo
*
pRepo
)
{
if
(
tsdbSaveConfig
(
pRepo
)
<
0
)
return
-
1
;
char
dirName
[
128
]
=
"
\0
"
;
if
(
tsdbGetDataDirName
(
pRepo
,
dirName
)
<
0
)
return
-
1
;
if
(
mkdir
(
dirName
,
0755
)
<
0
)
{
return
-
1
;
}
return
0
;
return
0
;
}
}
...
...
src/vnode/tsdb/src/tsdbMeta.c
浏览文件 @
d022f5e8
...
@@ -17,7 +17,7 @@ static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable);
...
@@ -17,7 +17,7 @@ static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable);
static
int
tsdbAddTableIntoIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbAddTableIntoIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbRemoveTableFromIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbRemoveTableFromIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
STsdbMeta
*
tsdb
Create
Meta
(
int32_t
maxTables
)
{
STsdbMeta
*
tsdb
Init
Meta
(
int32_t
maxTables
)
{
STsdbMeta
*
pMeta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
STsdbMeta
*
pMeta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
return
NULL
;
return
NULL
;
...
...
src/vnode/tsdb/tests/tsdbTests.cpp
浏览文件 @
d022f5e8
...
@@ -72,7 +72,7 @@ TEST(TsdbTest, createRepo) {
...
@@ -72,7 +72,7 @@ TEST(TsdbTest, createRepo) {
}
}
TEST
(
TsdbTest
,
DISABLED_createTable
)
{
TEST
(
TsdbTest
,
DISABLED_createTable
)
{
STsdbMeta
*
pMeta
=
tsdb
Create
Meta
(
100
);
STsdbMeta
*
pMeta
=
tsdb
Init
Meta
(
100
);
ASSERT_NE
(
pMeta
,
nullptr
);
ASSERT_NE
(
pMeta
,
nullptr
);
STableCfg
config
;
STableCfg
config
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录