Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cda6fa50
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cda6fa50
编写于
5月 18, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact: tdb
上级
bad77f8e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
40 deletion
+40
-40
source/libs/tdb/inc/tdb.h
source/libs/tdb/inc/tdb.h
+28
-28
source/libs/tdb/src/db/tdbDb.c
source/libs/tdb/src/db/tdbDb.c
+9
-9
source/libs/tdb/src/db/tdbTable.c
source/libs/tdb/src/db/tdbTable.c
+1
-1
source/libs/tdb/src/inc/tdbInt.h
source/libs/tdb/src/inc/tdbInt.h
+2
-2
未找到文件。
source/libs/tdb/inc/tdb.h
浏览文件 @
cda6fa50
...
...
@@ -22,7 +22,7 @@
extern
"C"
{
#endif
typedef
int
(
*
tdb_cmpr_fn_t
)(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
in
t
kLen2
);
typedef
int
(
*
tdb_cmpr_fn_t
)(
const
void
*
pKey1
,
int
32_t
kLen1
,
const
void
*
pKey2
,
int32_
t
kLen2
);
// exposed types
typedef
struct
STDB
TDB
;
...
...
@@ -31,42 +31,42 @@ typedef struct STBC TBC;
typedef
struct
STxn
TXN
;
// TDB
int
tdbOpen
(
const
char
*
dbname
,
int
szPage
,
int
pages
,
TDB
**
ppDb
);
int
tdbClose
(
TDB
*
pDb
);
int
tdbBegin
(
TDB
*
pDb
,
TXN
*
pTxn
);
int
tdbCommit
(
TDB
*
pDb
,
TXN
*
pTxn
);
int
32_t
tdbOpen
(
const
char
*
dbname
,
int
szPage
,
int
pages
,
TDB
**
ppDb
);
int
32_t
tdbClose
(
TDB
*
pDb
);
int
32_t
tdbBegin
(
TDB
*
pDb
,
TXN
*
pTxn
);
int
32_t
tdbCommit
(
TDB
*
pDb
,
TXN
*
pTxn
);
// TTB
int
tdbTbOpen
(
const
char
*
tbname
,
int
keyLen
,
int
valLen
,
tdb_cmpr_fn_t
keyCmprFn
,
TDB
*
pEnv
,
TTB
**
ppTb
);
int
tdbTbClose
(
TTB
*
pTb
);
int
tdbTbDrop
(
TTB
*
pTb
);
int
tdbTbInsert
(
TTB
*
pTb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
,
TXN
*
pTxn
);
int
tdbTbDelete
(
TTB
*
pTb
,
const
void
*
pKey
,
int
kLen
,
TXN
*
pTxn
);
int
tdbTbUpsert
(
TTB
*
pTb
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
,
TXN
*
pTxn
);
int
tdbTbGet
(
TTB
*
pTb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
tdbTbPGet
(
TTB
*
pTb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppKey
,
int
*
pkLen
,
void
**
ppVal
,
int
*
vLen
);
int
32_t
tdbTbOpen
(
const
char
*
tbname
,
int
keyLen
,
int
valLen
,
tdb_cmpr_fn_t
keyCmprFn
,
TDB
*
pEnv
,
TTB
**
ppTb
);
int
32_t
tdbTbClose
(
TTB
*
pTb
);
int
32_t
tdbTbDrop
(
TTB
*
pTb
);
int
32_t
tdbTbInsert
(
TTB
*
pTb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
,
TXN
*
pTxn
);
int
32_t
tdbTbDelete
(
TTB
*
pTb
,
const
void
*
pKey
,
int
kLen
,
TXN
*
pTxn
);
int
32_t
tdbTbUpsert
(
TTB
*
pTb
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
,
TXN
*
pTxn
);
int
32_t
tdbTbGet
(
TTB
*
pTb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
32_t
tdbTbPGet
(
TTB
*
pTb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppKey
,
int
*
pkLen
,
void
**
ppVal
,
int
*
vLen
);
// TBC
int
tdbTbcOpen
(
TTB
*
pTb
,
TBC
**
ppTbc
,
TXN
*
pTxn
);
int
tdbTbcClose
(
TBC
*
pTbc
);
int
tdbTbcIsValid
(
TBC
*
pTbc
);
int
tdbTbcMoveTo
(
TBC
*
pTbc
,
const
void
*
pKey
,
int
kLen
,
int
*
c
);
int
tdbTbcMoveToFirst
(
TBC
*
pTbc
);
int
tdbTbcMoveToLast
(
TBC
*
pTbc
);
int
tdbTbcMoveToNext
(
TBC
*
pTbc
);
int
tdbTbcMoveToPrev
(
TBC
*
pTbc
);
int
tdbTbcGet
(
TBC
*
pTbc
,
const
void
**
ppKey
,
int
*
pkLen
,
const
void
**
ppVal
,
int
*
pvLen
);
int
tdbTbcDelete
(
TBC
*
pTbc
);
int
tdbTbcNext
(
TBC
*
pTbc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
tdbTbcUpsert
(
TBC
*
pTbc
,
const
void
*
pKey
,
int
nKey
,
const
void
*
pData
,
int
nData
,
int
insert
);
int
32_t
tdbTbcOpen
(
TTB
*
pTb
,
TBC
**
ppTbc
,
TXN
*
pTxn
);
int
32_t
tdbTbcClose
(
TBC
*
pTbc
);
int
32_t
tdbTbcIsValid
(
TBC
*
pTbc
);
int
32_t
tdbTbcMoveTo
(
TBC
*
pTbc
,
const
void
*
pKey
,
int
kLen
,
int
*
c
);
int
32_t
tdbTbcMoveToFirst
(
TBC
*
pTbc
);
int
32_t
tdbTbcMoveToLast
(
TBC
*
pTbc
);
int
32_t
tdbTbcMoveToNext
(
TBC
*
pTbc
);
int
32_t
tdbTbcMoveToPrev
(
TBC
*
pTbc
);
int
32_t
tdbTbcGet
(
TBC
*
pTbc
,
const
void
**
ppKey
,
int
*
pkLen
,
const
void
**
ppVal
,
int
*
pvLen
);
int
32_t
tdbTbcDelete
(
TBC
*
pTbc
);
int
32_t
tdbTbcNext
(
TBC
*
pTbc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
32_t
tdbTbcUpsert
(
TBC
*
pTbc
,
const
void
*
pKey
,
int
nKey
,
const
void
*
pData
,
int
nData
,
int
insert
);
// TXN
#define TDB_TXN_WRITE 0x1
#define TDB_TXN_READ_UNCOMMITTED 0x2
int
tdbTxnOpen
(
TXN
*
pTxn
,
int64_t
txnid
,
void
*
(
*
xMalloc
)(
void
*
,
size_t
),
void
(
*
xFree
)(
void
*
,
void
*
),
void
*
xArg
,
int
flags
);
int
tdbTxnClose
(
TXN
*
pTxn
);
int
32_t
tdbTxnOpen
(
TXN
*
pTxn
,
int64_t
txnid
,
void
*
(
*
xMalloc
)(
void
*
,
size_t
),
void
(
*
xFree
)(
void
*
,
void
*
)
,
void
*
xArg
,
int
flags
);
int
32_t
tdbTxnClose
(
TXN
*
pTxn
);
// other
void
tdbFree
(
void
*
);
...
...
source/libs/tdb/src/db/tdbDb.c
浏览文件 @
cda6fa50
...
...
@@ -15,7 +15,7 @@
#include "tdbInt.h"
int
tdbOpen
(
const
char
*
dbname
,
int
szPage
,
in
t
pages
,
TDB
**
ppDb
)
{
int
32_t
tdbOpen
(
const
char
*
dbname
,
int32_t
szPage
,
int32_
t
pages
,
TDB
**
ppDb
)
{
TDB
*
pDb
;
int
dsize
;
int
zsize
;
...
...
@@ -36,16 +36,16 @@ int tdbOpen(const char *dbname, int szPage, int pages, TDB **ppDb) {
pDb
=
(
TDB
*
)
pPtr
;
pPtr
+=
sizeof
(
*
pDb
);
// pDb->rootDir
pDb
->
rootDir
=
pPtr
;
memcpy
(
pDb
->
rootDir
,
dbname
,
dsize
);
pDb
->
rootDir
[
dsize
]
=
'\0'
;
pDb
->
dbName
=
pPtr
;
memcpy
(
pDb
->
dbName
,
dbname
,
dsize
);
pDb
->
dbName
[
dsize
]
=
'\0'
;
pPtr
=
pPtr
+
dsize
+
1
;
// pDb->jfname
pDb
->
j
fn
ame
=
pPtr
;
memcpy
(
pDb
->
j
fn
ame
,
dbname
,
dsize
);
pDb
->
j
fn
ame
[
dsize
]
=
'/'
;
memcpy
(
pDb
->
j
fn
ame
+
dsize
+
1
,
TDB_JOURNAL_NAME
,
strlen
(
TDB_JOURNAL_NAME
));
pDb
->
j
fn
ame
[
dsize
+
1
+
strlen
(
TDB_JOURNAL_NAME
)]
=
'\0'
;
pDb
->
j
nN
ame
=
pPtr
;
memcpy
(
pDb
->
j
nN
ame
,
dbname
,
dsize
);
pDb
->
j
nN
ame
[
dsize
]
=
'/'
;
memcpy
(
pDb
->
j
nN
ame
+
dsize
+
1
,
TDB_JOURNAL_NAME
,
strlen
(
TDB_JOURNAL_NAME
));
pDb
->
j
nN
ame
[
dsize
+
1
+
strlen
(
TDB_JOURNAL_NAME
)]
=
'\0'
;
pDb
->
jfd
=
-
1
;
...
...
source/libs/tdb/src/db/tdbTable.c
浏览文件 @
cda6fa50
...
...
@@ -44,7 +44,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
pPager
=
tdbEnvGetPager
(
pEnv
,
tbname
);
if
(
pPager
==
NULL
)
{
snprintf
(
fFullName
,
TDB_FILENAME_LEN
,
"%s/%s"
,
pEnv
->
rootDir
,
tbname
);
snprintf
(
fFullName
,
TDB_FILENAME_LEN
,
"%s/%s"
,
pEnv
->
dbName
,
tbname
);
ret
=
tdbPagerOpen
(
pEnv
->
pCache
,
fFullName
,
&
pPager
);
if
(
ret
<
0
)
{
return
-
1
;
...
...
source/libs/tdb/src/inc/tdbInt.h
浏览文件 @
cda6fa50
...
...
@@ -335,8 +335,8 @@ static inline SCell *tdbPageGetCell(SPage *pPage, int idx) {
}
struct
STDB
{
char
*
rootDir
;
char
*
j
fn
ame
;
char
*
dbName
;
char
*
j
nN
ame
;
int
jfd
;
SPCache
*
pCache
;
SPager
*
pgrList
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录