Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2849a62c
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
2849a62c
编写于
2月 10, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more TDB
上级
a8bcf128
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
66 addition
and
9 deletion
+66
-9
source/dnode/vnode/src/meta/metaTDBImpl.c
source/dnode/vnode/src/meta/metaTDBImpl.c
+5
-0
source/libs/tdb/inc/tdb.h
source/libs/tdb/inc/tdb.h
+8
-0
source/libs/tdb/src/db/pgfile.c
source/libs/tdb/src/db/pgfile.c
+1
-1
source/libs/tdb/src/db/tdb.c
source/libs/tdb/src/db/tdb.c
+6
-1
source/libs/tdb/src/db/tdbEnv.c
source/libs/tdb/src/db/tdbEnv.c
+18
-0
source/libs/tdb/src/db/tdbUtil.c
source/libs/tdb/src/db/tdbUtil.c
+21
-2
source/libs/tdb/src/db/tdb_mpool.c
source/libs/tdb/src/db/tdb_mpool.c
+1
-1
source/libs/tdb/src/inc/tdbInt.h
source/libs/tdb/src/inc/tdbInt.h
+0
-3
source/libs/tdb/src/inc/tdbUtil.h
source/libs/tdb/src/inc/tdbUtil.h
+6
-1
未找到文件。
source/dnode/vnode/src/meta/metaTDBImpl.c
浏览文件 @
2849a62c
...
@@ -54,6 +54,11 @@ int metaOpenDB(SMeta *pMeta) {
...
@@ -54,6 +54,11 @@ int metaOpenDB(SMeta *pMeta) {
// Create and open the ENV
// Create and open the ENV
A
((
tdbEnvCreate
(
&
pEnv
)),
_err
);
A
((
tdbEnvCreate
(
&
pEnv
)),
_err
);
#if 0
// Set options of the environment
A(tdbEnvSetPageSize(pEnv, 8192), _err);
A(tdbEnvSetCacheSize(pEnv, 16 * 1024 * 1024), _err);
#endif
A
((
tdbEnvOpen
(
&
pEnv
)),
_err
);
A
((
tdbEnvOpen
(
&
pEnv
)),
_err
);
// Create and open each DB
// Create and open each DB
...
...
source/libs/tdb/inc/tdb.h
浏览文件 @
2849a62c
...
@@ -26,11 +26,19 @@ typedef struct STDb TDB;
...
@@ -26,11 +26,19 @@ typedef struct STDb TDB;
typedef
struct
STDbEnv
TENV
;
typedef
struct
STDbEnv
TENV
;
typedef
struct
STDbCurosr
TDBC
;
typedef
struct
STDbCurosr
TDBC
;
typedef
int32_t
pgsize_t
;
typedef
int32_t
cachesz_t
;
// TEVN
// TEVN
int
tdbEnvCreate
(
TENV
**
ppEnv
);
int
tdbEnvCreate
(
TENV
**
ppEnv
);
int
tdbEnvOpen
(
TENV
**
ppEnv
);
int
tdbEnvOpen
(
TENV
**
ppEnv
);
int
tdbEnvClose
(
TENV
*
pEnv
);
int
tdbEnvClose
(
TENV
*
pEnv
);
int
tdbEnvSetPageSize
(
TENV
*
pEnv
,
pgsize_t
szPage
);
int
tdbEnvSetCacheSize
(
TENV
*
pEnv
,
cachesz_t
szCache
);
pgsize_t
tdbEnvGetPageSize
(
TENV
*
pEnv
);
cachesz_t
tdbEnvGetCacheSize
(
TENV
*
pEnv
);
// TDB
// TDB
int
tdbCreate
(
TDB
**
ppDb
);
int
tdbCreate
(
TDB
**
ppDb
);
int
tdbOpen
(
TDB
**
ppDb
,
const
char
*
fname
,
const
char
*
dbname
,
TENV
*
pEnv
);
int
tdbOpen
(
TDB
**
ppDb
,
const
char
*
fname
,
const
char
*
dbname
,
TENV
*
pEnv
);
...
...
source/libs/tdb/src/db/pgfile.c
浏览文件 @
2849a62c
...
@@ -44,7 +44,7 @@ int pgFileOpen(SPgFile **ppPgFile, const char *fname, SPgCache *pPgCache) {
...
@@ -44,7 +44,7 @@ int pgFileOpen(SPgFile **ppPgFile, const char *fname, SPgCache *pPgCache) {
return
-
1
;
return
-
1
;
}
}
if
(
tdbGnrtFileID
(
fname
,
pPgFile
->
fileid
)
<
0
)
{
if
(
tdbGnrtFileID
(
fname
,
pPgFile
->
fileid
,
false
)
<
0
)
{
pgFileClose
(
pPgFile
);
pgFileClose
(
pPgFile
);
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/tdb/src/db/tdb.c
浏览文件 @
2849a62c
...
@@ -70,7 +70,12 @@ int tdbOpen(TDB **ppDb, const char *fname, const char *dbname, TENV *pEnv) {
...
@@ -70,7 +70,12 @@ int tdbOpen(TDB **ppDb, const char *fname, const char *dbname, TENV *pEnv) {
ASSERT
(
fname
!=
NULL
);
ASSERT
(
fname
!=
NULL
);
// Check if file exists (TODO)
// Check if file exists
if
(
tdbCheckFileAccess
(
fname
,
TDB_F_OK
)
!=
0
)
{
if
(
1
)
{
// create the file
}
}
// Check if the SPgFile already opened
// Check if the SPgFile already opened
pPgFile
=
tdbEnvGetPageFile
(
pEnv
,
fileid
);
pPgFile
=
tdbEnvGetPageFile
(
pEnv
,
fileid
);
...
...
source/libs/tdb/src/db/tdbEnv.c
浏览文件 @
2849a62c
...
@@ -57,6 +57,8 @@ int tdbEnvOpen(TENV **ppEnv) {
...
@@ -57,6 +57,8 @@ int tdbEnvOpen(TENV **ppEnv) {
pEnv
=
*
ppEnv
;
pEnv
=
*
ppEnv
;
TERR_A
(
ret
,
pgCacheCreate
(
&
pPgCache
,
pEnv
->
pgSize
,
pEnv
->
cacheSize
/
pEnv
->
pgSize
),
_err
);
TERR_A
(
ret
,
pgCacheCreate
(
&
pPgCache
,
pEnv
->
pgSize
,
pEnv
->
cacheSize
/
pEnv
->
pgSize
),
_err
);
TERR_A
(
ret
,
pgCacheOpen
(
&
pPgCache
),
_err
);
pEnv
->
pPgCache
=
pPgCache
;
pEnv
->
pPgCache
=
pPgCache
;
return
0
;
return
0
;
...
@@ -72,6 +74,22 @@ int tdbEnvClose(TENV *pEnv) {
...
@@ -72,6 +74,22 @@ int tdbEnvClose(TENV *pEnv) {
return
0
;
return
0
;
}
}
int
tdbEnvSetPageSize
(
TENV
*
pEnv
,
pgsize_t
szPage
)
{
/* TODO */
pEnv
->
pgSize
=
szPage
;
return
0
;
}
int
tdbEnvSetCacheSize
(
TENV
*
pEnv
,
cachesz_t
szCache
)
{
/* TODO */
pEnv
->
cacheSize
=
szCache
;
return
0
;
}
pgsize_t
tdbEnvGetPageSize
(
TENV
*
pEnv
)
{
return
pEnv
->
pgSize
;
}
cachesz_t
tdbEnvGetCacheSize
(
TENV
*
pEnv
)
{
return
pEnv
->
cacheSize
;
}
SPgFile
*
tdbEnvGetPageFile
(
TENV
*
pEnv
,
const
uint8_t
fileid
[])
{
SPgFile
*
tdbEnvGetPageFile
(
TENV
*
pEnv
,
const
uint8_t
fileid
[])
{
// TODO
// TODO
return
NULL
;
return
NULL
;
...
...
source/libs/tdb/src/db/tdbUtil.c
浏览文件 @
2849a62c
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include "tdbInt.h"
#include "tdbInt.h"
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
)
{
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
,
bool
unique
)
{
struct
stat
statbuf
;
struct
stat
statbuf
;
if
(
stat
(
fname
,
&
statbuf
)
<
0
)
{
if
(
stat
(
fname
,
&
statbuf
)
<
0
)
{
...
@@ -26,8 +26,27 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid) {
...
@@ -26,8 +26,27 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid) {
((
uint64_t
*
)
fileid
)[
0
]
=
(
uint64_t
)
statbuf
.
st_ino
;
((
uint64_t
*
)
fileid
)[
0
]
=
(
uint64_t
)
statbuf
.
st_ino
;
((
uint64_t
*
)
fileid
)[
1
]
=
(
uint64_t
)
statbuf
.
st_dev
;
((
uint64_t
*
)
fileid
)[
1
]
=
(
uint64_t
)
statbuf
.
st_dev
;
if
(
unique
)
{
((
uint64_t
*
)
fileid
)[
2
]
=
rand
();
((
uint64_t
*
)
fileid
)[
2
]
=
rand
();
}
return
0
;
return
0
;
}
}
int
tdbCheckFileAccess
(
const
char
*
pathname
,
int
mode
)
{
int
flags
=
0
;
if
(
mode
&
TDB_F_OK
)
{
flags
|=
F_OK
;
}
if
(
mode
&
TDB_R_OK
)
{
flags
|=
R_OK
;
}
if
(
mode
&
TDB_W_OK
)
{
flags
|=
W_OK
;
}
return
access
(
pathname
,
flags
);
}
\ No newline at end of file
source/libs/tdb/src/db/tdb_mpool.c
浏览文件 @
2849a62c
...
@@ -119,7 +119,7 @@ int tdbMPoolFileOpen(TDB_MPFILE **mpfp, const char *fname, TDB_MPOOL *mp) {
...
@@ -119,7 +119,7 @@ int tdbMPoolFileOpen(TDB_MPFILE **mpfp, const char *fname, TDB_MPOOL *mp) {
goto
_err
;
goto
_err
;
}
}
if
(
tdbGnrtFileID
(
fname
,
mpf
->
fileid
)
<
0
)
{
if
(
tdbGnrtFileID
(
fname
,
mpf
->
fileid
,
false
)
<
0
)
{
goto
_err
;
goto
_err
;
}
}
...
...
source/libs/tdb/src/inc/tdbInt.h
浏览文件 @
2849a62c
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#ifndef _TD_TDB_INTERNAL_H_
#ifndef _TD_TDB_INTERNAL_H_
#define _TD_TDB_INTERNAL_H_
#define _TD_TDB_INTERNAL_H_
#include "os.h"
#include "tlist.h"
#include "tlist.h"
#include "tlockfree.h"
#include "tlockfree.h"
...
@@ -64,14 +63,12 @@ static FORCE_INLINE int tdbCmprPgId(const void *p1, const void *p2) {
...
@@ -64,14 +63,12 @@ static FORCE_INLINE int tdbCmprPgId(const void *p1, const void *p2) {
typedef
int32_t
frame_id_t
;
typedef
int32_t
frame_id_t
;
// pgsize_t
// pgsize_t
typedef
int32_t
pgsize_t
;
#define TDB_MIN_PGSIZE 512
#define TDB_MIN_PGSIZE 512
#define TDB_MAX_PGSIZE 16384
#define TDB_MAX_PGSIZE 16384
#define TDB_DEFAULT_PGSIZE 4096
#define TDB_DEFAULT_PGSIZE 4096
#define TDB_IS_PGSIZE_VLD(s) (((s) >= TDB_MIN_PGSIZE) && ((s) <= TDB_MAX_PGSIZE))
#define TDB_IS_PGSIZE_VLD(s) (((s) >= TDB_MIN_PGSIZE) && ((s) <= TDB_MAX_PGSIZE))
// cache
// cache
typedef
int32_t
cachesz_t
;
#define TDB_DEFAULT_CACHE_SIZE (256 * 1024) // 256K
#define TDB_DEFAULT_CACHE_SIZE (256 * 1024) // 256K
// tdb_log
// tdb_log
...
...
source/libs/tdb/src/inc/tdbUtil.h
浏览文件 @
2849a62c
...
@@ -22,7 +22,12 @@ extern "C" {
...
@@ -22,7 +22,12 @@ extern "C" {
#define TDB_ROUND8(x) (((x) + 7) & ~7)
#define TDB_ROUND8(x) (((x) + 7) & ~7)
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
);
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
,
bool
unique
);
#define TDB_F_OK 0x1
#define TDB_R_OK 0x2
#define TDB_W_OK 0x4
int
tdbCheckFileAccess
(
const
char
*
pathname
,
int
mode
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录