Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d44f4137
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d44f4137
编写于
5月 18, 2022
作者:
H
Hongze Cheng
提交者:
GitHub
5月 18, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12635 from taosdata/feature/meta
refact: TDB
上级
62976d8b
f8b2bdec
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
95 addition
and
95 deletion
+95
-95
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+24
-24
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+7
-7
source/dnode/vnode/src/meta/metaSma.c
source/dnode/vnode/src/meta/metaSma.c
+4
-4
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+15
-15
source/dnode/vnode/src/sma/smaTDBImpl.c
source/dnode/vnode/src/sma/smaTDBImpl.c
+4
-4
source/dnode/vnode/src/tsdb/tsdbTDBImpl.c
source/dnode/vnode/src/tsdb/tsdbTDBImpl.c
+4
-4
source/libs/tdb/inc/tdb.h
source/libs/tdb/inc/tdb.h
+8
-8
source/libs/tdb/src/db/tdbDb.c
source/libs/tdb/src/db/tdbDb.c
+8
-8
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+21
-21
未找到文件。
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
d44f4137
...
...
@@ -57,56 +57,56 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
}
// open pTbDb
ret
=
tdb
Db
Open
(
"table.db"
,
sizeof
(
STbDbKey
),
-
1
,
tbDbKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTbDb
);
ret
=
tdbOpen
(
"table.db"
,
sizeof
(
STbDbKey
),
-
1
,
tbDbKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTbDb
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d failed to open meta table db since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pSkmDb
ret
=
tdb
Db
Open
(
"schema.db"
,
sizeof
(
SSkmDbKey
),
-
1
,
skmDbKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSkmDb
);
ret
=
tdbOpen
(
"schema.db"
,
sizeof
(
SSkmDbKey
),
-
1
,
skmDbKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSkmDb
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d failed to open meta schema db since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pUidIdx
ret
=
tdb
Db
Open
(
"uid.idx"
,
sizeof
(
tb_uid_t
),
sizeof
(
int64_t
),
uidIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pUidIdx
);
ret
=
tdbOpen
(
"uid.idx"
,
sizeof
(
tb_uid_t
),
sizeof
(
int64_t
),
uidIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pUidIdx
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d failed to open meta uid idx since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pNameIdx
ret
=
tdb
Db
Open
(
"name.idx"
,
-
1
,
sizeof
(
tb_uid_t
),
NULL
,
pMeta
->
pEnv
,
&
pMeta
->
pNameIdx
);
ret
=
tdbOpen
(
"name.idx"
,
-
1
,
sizeof
(
tb_uid_t
),
NULL
,
pMeta
->
pEnv
,
&
pMeta
->
pNameIdx
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d failed to open meta name index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pCtbIdx
ret
=
tdb
Db
Open
(
"ctb.idx"
,
sizeof
(
SCtbIdxKey
),
0
,
ctbIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pCtbIdx
);
ret
=
tdbOpen
(
"ctb.idx"
,
sizeof
(
SCtbIdxKey
),
0
,
ctbIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pCtbIdx
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d failed to open meta child table index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pTagIdx
ret
=
tdb
Db
Open
(
"tag.idx"
,
-
1
,
0
,
tagIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTagIdx
);
ret
=
tdbOpen
(
"tag.idx"
,
-
1
,
0
,
tagIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTagIdx
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d failed to open meta tag index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pTtlIdx
ret
=
tdb
Db
Open
(
"ttl.idx"
,
sizeof
(
STtlIdxKey
),
0
,
ttlIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTtlIdx
);
ret
=
tdbOpen
(
"ttl.idx"
,
sizeof
(
STtlIdxKey
),
0
,
ttlIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTtlIdx
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d failed to open meta ttl index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pSmaIdx
ret
=
tdb
Db
Open
(
"sma.idx"
,
sizeof
(
SSmaIdxKey
),
0
,
smaIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSmaIdx
);
ret
=
tdbOpen
(
"sma.idx"
,
sizeof
(
SSmaIdxKey
),
0
,
smaIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSmaIdx
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d failed to open meta sma index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
...
...
@@ -125,14 +125,14 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
_err:
if
(
pMeta
->
pIdx
)
metaCloseIdx
(
pMeta
);
if
(
pMeta
->
pSmaIdx
)
tdb
Db
Close
(
pMeta
->
pSmaIdx
);
if
(
pMeta
->
pTtlIdx
)
tdb
Db
Close
(
pMeta
->
pTtlIdx
);
if
(
pMeta
->
pTagIdx
)
tdb
Db
Close
(
pMeta
->
pTagIdx
);
if
(
pMeta
->
pCtbIdx
)
tdb
Db
Close
(
pMeta
->
pCtbIdx
);
if
(
pMeta
->
pNameIdx
)
tdb
Db
Close
(
pMeta
->
pNameIdx
);
if
(
pMeta
->
pUidIdx
)
tdb
Db
Close
(
pMeta
->
pUidIdx
);
if
(
pMeta
->
pSkmDb
)
tdb
Db
Close
(
pMeta
->
pSkmDb
);
if
(
pMeta
->
pTbDb
)
tdb
Db
Close
(
pMeta
->
pTbDb
);
if
(
pMeta
->
pSmaIdx
)
tdbClose
(
pMeta
->
pSmaIdx
);
if
(
pMeta
->
pTtlIdx
)
tdbClose
(
pMeta
->
pTtlIdx
);
if
(
pMeta
->
pTagIdx
)
tdbClose
(
pMeta
->
pTagIdx
);
if
(
pMeta
->
pCtbIdx
)
tdbClose
(
pMeta
->
pCtbIdx
);
if
(
pMeta
->
pNameIdx
)
tdbClose
(
pMeta
->
pNameIdx
);
if
(
pMeta
->
pUidIdx
)
tdbClose
(
pMeta
->
pUidIdx
);
if
(
pMeta
->
pSkmDb
)
tdbClose
(
pMeta
->
pSkmDb
);
if
(
pMeta
->
pTbDb
)
tdbClose
(
pMeta
->
pTbDb
);
if
(
pMeta
->
pEnv
)
tdbEnvClose
(
pMeta
->
pEnv
);
metaDestroyLock
(
pMeta
);
taosMemoryFree
(
pMeta
);
...
...
@@ -142,14 +142,14 @@ _err:
int
metaClose
(
SMeta
*
pMeta
)
{
if
(
pMeta
)
{
if
(
pMeta
->
pIdx
)
metaCloseIdx
(
pMeta
);
if
(
pMeta
->
pSmaIdx
)
tdb
Db
Close
(
pMeta
->
pSmaIdx
);
if
(
pMeta
->
pTtlIdx
)
tdb
Db
Close
(
pMeta
->
pTtlIdx
);
if
(
pMeta
->
pTagIdx
)
tdb
Db
Close
(
pMeta
->
pTagIdx
);
if
(
pMeta
->
pCtbIdx
)
tdb
Db
Close
(
pMeta
->
pCtbIdx
);
if
(
pMeta
->
pNameIdx
)
tdb
Db
Close
(
pMeta
->
pNameIdx
);
if
(
pMeta
->
pUidIdx
)
tdb
Db
Close
(
pMeta
->
pUidIdx
);
if
(
pMeta
->
pSkmDb
)
tdb
Db
Close
(
pMeta
->
pSkmDb
);
if
(
pMeta
->
pTbDb
)
tdb
Db
Close
(
pMeta
->
pTbDb
);
if
(
pMeta
->
pSmaIdx
)
tdbClose
(
pMeta
->
pSmaIdx
);
if
(
pMeta
->
pTtlIdx
)
tdbClose
(
pMeta
->
pTtlIdx
);
if
(
pMeta
->
pTagIdx
)
tdbClose
(
pMeta
->
pTagIdx
);
if
(
pMeta
->
pCtbIdx
)
tdbClose
(
pMeta
->
pCtbIdx
);
if
(
pMeta
->
pNameIdx
)
tdbClose
(
pMeta
->
pNameIdx
);
if
(
pMeta
->
pUidIdx
)
tdbClose
(
pMeta
->
pUidIdx
);
if
(
pMeta
->
pSkmDb
)
tdbClose
(
pMeta
->
pSkmDb
);
if
(
pMeta
->
pTbDb
)
tdbClose
(
pMeta
->
pTbDb
);
if
(
pMeta
->
pEnv
)
tdbEnvClose
(
pMeta
->
pEnv
);
metaDestroyLock
(
pMeta
);
taosMemoryFree
(
pMeta
);
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
d44f4137
...
...
@@ -35,7 +35,7 @@ int metaGetTableEntryByVersion(SMetaReader *pReader, int64_t version, tb_uid_t u
STbDbKey
tbDbKey
=
{.
version
=
version
,
.
uid
=
uid
};
// query table.db
if
(
tdb
Db
Get
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
if
(
tdbGet
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
terrno
=
TSDB_CODE_PAR_TABLE_NOT_EXIST
;
goto
_err
;
}
...
...
@@ -58,7 +58,7 @@ int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid) {
int64_t
version
;
// query uid.idx
if
(
tdb
Db
Get
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
if
(
tdbGet
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
terrno
=
TSDB_CODE_PAR_TABLE_NOT_EXIST
;
return
-
1
;
}
...
...
@@ -72,7 +72,7 @@ int metaGetTableEntryByName(SMetaReader *pReader, const char *name) {
tb_uid_t
uid
;
// query name.idx
if
(
tdb
Db
Get
(
pMeta
->
pNameIdx
,
name
,
strlen
(
name
)
+
1
,
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
if
(
tdbGet
(
pMeta
->
pNameIdx
,
name
,
strlen
(
name
)
+
1
,
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
terrno
=
TSDB_CODE_PAR_TABLE_NOT_EXIST
;
return
-
1
;
}
...
...
@@ -159,7 +159,7 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
pKey
=
&
skmDbKey
;
kLen
=
sizeof
(
skmDbKey
);
metaRLock
(
pMeta
);
ret
=
tdb
Db
Get
(
pMeta
->
pSkmDb
,
pKey
,
kLen
,
&
pVal
,
&
vLen
);
ret
=
tdbGet
(
pMeta
->
pSkmDb
,
pKey
,
kLen
,
&
pVal
,
&
vLen
);
metaULock
(
pMeta
);
if
(
ret
<
0
)
{
return
NULL
;
...
...
@@ -413,7 +413,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid, bool deepCopy) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
memcpy
((
void
*
)
pTSma
->
expr
,
mr
.
me
.
smaEntry
.
tsma
->
expr
,
pTSma
->
exprLen
);
memcpy
((
void
*
)
pTSma
->
expr
,
mr
.
me
.
smaEntry
.
tsma
->
expr
,
pTSma
->
exprLen
);
}
if
(
pTSma
->
tagsFilterLen
>
0
)
{
if
(
!
(
pTSma
->
tagsFilter
=
taosMemoryCalloc
(
1
,
pTSma
->
tagsFilterLen
)))
{
...
...
@@ -421,7 +421,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid, bool deepCopy) {
goto
_err
;
}
}
memcpy
((
void
*
)
pTSma
->
tagsFilter
,
mr
.
me
.
smaEntry
.
tsma
->
tagsFilter
,
pTSma
->
tagsFilterLen
);
memcpy
((
void
*
)
pTSma
->
tagsFilter
,
mr
.
me
.
smaEntry
.
tsma
->
tagsFilter
,
pTSma
->
tagsFilterLen
);
}
else
{
pTSma
->
exprLen
=
0
;
pTSma
->
expr
=
NULL
;
...
...
source/dnode/vnode/src/meta/metaSma.c
浏览文件 @
d44f4137
...
...
@@ -117,7 +117,7 @@ static int metaSaveSmaToDB(SMeta *pMeta, const SMetaEntry *pME) {
tEncoderClear
(
&
coder
);
// write to table.db
if
(
tdb
Db
Insert
(
pMeta
->
pTbDb
,
pKey
,
kLen
,
pVal
,
vLen
,
&
pMeta
->
txn
)
<
0
)
{
if
(
tdbInsert
(
pMeta
->
pTbDb
,
pKey
,
kLen
,
pVal
,
vLen
,
&
pMeta
->
txn
)
<
0
)
{
goto
_err
;
}
...
...
@@ -130,17 +130,17 @@ _err:
}
static
int
metaUpdateUidIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdb
Db
Insert
(
pMeta
->
pUidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pME
->
version
,
sizeof
(
int64_t
),
&
pMeta
->
txn
);
return
tdbInsert
(
pMeta
->
pUidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pME
->
version
,
sizeof
(
int64_t
),
&
pMeta
->
txn
);
}
static
int
metaUpdateNameIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdb
Db
Insert
(
pMeta
->
pNameIdx
,
pME
->
name
,
strlen
(
pME
->
name
)
+
1
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pMeta
->
txn
);
return
tdbInsert
(
pMeta
->
pNameIdx
,
pME
->
name
,
strlen
(
pME
->
name
)
+
1
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pMeta
->
txn
);
}
static
int
metaUpdateSmaIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SSmaIdxKey
smaIdxKey
=
{.
uid
=
pME
->
smaEntry
.
tsma
->
tableUid
,
.
smaUid
=
pME
->
smaEntry
.
tsma
->
indexUid
};
return
tdb
Db
Insert
(
pMeta
->
pSmaIdx
,
&
smaIdxKey
,
sizeof
(
smaIdxKey
),
NULL
,
0
,
&
pMeta
->
txn
);
return
tdbInsert
(
pMeta
->
pSmaIdx
,
&
smaIdxKey
,
sizeof
(
smaIdxKey
),
NULL
,
0
,
&
pMeta
->
txn
);
}
static
int
metaHandleSmaEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
d44f4137
...
...
@@ -389,7 +389,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
int
c
;
// search name index
ret
=
tdb
Db
Get
(
pMeta
->
pNameIdx
,
pAlterTbReq
->
tbName
,
strlen
(
pAlterTbReq
->
tbName
)
+
1
,
&
pVal
,
&
nVal
);
ret
=
tdbGet
(
pMeta
->
pNameIdx
,
pAlterTbReq
->
tbName
,
strlen
(
pAlterTbReq
->
tbName
)
+
1
,
&
pVal
,
&
nVal
);
if
(
ret
<
0
)
{
terrno
=
TSDB_CODE_VND_TABLE_NOT_EXIST
;
return
-
1
;
...
...
@@ -536,7 +536,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
int
nData
=
0
;
// search name index
ret
=
tdb
Db
Get
(
pMeta
->
pNameIdx
,
pAlterTbReq
->
tbName
,
strlen
(
pAlterTbReq
->
tbName
)
+
1
,
&
pVal
,
&
nVal
);
ret
=
tdbGet
(
pMeta
->
pNameIdx
,
pAlterTbReq
->
tbName
,
strlen
(
pAlterTbReq
->
tbName
)
+
1
,
&
pVal
,
&
nVal
);
if
(
ret
<
0
)
{
terrno
=
TSDB_CODE_VND_TABLE_NOT_EXIST
;
return
-
1
;
...
...
@@ -573,8 +573,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
tDecoderClear
(
&
dc
);
/* get stbEntry*/
tdb
Db
Get
(
pMeta
->
pUidIdx
,
&
ctbEntry
.
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pVal
,
&
nVal
);
tdb
Db
Get
(
pMeta
->
pTbDb
,
&
((
STbDbKey
){.
uid
=
ctbEntry
.
ctbEntry
.
suid
,
.
version
=
*
(
int64_t
*
)
pVal
}),
sizeof
(
STbDbKey
),
tdbGet
(
pMeta
->
pUidIdx
,
&
ctbEntry
.
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pVal
,
&
nVal
);
tdbGet
(
pMeta
->
pTbDb
,
&
((
STbDbKey
){.
uid
=
ctbEntry
.
ctbEntry
.
suid
,
.
version
=
*
(
int64_t
*
)
pVal
}),
sizeof
(
STbDbKey
),
(
void
**
)
&
stbEntry
.
pBuf
,
&
nVal
);
tdbFree
(
pVal
);
tDecoderInit
(
&
dc
,
stbEntry
.
pBuf
,
nVal
);
...
...
@@ -632,7 +632,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
metaSaveToTbDb
(
pMeta
,
&
ctbEntry
);
// save to uid.idx
tdb
Db
Upsert
(
pMeta
->
pUidIdx
,
&
ctbEntry
.
uid
,
sizeof
(
tb_uid_t
),
&
version
,
sizeof
(
version
),
&
pMeta
->
txn
);
tdbUpsert
(
pMeta
->
pUidIdx
,
&
ctbEntry
.
uid
,
sizeof
(
tb_uid_t
),
&
version
,
sizeof
(
version
),
&
pMeta
->
txn
);
if
(
ctbEntry
.
pBuf
)
taosMemoryFree
(
ctbEntry
.
pBuf
);
if
(
stbEntry
.
pBuf
)
tdbFree
(
stbEntry
.
pBuf
);
...
...
@@ -708,7 +708,7 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) {
tEncoderClear
(
&
coder
);
// write to table.db
if
(
tdb
Db
Insert
(
pMeta
->
pTbDb
,
pKey
,
kLen
,
pVal
,
vLen
,
&
pMeta
->
txn
)
<
0
)
{
if
(
tdbInsert
(
pMeta
->
pTbDb
,
pKey
,
kLen
,
pVal
,
vLen
,
&
pMeta
->
txn
)
<
0
)
{
goto
_err
;
}
...
...
@@ -721,11 +721,11 @@ _err:
}
static
int
metaUpdateUidIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdb
Db
Insert
(
pMeta
->
pUidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pME
->
version
,
sizeof
(
int64_t
),
&
pMeta
->
txn
);
return
tdbInsert
(
pMeta
->
pUidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pME
->
version
,
sizeof
(
int64_t
),
&
pMeta
->
txn
);
}
static
int
metaUpdateNameIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdb
Db
Insert
(
pMeta
->
pNameIdx
,
pME
->
name
,
strlen
(
pME
->
name
)
+
1
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pMeta
->
txn
);
return
tdbInsert
(
pMeta
->
pNameIdx
,
pME
->
name
,
strlen
(
pME
->
name
)
+
1
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pMeta
->
txn
);
}
static
int
metaUpdateTtlIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
...
...
@@ -748,12 +748,12 @@ static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
ttlKey
.
dtime
=
ctime
+
ttlDays
*
24
*
60
*
60
;
ttlKey
.
uid
=
pME
->
uid
;
return
tdb
Db
Insert
(
pMeta
->
pTtlIdx
,
&
ttlKey
,
sizeof
(
ttlKey
),
NULL
,
0
,
&
pMeta
->
txn
);
return
tdbInsert
(
pMeta
->
pTtlIdx
,
&
ttlKey
,
sizeof
(
ttlKey
),
NULL
,
0
,
&
pMeta
->
txn
);
}
static
int
metaUpdateCtbIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SCtbIdxKey
ctbIdxKey
=
{.
suid
=
pME
->
ctbEntry
.
suid
,
.
uid
=
pME
->
uid
};
return
tdb
Db
Insert
(
pMeta
->
pCtbIdx
,
&
ctbIdxKey
,
sizeof
(
ctbIdxKey
),
NULL
,
0
,
&
pMeta
->
txn
);
return
tdbInsert
(
pMeta
->
pCtbIdx
,
&
ctbIdxKey
,
sizeof
(
ctbIdxKey
),
NULL
,
0
,
&
pMeta
->
txn
);
}
static
int
metaCreateTagIdxKey
(
tb_uid_t
suid
,
int32_t
cid
,
const
void
*
pTagData
,
int8_t
type
,
tb_uid_t
uid
,
...
...
@@ -801,10 +801,10 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
SDecoder
dc
=
{
0
};
// get super table
tdb
Db
Get
(
pMeta
->
pUidIdx
,
&
pCtbEntry
->
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
);
tdbGet
(
pMeta
->
pUidIdx
,
&
pCtbEntry
->
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
);
tbDbKey
.
uid
=
pCtbEntry
->
ctbEntry
.
suid
;
tbDbKey
.
version
=
*
(
int64_t
*
)
pData
;
tdb
Db
Get
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pData
,
&
nData
);
tdbGet
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pData
,
&
nData
);
tDecoderInit
(
&
dc
,
pData
,
nData
);
metaDecodeEntry
(
&
dc
,
&
stbEntry
);
...
...
@@ -817,7 +817,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
&
pTagIdxKey
,
&
nTagIdxKey
)
<
0
)
{
return
-
1
;
}
tdb
Db
Insert
(
pMeta
->
pTagIdx
,
pTagIdxKey
,
nTagIdxKey
,
NULL
,
0
,
&
pMeta
->
txn
);
tdbInsert
(
pMeta
->
pTagIdx
,
pTagIdxKey
,
nTagIdxKey
,
NULL
,
0
,
&
pMeta
->
txn
);
metaDestroyTagIdxKey
(
pTagIdxKey
);
tDecoderClear
(
&
dc
);
...
...
@@ -859,7 +859,7 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
tEncoderInit
(
&
coder
,
pVal
,
vLen
);
tEncodeSSchemaWrapper
(
&
coder
,
pSW
);
if
(
tdb
Db
Insert
(
pMeta
->
pSkmDb
,
&
skmDbKey
,
sizeof
(
skmDbKey
),
pVal
,
vLen
,
&
pMeta
->
txn
)
<
0
)
{
if
(
tdbInsert
(
pMeta
->
pSkmDb
,
&
skmDbKey
,
sizeof
(
skmDbKey
),
pVal
,
vLen
,
&
pMeta
->
txn
)
<
0
)
{
rcode
=
-
1
;
goto
_exit
;
}
...
...
source/dnode/vnode/src/sma/smaTDBImpl.c
浏览文件 @
d44f4137
...
...
@@ -59,14 +59,14 @@ static int32_t smaOpenDBDb(TDB **ppDB, TENV *pEnv, const char *pFName) {
// Create a database
compFunc
=
tdSmaKeyCmpr
;
if
(
tdbD
bOpen
(
pFName
,
-
1
,
-
1
,
compFunc
,
pEnv
,
ppDB
)
<
0
)
{
if
(
td
bOpen
(
pFName
,
-
1
,
-
1
,
compFunc
,
pEnv
,
ppDB
)
<
0
)
{
return
-
1
;
}
return
0
;
}
static
int32_t
smaCloseDBDb
(
TDB
*
pDB
)
{
return
tdb
Db
Close
(
pDB
);
}
static
int32_t
smaCloseDBDb
(
TDB
*
pDB
)
{
return
tdbClose
(
pDB
);
}
int32_t
smaOpenDBF
(
TENV
*
pEnv
,
SDBFile
*
pDBF
)
{
// TEnv is shared by a group of SDBFile
...
...
@@ -99,7 +99,7 @@ int32_t smaSaveSmaToDB(SDBFile *pDBF, void *pKey, int32_t keyLen, void *pVal, in
int32_t
ret
;
printf
(
"save tsma data into %s, keyLen:%d valLen:%d txn:%p
\n
"
,
pDBF
->
path
,
keyLen
,
valLen
,
txn
);
ret
=
tdb
Db
Upsert
(
pDBF
->
pDB
,
pKey
,
keyLen
,
pVal
,
valLen
,
txn
);
ret
=
tdbUpsert
(
pDBF
->
pDB
,
pKey
,
keyLen
,
pVal
,
valLen
,
txn
);
if
(
ret
<
0
)
{
smaError
(
"failed to upsert tsma data into db, ret = %d"
,
ret
);
return
-
1
;
...
...
@@ -112,7 +112,7 @@ void *smaGetSmaDataByKey(SDBFile *pDBF, const void *pKey, int32_t keyLen, int32_
void
*
pVal
=
NULL
;
int
ret
;
ret
=
tdb
Db
Get
(
pDBF
->
pDB
,
pKey
,
keyLen
,
&
pVal
,
valLen
);
ret
=
tdbGet
(
pDBF
->
pDB
,
pKey
,
keyLen
,
&
pVal
,
valLen
);
if
(
ret
<
0
)
{
smaError
(
"failed to get tsma data from db, ret = %d"
,
ret
);
...
...
source/dnode/vnode/src/tsdb/tsdbTDBImpl.c
浏览文件 @
d44f4137
...
...
@@ -60,12 +60,12 @@ static int32_t tsdbOpenDBDb(TDB **ppDB, TENV *pEnv, const char *pFName) {
// Create a database
compFunc
=
tsdbSmaKeyCmpr
;
ret
=
tdb
Db
Open
(
pFName
,
-
1
,
-
1
,
compFunc
,
pEnv
,
ppDB
);
ret
=
tdbOpen
(
pFName
,
-
1
,
-
1
,
compFunc
,
pEnv
,
ppDB
);
return
0
;
}
static
int32_t
tsdbCloseDBDb
(
TDB
*
pDB
)
{
return
tdb
Db
Close
(
pDB
);
}
static
int32_t
tsdbCloseDBDb
(
TDB
*
pDB
)
{
return
tdbClose
(
pDB
);
}
int32_t
tsdbOpenDBF
(
TENV
*
pEnv
,
SDBFile
*
pDBF
)
{
// TEnv is shared by a group of SDBFile
...
...
@@ -97,7 +97,7 @@ int32_t tsdbCloseDBF(SDBFile *pDBF) {
int32_t
tsdbSaveSmaToDB
(
SDBFile
*
pDBF
,
void
*
pKey
,
int32_t
keyLen
,
void
*
pVal
,
int32_t
valLen
,
TXN
*
txn
)
{
int32_t
ret
;
ret
=
tdb
Db
Insert
(
pDBF
->
pDB
,
pKey
,
keyLen
,
pVal
,
valLen
,
txn
);
ret
=
tdbInsert
(
pDBF
->
pDB
,
pKey
,
keyLen
,
pVal
,
valLen
,
txn
);
if
(
ret
<
0
)
{
tsdbError
(
"Failed to create insert sma data into db, ret = %d"
,
ret
);
return
-
1
;
...
...
@@ -110,7 +110,7 @@ void *tsdbGetSmaDataByKey(SDBFile *pDBF, const void *pKey, int32_t keyLen, int32
void
*
pVal
=
NULL
;
int
ret
;
ret
=
tdb
Db
Get
(
pDBF
->
pDB
,
pKey
,
keyLen
,
&
pVal
,
valLen
);
ret
=
tdbGet
(
pDBF
->
pDB
,
pKey
,
keyLen
,
&
pVal
,
valLen
);
if
(
ret
<
0
)
{
tsdbError
(
"Failed to get sma data from db, ret = %d"
,
ret
);
...
...
source/libs/tdb/inc/tdb.h
浏览文件 @
d44f4137
...
...
@@ -37,14 +37,14 @@ int tdbBegin(TENV *pEnv, TXN *pTxn);
int
tdbCommit
(
TENV
*
pEnv
,
TXN
*
pTxn
);
// TDB
int
tdb
Db
Open
(
const
char
*
fname
,
int
keyLen
,
int
valLen
,
tdb_cmpr_fn_t
keyCmprFn
,
TENV
*
pEnv
,
TDB
**
ppDb
);
int
tdb
Db
Close
(
TDB
*
pDb
);
int
tdbD
bD
rop
(
TDB
*
pDb
);
int
tdb
Db
Insert
(
TDB
*
pDb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
,
TXN
*
pTxn
);
int
tdbD
bD
elete
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
TXN
*
pTxn
);
int
tdb
Db
Upsert
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
,
TXN
*
pTxn
);
int
tdb
Db
Get
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
tdb
Db
PGet
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppKey
,
int
*
pkLen
,
void
**
ppVal
,
int
*
vLen
);
int
tdbOpen
(
const
char
*
fname
,
int
keyLen
,
int
valLen
,
tdb_cmpr_fn_t
keyCmprFn
,
TENV
*
pEnv
,
TDB
**
ppDb
);
int
tdbClose
(
TDB
*
pDb
);
int
tdbDrop
(
TDB
*
pDb
);
int
tdbInsert
(
TDB
*
pDb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
,
TXN
*
pTxn
);
int
tdbDelete
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
TXN
*
pTxn
);
int
tdbUpsert
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
,
TXN
*
pTxn
);
int
tdbGet
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
tdbPGet
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppKey
,
int
*
pkLen
,
void
**
ppVal
,
int
*
vLen
);
// TDBC
int
tdbDbcOpen
(
TDB
*
pDb
,
TDBC
**
ppDbc
,
TXN
*
pTxn
);
...
...
source/libs/tdb/src/db/tdbDb.c
浏览文件 @
d44f4137
...
...
@@ -24,7 +24,7 @@ struct STDBC {
SBTC
btc
;
};
int
tdb
Db
Open
(
const
char
*
fname
,
int
keyLen
,
int
valLen
,
tdb_cmpr_fn_t
keyCmprFn
,
TENV
*
pEnv
,
TDB
**
ppDb
)
{
int
tdbOpen
(
const
char
*
fname
,
int
keyLen
,
int
valLen
,
tdb_cmpr_fn_t
keyCmprFn
,
TENV
*
pEnv
,
TDB
**
ppDb
)
{
TDB
*
pDb
;
SPager
*
pPager
;
int
ret
;
...
...
@@ -65,7 +65,7 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprFn
return
0
;
}
int
tdb
Db
Close
(
TDB
*
pDb
)
{
int
tdbClose
(
TDB
*
pDb
)
{
if
(
pDb
)
{
tdbBtreeClose
(
pDb
->
pBt
);
tdbOsFree
(
pDb
);
...
...
@@ -73,26 +73,26 @@ int tdbDbClose(TDB *pDb) {
return
0
;
}
int
tdbD
bD
rop
(
TDB
*
pDb
)
{
int
tdbDrop
(
TDB
*
pDb
)
{
// TODO
return
0
;
}
int
tdb
Db
Insert
(
TDB
*
pDb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
,
TXN
*
pTxn
)
{
int
tdbInsert
(
TDB
*
pDb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
,
TXN
*
pTxn
)
{
return
tdbBtreeInsert
(
pDb
->
pBt
,
pKey
,
keyLen
,
pVal
,
valLen
,
pTxn
);
}
int
tdbD
bD
elete
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
TXN
*
pTxn
)
{
return
tdbBtreeDelete
(
pDb
->
pBt
,
pKey
,
kLen
,
pTxn
);
}
int
tdbDelete
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
TXN
*
pTxn
)
{
return
tdbBtreeDelete
(
pDb
->
pBt
,
pKey
,
kLen
,
pTxn
);
}
int
tdb
Db
Upsert
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
,
TXN
*
pTxn
)
{
int
tdbUpsert
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
,
TXN
*
pTxn
)
{
return
tdbBtreeUpsert
(
pDb
->
pBt
,
pKey
,
kLen
,
pVal
,
vLen
,
pTxn
);
}
int
tdb
Db
Get
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppVal
,
int
*
vLen
)
{
int
tdbGet
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppVal
,
int
*
vLen
)
{
return
tdbBtreeGet
(
pDb
->
pBt
,
pKey
,
kLen
,
ppVal
,
vLen
);
}
int
tdb
Db
PGet
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppKey
,
int
*
pkLen
,
void
**
ppVal
,
int
*
vLen
)
{
int
tdbPGet
(
TDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppKey
,
int
*
pkLen
,
void
**
ppVal
,
int
*
vLen
)
{
return
tdbBtreePGet
(
pDb
->
pBt
,
pKey
,
kLen
,
ppKey
,
pkLen
,
ppVal
,
vLen
);
}
...
...
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
d44f4137
...
...
@@ -131,7 +131,7 @@ TEST(tdb_test, simple_insert1) {
// Create a database
compFunc
=
tKeyCmpr
;
ret
=
tdb
Db
Open
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
ret
=
tdbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
GTEST_ASSERT_EQ
(
ret
,
0
);
{
...
...
@@ -152,7 +152,7 @@ TEST(tdb_test, simple_insert1) {
for
(
int
iData
=
1
;
iData
<=
nData
;
iData
++
)
{
sprintf
(
key
,
"key%d"
,
iData
);
sprintf
(
val
,
"value%d"
,
iData
);
ret
=
tdb
Db
Insert
(
pDb
,
key
,
strlen
(
key
),
val
,
strlen
(
val
),
&
txn
);
ret
=
tdbInsert
(
pDb
,
key
,
strlen
(
key
),
val
,
strlen
(
val
),
&
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// if pool is full, commit the transaction and start a new one
...
...
@@ -181,7 +181,7 @@ TEST(tdb_test, simple_insert1) {
sprintf
(
key
,
"key%d"
,
i
);
sprintf
(
val
,
"value%d"
,
i
);
ret
=
tdb
Db
Get
(
pDb
,
key
,
strlen
(
key
),
&
pVal
,
&
vLen
);
ret
=
tdbGet
(
pDb
,
key
,
strlen
(
key
),
&
pVal
,
&
vLen
);
ASSERT
(
ret
==
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
...
...
@@ -224,11 +224,11 @@ TEST(tdb_test, simple_insert1) {
}
}
ret
=
tdbD
bD
rop
(
pDb
);
ret
=
tdbDrop
(
pDb
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// Close a database
tdb
Db
Close
(
pDb
);
tdbClose
(
pDb
);
// Close Env
ret
=
tdbEnvClose
(
pEnv
);
...
...
@@ -251,7 +251,7 @@ TEST(tdb_test, simple_insert2) {
// Create a database
compFunc
=
tDefaultKeyCmpr
;
ret
=
tdb
Db
Open
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
ret
=
tdbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
GTEST_ASSERT_EQ
(
ret
,
0
);
{
...
...
@@ -271,7 +271,7 @@ TEST(tdb_test, simple_insert2) {
for
(
int
iData
=
1
;
iData
<=
nData
;
iData
++
)
{
sprintf
(
key
,
"key%d"
,
iData
);
sprintf
(
val
,
"value%d"
,
iData
);
ret
=
tdb
Db
Insert
(
pDb
,
key
,
strlen
(
key
),
val
,
strlen
(
val
),
&
txn
);
ret
=
tdbInsert
(
pDb
,
key
,
strlen
(
key
),
val
,
strlen
(
val
),
&
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
...
...
@@ -311,11 +311,11 @@ TEST(tdb_test, simple_insert2) {
tdbCommit
(
pEnv
,
&
txn
);
tdbTxnClose
(
&
txn
);
ret
=
tdbD
bD
rop
(
pDb
);
ret
=
tdbDrop
(
pDb
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// Close a database
tdb
Db
Close
(
pDb
);
tdbClose
(
pDb
);
// Close Env
ret
=
tdbEnvClose
(
pEnv
);
...
...
@@ -346,7 +346,7 @@ TEST(tdb_test, simple_delete1) {
GTEST_ASSERT_EQ
(
ret
,
0
);
// open database
ret
=
tdb
Db
Open
(
"db.db"
,
-
1
,
-
1
,
tKeyCmpr
,
pEnv
,
&
pDb
);
ret
=
tdbOpen
(
"db.db"
,
-
1
,
-
1
,
tKeyCmpr
,
pEnv
,
&
pDb
);
GTEST_ASSERT_EQ
(
ret
,
0
);
tdbTxnOpen
(
&
txn
,
0
,
poolMalloc
,
poolFree
,
pPool
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
);
...
...
@@ -356,7 +356,7 @@ TEST(tdb_test, simple_delete1) {
for
(
int
iData
=
0
;
iData
<
nKV
;
iData
++
)
{
sprintf
(
key
,
"key%d"
,
iData
);
sprintf
(
data
,
"data%d"
,
iData
);
ret
=
tdb
Db
Insert
(
pDb
,
key
,
strlen
(
key
),
data
,
strlen
(
data
),
&
txn
);
ret
=
tdbInsert
(
pDb
,
key
,
strlen
(
key
),
data
,
strlen
(
data
),
&
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
...
...
@@ -365,7 +365,7 @@ TEST(tdb_test, simple_delete1) {
sprintf
(
key
,
"key%d"
,
iData
);
sprintf
(
data
,
"data%d"
,
iData
);
ret
=
tdb
Db
Get
(
pDb
,
key
,
strlen
(
key
),
&
pData
,
&
nData
);
ret
=
tdbGet
(
pDb
,
key
,
strlen
(
key
),
&
pData
,
&
nData
);
GTEST_ASSERT_EQ
(
ret
,
0
);
GTEST_ASSERT_EQ
(
memcmp
(
data
,
pData
,
nData
),
0
);
}
...
...
@@ -374,7 +374,7 @@ TEST(tdb_test, simple_delete1) {
for
(
int
iData
=
nKV
-
1
;
iData
>
30
;
iData
--
)
{
sprintf
(
key
,
"key%d"
,
iData
);
ret
=
tdbD
bD
elete
(
pDb
,
key
,
strlen
(
key
),
&
txn
);
ret
=
tdbDelete
(
pDb
,
key
,
strlen
(
key
),
&
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
...
...
@@ -382,7 +382,7 @@ TEST(tdb_test, simple_delete1) {
for
(
int
iData
=
0
;
iData
<
nKV
;
iData
++
)
{
sprintf
(
key
,
"key%d"
,
iData
);
ret
=
tdb
Db
Get
(
pDb
,
key
,
strlen
(
key
),
&
pData
,
&
nData
);
ret
=
tdbGet
(
pDb
,
key
,
strlen
(
key
),
&
pData
,
&
nData
);
if
(
iData
<=
30
)
{
GTEST_ASSERT_EQ
(
ret
,
0
);
}
else
{
...
...
@@ -413,7 +413,7 @@ TEST(tdb_test, simple_delete1) {
closePool
(
pPool
);
tdb
Db
Close
(
pDb
);
tdbClose
(
pDb
);
tdbEnvClose
(
pEnv
);
}
...
...
@@ -435,7 +435,7 @@ TEST(tdb_test, simple_upsert1) {
GTEST_ASSERT_EQ
(
ret
,
0
);
// open database
ret
=
tdb
Db
Open
(
"db.db"
,
-
1
,
-
1
,
NULL
,
pEnv
,
&
pDb
);
ret
=
tdbOpen
(
"db.db"
,
-
1
,
-
1
,
NULL
,
pEnv
,
&
pDb
);
GTEST_ASSERT_EQ
(
ret
,
0
);
pPool
=
openPool
();
...
...
@@ -446,7 +446,7 @@ TEST(tdb_test, simple_upsert1) {
for
(
int
iData
=
0
;
iData
<
nData
;
iData
++
)
{
sprintf
(
key
,
"key%d"
,
iData
);
sprintf
(
data
,
"data%d"
,
iData
);
ret
=
tdb
Db
Insert
(
pDb
,
key
,
strlen
(
key
),
data
,
strlen
(
data
),
&
txn
);
ret
=
tdbInsert
(
pDb
,
key
,
strlen
(
key
),
data
,
strlen
(
data
),
&
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
...
...
@@ -454,7 +454,7 @@ TEST(tdb_test, simple_upsert1) {
for
(
int
iData
=
0
;
iData
<
nData
;
iData
++
)
{
sprintf
(
key
,
"key%d"
,
iData
);
sprintf
(
data
,
"data%d"
,
iData
);
ret
=
tdb
Db
Get
(
pDb
,
key
,
strlen
(
key
),
&
pData
,
&
nData
);
ret
=
tdbGet
(
pDb
,
key
,
strlen
(
key
),
&
pData
,
&
nData
);
GTEST_ASSERT_EQ
(
ret
,
0
);
GTEST_ASSERT_EQ
(
memcmp
(
pData
,
data
,
nData
),
0
);
}
...
...
@@ -463,7 +463,7 @@ TEST(tdb_test, simple_upsert1) {
for
(
int
iData
=
0
;
iData
<
nData
;
iData
++
)
{
sprintf
(
key
,
"key%d"
,
iData
);
sprintf
(
data
,
"data%d-u"
,
iData
);
ret
=
tdb
Db
Upsert
(
pDb
,
key
,
strlen
(
key
),
data
,
strlen
(
data
),
&
txn
);
ret
=
tdbUpsert
(
pDb
,
key
,
strlen
(
key
),
data
,
strlen
(
data
),
&
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
...
...
@@ -473,11 +473,11 @@ TEST(tdb_test, simple_upsert1) {
for
(
int
iData
=
0
;
iData
<
nData
;
iData
++
)
{
sprintf
(
key
,
"key%d"
,
iData
);
sprintf
(
data
,
"data%d-u"
,
iData
);
ret
=
tdb
Db
Get
(
pDb
,
key
,
strlen
(
key
),
&
pData
,
&
nData
);
ret
=
tdbGet
(
pDb
,
key
,
strlen
(
key
),
&
pData
,
&
nData
);
GTEST_ASSERT_EQ
(
ret
,
0
);
GTEST_ASSERT_EQ
(
memcmp
(
pData
,
data
,
nData
),
0
);
}
tdb
Db
Close
(
pDb
);
tdbClose
(
pDb
);
tdbEnvClose
(
pEnv
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录