Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d3487c88
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d3487c88
编写于
5月 03, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TDB impl delete
上级
bf355e70
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
9 deletion
+51
-9
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+14
-2
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+37
-7
未找到文件。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
d3487c88
...
@@ -766,6 +766,13 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
...
@@ -766,6 +766,13 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
}
}
}
}
if
(
TDB_BTREE_PAGE_IS_ROOT
(
pParent
)
&&
TDB_PAGE_TOTAL_CELLS
(
pParent
)
==
0
)
{
i8
flags
=
TDB_BTREE_ROOT
|
TDB_BTREE_PAGE_IS_LEAF
(
pNews
[
0
]);
// copy content to the parent page
tdbBtreeInitPage
(
pParent
,
&
(
SBtreeInitPageArg
){.
flags
=
flags
,
.
pBt
=
pBt
},
0
);
tdbPageCopy
(
pNews
[
0
],
pParent
);
}
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
if
(
pDivCell
[
i
])
{
if
(
pDivCell
[
i
])
{
tdbOsFree
(
pDivCell
[
i
]);
tdbOsFree
(
pDivCell
[
i
]);
...
@@ -1454,9 +1461,14 @@ int tdbBtcDelete(SBTC *pBtc) {
...
@@ -1454,9 +1461,14 @@ int tdbBtcDelete(SBTC *pBtc) {
}
}
}
}
}
else
{
}
else
{
// delete the leaf page and do balance
(TODO)
// delete the leaf page and do balance
ASSERT
(
TDB_PAGE_TOTAL_CELLS
(
pBtc
->
pPage
)
==
0
);
ASSERT
(
TDB_PAGE_TOTAL_CELLS
(
pBtc
->
pPage
)
==
0
);
ASSERT
(
0
);
ret
=
tdbBtreeBalance
(
pBtc
);
if
(
ret
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
}
}
}
}
...
...
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
d3487c88
...
@@ -120,7 +120,7 @@ TEST(tdb_test, simple_test) {
...
@@ -120,7 +120,7 @@ TEST(tdb_test, simple_test) {
TENV
*
pEnv
;
TENV
*
pEnv
;
TDB
*
pDb
;
TDB
*
pDb
;
tdb_cmpr_fn_t
compFunc
;
tdb_cmpr_fn_t
compFunc
;
int
nData
=
1000000
0
;
int
nData
=
1000000
;
TXN
txn
;
TXN
txn
;
taosRemoveDir
(
"tdb"
);
taosRemoveDir
(
"tdb"
);
...
@@ -291,9 +291,9 @@ TEST(tdb_test, simple_test2) {
...
@@ -291,9 +291,9 @@ TEST(tdb_test, simple_test2) {
ret
=
tdbDbcNext
(
pDBC
,
&
pKey
,
&
kLen
,
&
pVal
,
&
vLen
);
ret
=
tdbDbcNext
(
pDBC
,
&
pKey
,
&
kLen
,
&
pVal
,
&
vLen
);
if
(
ret
<
0
)
break
;
if
(
ret
<
0
)
break
;
std
::
cout
.
write
((
char
*
)
pKey
,
kLen
)
/* << " " << kLen */
<<
" "
;
//
std::cout.write((char *)pKey, kLen) /* << " " << kLen */ << " ";
std
::
cout
.
write
((
char
*
)
pVal
,
vLen
)
/* << " " << vLen */
;
//
std::cout.write((char *)pVal, vLen) /* << " " << vLen */;
std
::
cout
<<
std
::
endl
;
//
std::cout << std::endl;
count
++
;
count
++
;
}
}
...
@@ -333,15 +333,16 @@ TEST(tdb_test, simple_delete1) {
...
@@ -333,15 +333,16 @@ TEST(tdb_test, simple_delete1) {
void
*
pKey
=
NULL
;
void
*
pKey
=
NULL
;
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nKey
;
int
nKey
;
TDBC
*
pDbc
;
int
nData
;
int
nData
;
int
nKV
=
254
;
int
nKV
=
69
;
taosRemoveDir
(
"tdb"
);
taosRemoveDir
(
"tdb"
);
pPool
=
openPool
();
pPool
=
openPool
();
// open env
// open env
ret
=
tdbEnvOpen
(
"tdb"
,
4096
,
256
,
&
pEnv
);
ret
=
tdbEnvOpen
(
"tdb"
,
1024
,
256
,
&
pEnv
);
GTEST_ASSERT_EQ
(
ret
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// open database
// open database
...
@@ -370,7 +371,7 @@ TEST(tdb_test, simple_delete1) {
...
@@ -370,7 +371,7 @@ TEST(tdb_test, simple_delete1) {
}
}
// loop to delete some data
// loop to delete some data
for
(
int
iData
=
nKV
-
1
;
iData
>
=
0
;
iData
--
)
{
for
(
int
iData
=
nKV
-
1
;
iData
>
3
0
;
iData
--
)
{
sprintf
(
key
,
"key%d"
,
iData
);
sprintf
(
key
,
"key%d"
,
iData
);
ret
=
tdbDbDelete
(
pDb
,
key
,
strlen
(
key
),
&
txn
);
ret
=
tdbDbDelete
(
pDb
,
key
,
strlen
(
key
),
&
txn
);
...
@@ -378,6 +379,35 @@ TEST(tdb_test, simple_delete1) {
...
@@ -378,6 +379,35 @@ TEST(tdb_test, simple_delete1) {
}
}
// query the data
// query the data
for
(
int
iData
=
0
;
iData
<
nKV
;
iData
++
)
{
sprintf
(
key
,
"key%d"
,
iData
);
ret
=
tdbDbGet
(
pDb
,
key
,
strlen
(
key
),
&
pData
,
&
nData
);
if
(
iData
<=
30
)
{
GTEST_ASSERT_EQ
(
ret
,
0
);
}
else
{
GTEST_ASSERT_EQ
(
ret
,
-
1
);
}
}
// loop to iterate the data
tdbDbcOpen
(
pDb
,
&
pDbc
,
NULL
);
ret
=
tdbDbcMoveToFirst
(
pDbc
);
GTEST_ASSERT_EQ
(
ret
,
0
);
pKey
=
NULL
;
pData
=
NULL
;
for
(;;)
{
ret
=
tdbDbcNext
(
pDbc
,
&
pKey
,
&
nKey
,
&
pData
,
&
nData
);
if
(
ret
<
0
)
break
;
std
::
cout
.
write
((
char
*
)
pKey
,
nKey
)
/* << " " << kLen */
<<
" "
;
std
::
cout
.
write
((
char
*
)
pData
,
nData
)
/* << " " << vLen */
;
std
::
cout
<<
std
::
endl
;
}
tdbDbcClose
(
pDbc
);
tdbCommit
(
pEnv
,
&
txn
);
tdbCommit
(
pEnv
,
&
txn
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录