Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
238550b0
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看板
提交
238550b0
编写于
3月 22, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more TDB
上级
2d1e356c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
5 deletion
+33
-5
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+32
-4
source/libs/tdb/src/inc/tdbPage.h
source/libs/tdb/src/inc/tdbPage.h
+1
-0
source/libs/tdb/src/page/tdbPage.c
source/libs/tdb/src/page/tdbPage.c
+0
-1
未找到文件。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
238550b0
...
...
@@ -477,10 +477,15 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
int
nOlds
;
SPage
*
pOlds
[
3
];
SCell
*
pDivCell
[
2
]
=
{
0
};
int
szDivCell
[
2
];
int
sIdx
;
u8
childLeaf
;
{
// Find 3 child pages at most to do balance
int
nCells
=
TDB_PAGE_TOTAL_CELLS
(
pParent
);
int
nCells
=
TDB_PAGE_TOTAL_CELLS
(
pParent
);
SCell
*
pCell
;
if
(
nCells
<=
2
)
{
sIdx
=
0
;
nOlds
=
nCells
+
1
;
...
...
@@ -503,8 +508,6 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
ASSERT
(
!
TDB_BTREE_PAGE_IS_LEAF
(
TDB_BTREE_PAGE_GET_FLAGS
(
pParent
)));
pgno
=
((
SIntHdr
*
)(
pParent
->
pData
))
->
pgno
;
}
else
{
SCell
*
pCell
;
pCell
=
tdbPageGetCell
(
pParent
,
sIdx
+
i
);
pgno
=
*
(
SPgno
*
)
pCell
;
}
...
...
@@ -515,6 +518,17 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
return
-
1
;
}
}
// copy the parent key out if child pages are not leaf page
childLeaf
=
TDB_BTREE_PAGE_IS_LEAF
(
TDB_BTREE_PAGE_GET_FLAGS
(
pOlds
[
0
]));
if
(
childLeaf
)
{
for
(
int
i
=
0
;
i
<
nOlds
-
1
;
i
++
)
{
pCell
=
tdbPageGetCell
(
pParent
,
sIdx
+
i
);
szDivCell
[
i
]
=
tdbBtreeCellSize
(
pParent
,
pCell
);
pDivCell
[
i
]
=
malloc
(
szDivCell
[
i
]);
memcpy
(
pDivCell
,
pCell
,
szDivCell
[
i
]);
}
}
// drop the cells on parent page
for
(
int
i
=
0
;
i
<
nOlds
;
i
++
)
{
nCells
=
TDB_PAGE_TOTAL_CELLS
(
pParent
);
...
...
@@ -541,14 +555,28 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
SPage
*
pPage
=
pOlds
[
oPage
];
SCell
*
pCell
;
int
cellBytes
;
int
oIdx
;
for
(
int
oIdx
=
0
;
oIdx
<
TDB_PAGE_TOTAL_CELLS
(
pPage
);
oIdx
++
)
{
for
(
oIdx
=
0
;
oIdx
<
TDB_PAGE_TOTAL_CELLS
(
pPage
);
oIdx
++
)
{
pCell
=
tdbPageGetCell
(
pPage
,
oIdx
);
cellBytes
=
TDB_BYTES_CELL_TAKEN
(
pPage
,
pCell
);
if
(
infoNews
[
nNews
].
size
+
cellBytes
>
TDB_PAGE_USABLE_SIZE
(
pPage
))
{
// page is full, use a new page
nNews
++
;
// for a child leaf case, this cell is used as the new divider cell
if
(
childLeaf
)
continue
;
}
infoNews
[
nNews
].
cnt
++
;
infoNews
[
nNews
].
size
+=
cellBytes
;
infoNews
[
nNews
].
oPage
=
oPage
;
infoNews
[
nNews
].
oIdx
=
oIdx
;
}
// For child leaf pages
if
(
childLeaf
&&
oPage
<
nOlds
-
1
)
{
if
(
infoNews
[
nNews
].
size
+
szDivCell
[
oPage
]
+
TDB_PAGE_OFFSET_SIZE
(
pPage
)
>
TDB_PAGE_USABLE_SIZE
(
pPage
))
{
nNews
++
;
}
infoNews
[
nNews
].
cnt
++
;
infoNews
[
nNews
].
size
+=
cellBytes
;
...
...
source/libs/tdb/src/inc/tdbPage.h
浏览文件 @
238550b0
...
...
@@ -102,6 +102,7 @@ struct SPage {
#define TDB_PAGE_USABLE_SIZE(pPage) ((u8 *)(pPage)->pPageFtr - (pPage)->pCellIdx)
#define TDB_PAGE_PGNO(pPage) ((pPage)->pgid.pgno)
#define TDB_BYTES_CELL_TAKEN(pPage, pCell) ((*(pPage)->xCellSize)(pPage, pCell) + (pPage)->pPageMethods->szOffset)
#define TDB_PAGE_OFFSET_SIZE(pPage) ((pPage)->pPageMethods->szOffset)
int
tdbPageCreate
(
int
pageSize
,
SPage
**
ppPage
,
void
*
(
*
xMalloc
)(
void
*
,
size_t
),
void
*
arg
);
int
tdbPageDestroy
(
SPage
*
pPage
,
void
(
*
xFree
)(
void
*
arg
,
void
*
ptr
),
void
*
arg
);
...
...
source/libs/tdb/src/page/tdbPage.c
浏览文件 @
238550b0
...
...
@@ -18,7 +18,6 @@
extern
SPageMethods
pageMethods
;
extern
SPageMethods
pageLargeMethods
;
#define TDB_PAGE_OFFSET_SIZE(pPage) ((pPage)->pPageMethods->szOffset)
#define TDB_PAGE_HDR_SIZE(pPage) ((pPage)->pPageMethods->szPageHdr)
#define TDB_PAGE_FREE_CELL_SIZE(pPage) ((pPage)->pPageMethods->szFreeCell)
#define TDB_PAGE_NCELLS(pPage) (*(pPage)->pPageMethods->getCellNum)(pPage)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录