Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
52d15771
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
52d15771
编写于
5月 02, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more tdb delte
上级
b2e5a364
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
68 addition
and
14 deletion
+68
-14
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+61
-14
source/libs/tdb/src/db/tdbPage.c
source/libs/tdb/src/db/tdbPage.c
+5
-0
source/libs/tdb/src/inc/tdbInt.h
source/libs/tdb/src/inc/tdbInt.h
+2
-0
未找到文件。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
52d15771
...
...
@@ -1394,32 +1394,79 @@ int tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int
}
int
tdbBtcDelete
(
SBTC
*
pBtc
)
{
#if 0
// check transaction
if (!TDB_TXN_IS_WRITE(pBtc->pTxn)) {
return -1;
}
int
idx
=
pBtc
->
idx
;
int
nCells
=
TDB_PAGE_TOTAL_CELLS
(
pBtc
->
pPage
);
SPager
*
pPager
=
pBtc
->
pBt
->
pPager
;
const
void
*
pKey
;
i8
iPage
;
SPage
*
pPage
;
SPgno
pgno
;
SCell
*
pCell
;
int
szCell
;
int
nKey
;
int
ret
;
int idx = pBtc->idx;
int nCells = TDB_PAGE_TOTAL_CELLS(pBtc->pPage);
ASSERT
(
idx
>=
0
&&
idx
<
nCells
);
tdbPagerWrite(pBtc->pBt->pPager, pBtc->pPage);
// drop the cell on the leaf
ret
=
tdbPagerWrite
(
pPager
,
pBtc
->
pPage
);
if
(
ret
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
tdbPageDropCell
(
pBtc
->
pPage
,
idx
);
// update interior page or do balance
if
(
idx
==
nCells
-
1
)
{
// drop cells above
for (;;) {
/* code */
}
if
(
idx
)
{
pBtc
->
idx
--
;
tdbBtcGet
(
pBtc
,
&
pKey
,
&
nKey
,
NULL
,
NULL
);
// loop to update the interial page
pgno
=
TDB_PAGE_PGNO
(
pBtc
->
pPage
);
for
(
iPage
=
pBtc
->
iPage
-
1
;
iPage
>=
0
;
iPage
--
)
{
pPage
=
pBtc
->
pgStack
[
iPage
];
idx
=
pBtc
->
idxStack
[
iPage
];
nCells
=
TDB_PAGE_TOTAL_CELLS
(
pPage
);
if
(
idx
<
nCells
)
{
ret
=
tdbPagerWrite
(
pPager
,
pPage
);
if
(
ret
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
// update the cell with new key
pCell
=
tdbOsMalloc
(
nKey
+
9
);
tdbBtreeEncodeCell
(
pPage
,
pKey
,
nKey
,
&
pgno
,
sizeof
(
pgno
),
pCell
,
&
szCell
);
// do balance
ret
=
tdbPageUpdateCell
(
pPage
,
idx
,
pCell
,
szCell
);
if
(
ret
<
0
)
{
tdbOsFree
(
pCell
);
ASSERT
(
0
);
return
-
1
;
}
tdbOsFree
(
pCell
);
break
;
}
else
{
pgno
=
TDB_PAGE_PGNO
(
pPage
);
}
}
}
else
{
// delete the leaf page and do balance (TODO)
}
}
#endif
return
0
;
}
int
tdbBtcUpsert
(
SBTC
*
pBtc
)
{
ASSERT
(
0
);
// TODO
return
0
;
}
int
tdbBtcMoveTo
(
SBTC
*
pBtc
,
const
void
*
pKey
,
int
kLen
,
int
*
pCRst
)
{
int
ret
;
int
nCells
;
...
...
source/libs/tdb/src/db/tdbPage.c
浏览文件 @
52d15771
...
...
@@ -171,6 +171,11 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
return
0
;
}
int
tdbPageUpdateCell
(
SPage
*
pPage
,
int
idx
,
SCell
*
pCell
,
int
szCell
)
{
tdbPageDropCell
(
pPage
,
idx
);
return
tdbPageInsertCell
(
pPage
,
idx
,
pCell
,
szCell
,
0
);
}
int
tdbPageDropCell
(
SPage
*
pPage
,
int
idx
)
{
int
lidx
;
SCell
*
pCell
;
...
...
source/libs/tdb/src/inc/tdbInt.h
浏览文件 @
52d15771
...
...
@@ -143,6 +143,7 @@ int tdbBtcMoveToPrev(SBTC *pBtc);
int
tdbBtreeNext
(
SBTC
*
pBtc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
tdbBtcGet
(
SBTC
*
pBtc
,
const
void
**
ppKey
,
int
*
kLen
,
const
void
**
ppVal
,
int
*
vLen
);
int
tdbBtcDelete
(
SBTC
*
pBtc
);
int
tdbBtcUpsert
(
SBTC
*
pBtc
);
// tdbPager.c ====================================
...
...
@@ -280,6 +281,7 @@ void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell
void
tdbPageInit
(
SPage
*
pPage
,
u8
szAmHdr
,
int
(
*
xCellSize
)(
const
SPage
*
,
SCell
*
));
int
tdbPageInsertCell
(
SPage
*
pPage
,
int
idx
,
SCell
*
pCell
,
int
szCell
,
u8
asOvfl
);
int
tdbPageDropCell
(
SPage
*
pPage
,
int
idx
);
int
tdbPageUpdateCell
(
SPage
*
pPage
,
int
idx
,
SCell
*
pCell
,
int
szCell
);
void
tdbPageCopy
(
SPage
*
pFromPage
,
SPage
*
pToPage
);
int
tdbPageCapacity
(
int
pageSize
,
int
amHdrSize
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录