Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fd6b2ad6
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看板
提交
fd6b2ad6
编写于
4月 28, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more refact
上级
8565e900
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
201 addition
and
74 deletion
+201
-74
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+6
-6
source/dnode/vnode/src/meta/metaTDBImpl.c
source/dnode/vnode/src/meta/metaTDBImpl.c
+2
-2
source/libs/tdb/inc/tdb.h
source/libs/tdb/inc/tdb.h
+15
-4
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+119
-2
source/libs/tdb/src/db/tdbDb.c
source/libs/tdb/src/db/tdbDb.c
+35
-9
source/libs/tdb/src/db/tdbEnv.c
source/libs/tdb/src/db/tdbEnv.c
+2
-2
source/libs/tdb/src/db/tdbPCache.c
source/libs/tdb/src/db/tdbPCache.c
+1
-1
source/libs/tdb/src/inc/tdbInt.h
source/libs/tdb/src/inc/tdbInt.h
+17
-44
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+4
-4
未找到文件。
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
fd6b2ad6
...
...
@@ -96,7 +96,7 @@ SMTbCursor *metaOpenTbCursor(SMeta *pMeta) {
metaReaderInit
(
&
pTbCur
->
mr
,
pMeta
,
0
);
tdbDbcOpen
(
pMeta
->
pUidIdx
,
&
pTbCur
->
pDbc
);
tdbDbcOpen
(
pMeta
->
pUidIdx
,
&
pTbCur
->
pDbc
,
NULL
);
return
pTbCur
;
}
...
...
@@ -119,7 +119,7 @@ int metaTbCursorNext(SMTbCursor *pTbCur) {
STbCfg
tbCfg
;
for
(;;)
{
ret
=
tdbDbNext
(
pTbCur
->
pDbc
,
&
pTbCur
->
pKey
,
&
pTbCur
->
kLen
,
&
pTbCur
->
pVal
,
&
pTbCur
->
vLen
);
ret
=
tdbDb
c
Next
(
pTbCur
->
pDbc
,
&
pTbCur
->
pKey
,
&
pTbCur
->
kLen
,
&
pTbCur
->
pVal
,
&
pTbCur
->
vLen
);
if
(
ret
<
0
)
{
return
-
1
;
}
...
...
@@ -193,7 +193,7 @@ SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) {
}
pCtbCur
->
suid
=
uid
;
ret
=
tdbDbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbCur
->
pCur
);
ret
=
tdbDbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbCur
->
pCur
,
NULL
);
if
(
ret
<
0
)
{
taosMemoryFree
(
pCtbCur
);
return
NULL
;
...
...
@@ -219,7 +219,7 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) {
int
ret
;
SCtbIdxKey
*
pCtbIdxKey
;
ret
=
tdbDbNext
(
pCtbCur
->
pCur
,
&
pCtbCur
->
pKey
,
&
pCtbCur
->
kLen
,
&
pCtbCur
->
pVal
,
&
pCtbCur
->
vLen
);
ret
=
tdbDb
c
Next
(
pCtbCur
->
pCur
,
&
pCtbCur
->
pKey
,
&
pCtbCur
->
kLen
,
&
pCtbCur
->
pVal
,
&
pCtbCur
->
vLen
);
if
(
ret
<
0
)
{
return
0
;
}
...
...
@@ -283,7 +283,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
while (true) {
// TODO: lock during iterate?
if (tdbDbNext(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
if (tdbDb
c
Next(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
pSmaIdxKey = pCur->pKey;
ASSERT(pSmaIdxKey != NULL);
...
...
@@ -354,7 +354,7 @@ SArray *metaGetSmaTbUids(SMeta *pMeta, bool isDup) {
tb_uid_t uid = 0;
while (true) {
// TODO: lock during iterate?
if (tdbDbNext(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
if (tdbDb
c
Next(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
ASSERT(pSmaIdxKey != NULL);
pSmaIdxKey = pCur->pKey;
...
...
source/dnode/vnode/src/meta/metaTDBImpl.c
浏览文件 @
fd6b2ad6
...
...
@@ -438,7 +438,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
while
(
true
)
{
// TODO: lock during iterate?
if
(
tdbDbNext
(
pCur
->
pCur
,
&
pCur
->
pKey
,
&
pCur
->
kLen
,
NULL
,
&
pCur
->
vLen
)
==
0
)
{
if
(
tdbDb
c
Next
(
pCur
->
pCur
,
&
pCur
->
pKey
,
&
pCur
->
kLen
,
NULL
,
&
pCur
->
vLen
)
==
0
)
{
pSmaIdxKey
=
pCur
->
pKey
;
ASSERT
(
pSmaIdxKey
!=
NULL
);
...
...
@@ -613,7 +613,7 @@ int64_t metaSmaCursorNext(SMSmaCursor *pCur) {
void
*
pBuf
;
SSmaIdxKey
*
smaIdxKey
;
ret
=
tdbDbNext
(
pCur
->
pCur
,
&
pCur
->
pKey
,
&
pCur
->
kLen
,
&
pCur
->
pVal
,
&
pCur
->
vLen
);
ret
=
tdbDb
c
Next
(
pCur
->
pCur
,
&
pCur
->
pKey
,
&
pCur
->
kLen
,
&
pCur
->
pVal
,
&
pCur
->
vLen
);
if
(
ret
<
0
)
{
return
0
;
}
...
...
source/libs/tdb/inc/tdb.h
浏览文件 @
fd6b2ad6
...
...
@@ -31,7 +31,7 @@ typedef struct STDBC TDBC;
typedef
struct
STxn
TXN
;
// TENV
int
tdbEnvOpen
(
const
char
*
rootDir
,
int
pageSize
,
int
cacheSize
,
TENV
**
ppEnv
);
int
tdbEnvOpen
(
const
char
*
rootDir
,
int
szPage
,
int
pages
,
TENV
**
ppEnv
);
int
tdbEnvClose
(
TENV
*
pEnv
);
int
tdbBegin
(
TENV
*
pEnv
,
TXN
*
pTxn
);
int
tdbCommit
(
TENV
*
pEnv
,
TXN
*
pTxn
);
...
...
@@ -45,10 +45,18 @@ int tdbDbGet(TDB *pDb, const void *pKey, int kLen, void **ppVal, int *vLen);
int
tdbDbPGet
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppKey
,
int
*
pkLen
,
void
**
ppVal
,
int
*
vLen
);
// TDBC
int
tdbDbcOpen
(
TDB
*
pDb
,
TDBC
**
ppDbc
);
int
tdbDbNext
(
TDBC
*
pDbc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
);
#define TDB_FLG_BACKWD 0x1 // backward search
#define TDB_FLG_CMP_LT 0x2 // less than
#define TDB_FLG_CMP_EQ 0x4 // equal
#define TDB_FLG_CMP_GT 0x8 // greater than
int
tdbDbcOpen
(
TDB
*
pDb
,
TDBC
**
ppDbc
,
TXN
*
pTxn
);
int
tdbDbcMoveTo
(
TDBC
*
pDbc
,
const
void
*
pKey
,
int
kLen
,
tdb_cmpr_fn_t
cmprFn
,
int
flags
);
int
tdbDbcPut
(
TDBC
*
pDbc
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
);
int
tdbDbcUpdate
(
TDBC
*
pDbc
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
);
int
tdbDbcDrop
(
TDBC
*
pDbc
);
int
tdbDbcNext
(
TDBC
*
pDbc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
tdbDbcClose
(
TDBC
*
pDbc
);
int
tdbDbcInsert
(
TDBC
*
pDbc
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
);
// TXN
#define TDB_TXN_WRITE 0x1
...
...
@@ -69,6 +77,9 @@ struct STxn {
void
*
xArg
;
};
// error code
enum
{
TDB_CODE_SUCCESS
=
0
,
TDB_CODE_MAX
};
#ifdef __cplusplus
}
#endif
...
...
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
fd6b2ad6
...
...
@@ -67,8 +67,8 @@ typedef struct {
u8
*
pBuf
;
}
SCellDecoder
;
static
int
tdbBtcMoveTo
(
SBTC
*
pBtc
,
const
void
*
pKey
,
int
kLen
,
int
*
pCRst
);
static
int
tdbDefaultKeyCmprFn
(
const
void
*
pKey1
,
int
keyLen1
,
const
void
*
pKey2
,
int
keyLen2
);
static
int
tdbBtcMoveTo
(
SBTC
*
pBtc
,
const
void
*
pKey
,
int
kLen
,
int
*
pCRst
);
static
int
tdbBtreeOpenImpl
(
SBTree
*
pBt
);
static
int
tdbBtreeInitPage
(
SPage
*
pPage
,
void
*
arg
,
int
init
);
static
int
tdbBtreeEncodeCell
(
SPage
*
pPage
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
,
SCell
*
pCell
,
...
...
@@ -1504,4 +1504,121 @@ void tdbBtPageInfo(SPage *pPage, int idx) {
pBtPageInfo
->
nOvfl
=
pPage
->
nOverflow
;
}
#endif
// TDB_BTREE_DEBUG
\ No newline at end of file
// TDB_BTREE_DEBUG
int
tdbBtcMoveTo2
(
SBTC
*
pBtc
,
const
void
*
pKey
,
int
kLen
,
tdb_cmpr_fn_t
cmprFn
,
int
flags
)
{
SBTree
*
pBt
=
pBtc
->
pBt
;
SPager
*
pPager
=
pBt
->
pPager
;
SPgno
root
=
pBt
->
root
;
SCellDecoder
cd
=
{
0
};
int
nCells
=
0
;
SCell
*
pCell
=
NULL
;
int
ret
=
0
;
int
c
;
int
backward
=
flags
&
TDB_FLG_BACKWD
;
if
(
cmprFn
==
NULL
)
{
cmprFn
=
pBt
->
kcmpr
;
}
// move cursor to a level
if
(
pBtc
->
iPage
<
0
)
{
// move from clear cursor
ret
=
tdbPagerFetchPage
(
pPager
,
&
root
,
&
(
pBtc
->
pPage
),
tdbBtreeInitPage
,
&
((
SBtreeInitPageArg
){.
pBt
=
pBt
,
.
flags
=
TDB_BTREE_ROOT
|
TDB_BTREE_LEAF
}),
pBtc
->
pTxn
);
if
(
ret
<
0
)
{
// TODO
ASSERT
(
0
);
return
-
1
;
}
pBtc
->
iPage
=
0
;
pBtc
->
idx
=
-
1
;
// for empty tree, just return with an invalid position
if
(
TDB_PAGE_TOTAL_CELLS
(
pBtc
->
pPage
)
==
0
)
return
0
;
}
else
{
// move from a position (TODO)
}
// search downward
for
(;;)
{
int
lidx
,
ridx
,
midx
;
SPage
*
pPage
;
pPage
=
pBtc
->
pPage
;
nCells
=
TDB_PAGE_TOTAL_CELLS
(
pPage
);
lidx
=
0
;
ridx
=
nCells
-
1
;
ASSERT
(
nCells
>
0
);
ASSERT
(
pBtc
->
idx
==
-
1
);
// compare first cell
midx
=
lidx
;
pCell
=
tdbPageGetCell
(
pPage
,
midx
);
tdbBtreeDecodeCell
(
pPage
,
pCell
,
&
cd
);
c
=
cmprFn
(
pKey
,
kLen
,
cd
.
pKey
,
cd
.
kLen
);
if
(
c
<=
0
)
{
ridx
=
lidx
-
1
;
}
else
{
lidx
=
lidx
+
1
;
}
// compare last cell
if
(
lidx
<=
ridx
)
{
midx
=
ridx
;
pCell
=
tdbPageGetCell
(
pPage
,
midx
);
tdbBtreeDecodeCell
(
pPage
,
pCell
,
&
cd
);
c
=
cmprFn
(
pKey
,
kLen
,
cd
.
pKey
,
cd
.
kLen
);
if
(
c
>=
0
)
{
lidx
=
ridx
+
1
;
}
else
{
ridx
=
ridx
-
1
;
}
}
// binary search
for
(;;)
{
if
(
lidx
>
ridx
)
break
;
midx
=
(
lidx
+
ridx
)
>>
1
;
pCell
=
tdbPageGetCell
(
pPage
,
midx
);
ret
=
tdbBtreeDecodeCell
(
pPage
,
pCell
,
&
cd
);
if
(
ret
<
0
)
{
// TODO: handle error
ASSERT
(
0
);
return
-
1
;
}
// Compare the key values
c
=
cmprFn
(
pKey
,
kLen
,
cd
.
pKey
,
cd
.
kLen
);
if
(
c
<
0
)
{
// pKey < cd.pKey
ridx
=
midx
-
1
;
}
else
if
(
c
>
0
)
{
// pKey > cd.pKey
lidx
=
midx
+
1
;
}
else
{
// pKey == cd.pKey
break
;
}
}
// keep search downward or break
if
(
TDB_BTREE_PAGE_IS_LEAF
(
pPage
))
{
pBtc
->
idx
=
midx
;
// *pCRst = c;
break
;
}
else
{
if
(
c
<=
0
)
{
pBtc
->
idx
=
midx
;
}
else
{
pBtc
->
idx
=
midx
+
1
;
}
tdbBtcMoveDownward
(
pBtc
);
}
}
return
0
;
}
\ No newline at end of file
source/libs/tdb/src/db/tdbDb.c
浏览文件 @
fd6b2ad6
...
...
@@ -87,7 +87,7 @@ int tdbDbPGet(TDB *pDb, const void *pKey, int kLen, void **ppKey, int *pkLen, vo
return
tdbBtreePGet
(
pDb
->
pBt
,
pKey
,
kLen
,
ppKey
,
pkLen
,
ppVal
,
vLen
);
}
int
tdbDbcOpen
(
TDB
*
pDb
,
TDBC
**
ppDbc
)
{
int
tdbDbcOpen
(
TDB
*
pDb
,
TDBC
**
ppDbc
,
TXN
*
pTxn
)
{
int
ret
;
TDBC
*
pDbc
=
NULL
;
...
...
@@ -97,7 +97,7 @@ int tdbDbcOpen(TDB *pDb, TDBC **ppDbc) {
return
-
1
;
}
tdbBtcOpen
(
&
pDbc
->
btc
,
pDb
->
pBt
,
NULL
);
tdbBtcOpen
(
&
pDbc
->
btc
,
pDb
->
pBt
,
pTxn
);
// TODO: move to first now, we can move to any key-value
// and in any direction, design new APIs.
...
...
@@ -111,7 +111,39 @@ int tdbDbcOpen(TDB *pDb, TDBC **ppDbc) {
return
0
;
}
int
tdbDbNext
(
TDBC
*
pDbc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
)
{
int
tdbDbcMoveTo
(
TDBC
*
pDbc
,
const
void
*
pKey
,
int
kLen
,
tdb_cmpr_fn_t
cmprFn
,
int
flags
)
{
int
tflags
;
// set/check flags
if
(
flags
==
0
)
{
flags
|=
TDB_FLG_CMP_EQ
;
}
else
{
tflags
=
flags
&
(
TDB_FLG_CMP_LT
|
TDB_FLG_CMP_EQ
|
TDB_FLG_CMP_GT
);
if
(
tflags
!=
TDB_FLG_CMP_LT
&&
tflags
!=
TDB_FLG_CMP_EQ
&&
tflags
!=
TDB_FLG_CMP_GT
)
return
-
1
;
}
return
tdbBtcMoveTo2
(
&
pDbc
->
btc
,
pKey
,
kLen
,
cmprFn
,
flags
);
}
int
tdbDbcPut
(
TDBC
*
pDbc
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
)
{
// TODO
ASSERT
(
0
);
return
0
;
}
int
tdbDbcUpdate
(
TDBC
*
pDbc
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
)
{
// TODO
ASSERT
(
0
);
return
0
;
}
int
tdbDbcDrop
(
TDBC
*
pDbc
)
{
// TODO
ASSERT
(
0
);
return
0
;
}
int
tdbDbcNext
(
TDBC
*
pDbc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
)
{
return
tdbBtreeNext
(
&
pDbc
->
btc
,
ppKey
,
kLen
,
ppVal
,
vLen
);
}
...
...
@@ -122,9 +154,3 @@ int tdbDbcClose(TDBC *pDbc) {
return
0
;
}
int
tdbDbcInsert
(
TDBC
*
pDbc
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
)
{
// TODO
ASSERT
(
0
);
return
0
;
}
\ No newline at end of file
source/libs/tdb/src/db/tdbEnv.c
浏览文件 @
fd6b2ad6
...
...
@@ -15,7 +15,7 @@
#include "tdbInt.h"
int
tdbEnvOpen
(
const
char
*
rootDir
,
int
pageSize
,
int
cacheSize
,
TENV
**
ppEnv
)
{
int
tdbEnvOpen
(
const
char
*
rootDir
,
int
szPage
,
int
pages
,
TENV
**
ppEnv
)
{
TENV
*
pEnv
;
int
dsize
;
int
zsize
;
...
...
@@ -49,7 +49,7 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, TENV **ppEnv) {
pEnv
->
jfd
=
-
1
;
ret
=
tdbPCacheOpen
(
pageSize
,
cacheSize
,
&
(
pEnv
->
pCache
));
ret
=
tdbPCacheOpen
(
szPage
,
pages
,
&
(
pEnv
->
pCache
));
if
(
ret
<
0
)
{
return
-
1
;
}
...
...
source/libs/tdb/src/db/tdbPCache.c
浏览文件 @
fd6b2ad6
...
...
@@ -135,7 +135,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn)
// 1. Search the hash table
pPage
=
pCache
->
pgHash
[
tdbPCachePageHash
(
pPgid
)
%
pCache
->
nHash
];
while
(
pPage
)
{
if
(
TDB_IS_SAME_PAGE
(
&
(
pPage
->
pgid
),
pPgid
)
)
break
;
if
(
memcmp
(
pPage
->
pgid
.
fileid
,
pPgid
->
fileid
,
TDB_FILE_ID_LEN
)
==
0
&&
pPage
->
pgid
.
pgno
==
pPgid
->
pgno
)
break
;
pPage
=
pPage
->
pHashNext
;
}
...
...
source/libs/tdb/src/inc/tdbInt.h
浏览文件 @
fd6b2ad6
...
...
@@ -33,7 +33,6 @@ typedef uint64_t u64;
// SPgno
typedef
u32
SPgno
;
#define TDB_IVLD_PGNO ((pgno_t)0)
#include "tdbOs.h"
#include "tdbUtil.h"
...
...
@@ -57,38 +56,12 @@ typedef struct {
SPgno
pgno
;
}
SPgid
;
#define TDB_IVLD_PGID (SPgid){0, TDB_IVLD_PGNO};
static
FORCE_INLINE
int
tdbCmprPgId
(
const
void
*
p1
,
const
void
*
p2
)
{
SPgid
*
pgid1
=
(
SPgid
*
)
p1
;
SPgid
*
pgid2
=
(
SPgid
*
)
p2
;
int
rcode
;
rcode
=
memcmp
(
pgid1
->
fileid
,
pgid2
->
fileid
,
TDB_FILE_ID_LEN
);
if
(
rcode
)
{
return
rcode
;
}
else
{
if
(
pgid1
->
pgno
>
pgid2
->
pgno
)
{
return
1
;
}
else
if
(
pgid1
->
pgno
<
pgid2
->
pgno
)
{
return
-
1
;
}
else
{
return
0
;
}
}
}
#define TDB_IS_SAME_PAGE(pPgid1, pPgid2) (tdbCmprPgId(pPgid1, pPgid2) == 0)
// pgsz_t
#define TDB_MIN_PGSIZE 512 // 512B
#define TDB_MAX_PGSIZE 16777216 // 16M
#define TDB_DEFAULT_PGSIZE 4096
#define TDB_IS_PGSIZE_VLD(s) (((s) >= TDB_MIN_PGSIZE) && ((s) <= TDB_MAX_PGSIZE))
// cache
#define TDB_DEFAULT_CACHE_SIZE (256 * 4096) // 1M
// dbname
#define TDB_MAX_DBNAME_LEN 24
...
...
@@ -98,8 +71,6 @@ static FORCE_INLINE int tdbCmprPgId(const void *p1, const void *p2) {
#define TDB_FILENAME_LEN 128
#define TDB_DEFAULT_FANOUT 6
#define BTREE_MAX_DEPTH 20
#define TDB_FLAG_IS(flags, flag) ((flags) == (flag))
...
...
@@ -152,27 +123,13 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
// SBTC
int
tdbBtcOpen
(
SBTC
*
pBtc
,
SBTree
*
pBt
,
TXN
*
pTxn
);
int
tdbBtcMoveTo2
(
SBTC
*
pBtc
,
const
void
*
pKey
,
int
kLen
,
tdb_cmpr_fn_t
cmprFn
,
int
flags
);
int
tdbBtcMoveToFirst
(
SBTC
*
pBtc
);
int
tdbBtcMoveToLast
(
SBTC
*
pBtc
);
int
tdbBtreeNext
(
SBTC
*
pBtc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
tdbBtcClose
(
SBTC
*
pBtc
);
// tdbPager.c ====================================
struct
SPager
{
char
*
dbFileName
;
char
*
jFileName
;
int
pageSize
;
uint8_t
fid
[
TDB_FILE_ID_LEN
];
tdb_fd_t
fd
;
tdb_fd_t
jfd
;
SPCache
*
pCache
;
SPgno
dbFileSize
;
SPgno
dbOrigSize
;
SPage
*
pDirty
;
u8
inTran
;
SPager
*
pNext
;
// used by TENV
SPager
*
pHashNext
;
// used by TENV
};
int
tdbPagerOpen
(
SPCache
*
pCache
,
const
char
*
fileName
,
SPager
**
ppPager
);
int
tdbPagerClose
(
SPager
*
pPager
);
...
...
@@ -346,6 +303,22 @@ struct STEnv {
SPager
**
pgrHash
;
};
struct
SPager
{
char
*
dbFileName
;
char
*
jFileName
;
int
pageSize
;
uint8_t
fid
[
TDB_FILE_ID_LEN
];
tdb_fd_t
fd
;
tdb_fd_t
jfd
;
SPCache
*
pCache
;
SPgno
dbFileSize
;
SPgno
dbOrigSize
;
SPage
*
pDirty
;
u8
inTran
;
SPager
*
pNext
;
// used by TENV
SPager
*
pHashNext
;
// used by TENV
};
#ifdef __cplusplus
}
#endif
...
...
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
fd6b2ad6
...
...
@@ -199,11 +199,11 @@ TEST(tdb_test, simple_test) {
int
vLen
,
kLen
;
int
count
=
0
;
ret
=
tdbDbcOpen
(
pDb
,
&
pDBC
);
ret
=
tdbDbcOpen
(
pDb
,
&
pDBC
,
NULL
);
GTEST_ASSERT_EQ
(
ret
,
0
);
for
(;;)
{
ret
=
tdbDbNext
(
pDBC
,
&
pKey
,
&
kLen
,
&
pVal
,
&
vLen
);
ret
=
tdbDb
c
Next
(
pDBC
,
&
pKey
,
&
kLen
,
&
pVal
,
&
vLen
);
if
(
ret
<
0
)
break
;
// std::cout.write((char *)pKey, kLen) /* << " " << kLen */ << " ";
...
...
@@ -280,11 +280,11 @@ TEST(tdb_test, simple_test2) {
int
vLen
,
kLen
;
int
count
=
0
;
ret
=
tdbDbcOpen
(
pDb
,
&
pDBC
);
ret
=
tdbDbcOpen
(
pDb
,
&
pDBC
,
NULL
);
GTEST_ASSERT_EQ
(
ret
,
0
);
for
(;;)
{
ret
=
tdbDbNext
(
pDBC
,
&
pKey
,
&
kLen
,
&
pVal
,
&
vLen
);
ret
=
tdbDb
c
Next
(
pDBC
,
&
pKey
,
&
kLen
,
&
pVal
,
&
vLen
);
if
(
ret
<
0
)
break
;
std
::
cout
.
write
((
char
*
)
pKey
,
kLen
)
/* << " " << kLen */
<<
" "
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录