Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cde7a7c6
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看板
提交
cde7a7c6
编写于
3月 21, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more TDB
上级
13b7ba3e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
17 deletion
+27
-17
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+8
-6
source/libs/tdb/src/inc/tdbPage.h
source/libs/tdb/src/inc/tdbPage.h
+3
-3
source/libs/tdb/src/page/tdbPage.c
source/libs/tdb/src/page/tdbPage.c
+16
-8
未找到文件。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
cde7a7c6
...
...
@@ -381,19 +381,20 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) {
SBTree
*
pBt
;
u16
flags
;
u8
isLeaf
;
u8
szAmHdr
;
pBt
=
(
SBTree
*
)
arg
;
flags
=
TDB_PAGE_FLAGS
(
pPage
);
isLeaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
if
(
isLeaf
)
{
pPage
->
szAmHdr
=
0
;
szAmHdr
=
0
;
}
else
{
pPage
->
szAmHdr
=
sizeof
(
SBtPageHdr
);
szAmHdr
=
sizeof
(
SBtPageHdr
);
}
pPage
->
xCellSize
=
NULL
;
// TODO
tdbPageInit
(
pPage
);
tdbPageInit
(
pPage
,
szAmHdr
);
TDB_BTREE_ASSERT_FLAG
(
flags
);
...
...
@@ -416,6 +417,7 @@ static int tdbBtreeZeroPage(SPage *pPage, void *arg) {
u16
flags
;
SBTree
*
pBt
;
u8
isLeaf
;
u8
szAmHdr
;
flags
=
((
SBtreeZeroPageArg
*
)
arg
)
->
flags
;
pBt
=
((
SBtreeZeroPageArg
*
)
arg
)
->
pBt
;
...
...
@@ -425,13 +427,13 @@ static int tdbBtreeZeroPage(SPage *pPage, void *arg) {
TDB_PAGE_FLAGS_SET
(
pPage
,
flags
);
// Set szAmHdr
if
(
isLeaf
)
{
pPage
->
szAmHdr
=
0
;
szAmHdr
=
0
;
}
else
{
pPage
->
szAmHdr
=
sizeof
(
SBtPageHdr
);
szAmHdr
=
sizeof
(
SBtPageHdr
);
}
pPage
->
xCellSize
=
NULL
;
// TODO
tdbPageZero
(
pPage
);
tdbPageZero
(
pPage
,
szAmHdr
);
if
(
isLeaf
)
{
pPage
->
kLen
=
pBt
->
keyLen
;
...
...
source/libs/tdb/src/inc/tdbPage.h
浏览文件 @
cde7a7c6
...
...
@@ -61,7 +61,6 @@ struct SPage {
u8
*
pData
;
SPageMethods
*
pPageMethods
;
// Fields below used by pager and am
u8
szAmHdr
;
u8
*
pAmHdr
;
u8
*
pPageHdr
;
u8
*
pCellIdx
;
...
...
@@ -111,8 +110,8 @@ struct SPage {
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
);
void
tdbPageZero
(
SPage
*
pPage
);
void
tdbPageInit
(
SPage
*
pPage
);
void
tdbPageZero
(
SPage
*
pPage
,
u8
szAmHdr
);
void
tdbPageInit
(
SPage
*
pPage
,
u8
szAmHdr
);
int
tdbPageInsertCell
(
SPage
*
pPage
,
int
idx
,
SCell
*
pCell
,
int
szCell
);
int
tdbPageDropCell
(
SPage
*
pPage
,
int
idx
);
...
...
@@ -134,6 +133,7 @@ static inline SCell *tdbPageGetCell(SPage *pPage, int idx) {
}
lidx
=
idx
-
iOvfl
;
ASSERT
(
lidx
>=
0
&&
lidx
<
pPage
->
pPageMethods
->
getCellNum
(
pPage
));
pCell
=
pPage
->
pData
+
pPage
->
pPageMethods
->
getCellOffset
(
pPage
,
lidx
);
return
pCell
;
...
...
source/libs/tdb/src/page/tdbPage.c
浏览文件 @
cde7a7c6
...
...
@@ -32,8 +32,8 @@ extern SPageMethods pageLargeMethods;
#define TDB_PAGE_NFREE_SET(pPage, NFREE) (*(pPage)->pPageMethods->setFreeBytes)(pPage, NFREE)
#define TDB_PAGE_CELL_OFFSET_AT_SET(pPage, idx, OFFSET) (*(pPage)->pPageMethods->setCellOffset)(pPage, idx, OFFSET)
#define TDB_PAGE_CELL_AT(pPage, idx) ((pPage)->pData + TDB_PAGE_CELL_OFFSET_AT(pPage, idx))
#define TDB_PAGE_MAX_FREE_BLOCK(pPage) \
((pPage)->pageSize - (
pPage)->szAmHdr -
TDB_PAGE_HDR_SIZE(pPage) - sizeof(SPageFtr))
#define TDB_PAGE_MAX_FREE_BLOCK(pPage
, szAmHdr
) \
((pPage)->pageSize - (
szAmHdr)-
TDB_PAGE_HDR_SIZE(pPage) - sizeof(SPageFtr))
static
int
tdbPageAllocate
(
SPage
*
pPage
,
int
size
,
SCell
**
ppCell
);
static
int
tdbPageDefragment
(
SPage
*
pPage
);
...
...
@@ -79,17 +79,25 @@ int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg)
return
0
;
}
void
tdbPageZero
(
SPage
*
pPage
)
{
void
tdbPageZero
(
SPage
*
pPage
,
u8
szAmHdr
)
{
pPage
->
pAmHdr
=
pPage
->
pData
;
pPage
->
pPageHdr
=
pPage
->
pAmHdr
+
szAmHdr
;
TDB_PAGE_NCELLS_SET
(
pPage
,
0
);
TDB_PAGE_CCELLS_SET
(
pPage
,
pPage
->
pageSize
-
sizeof
(
SPageFtr
));
TDB_PAGE_FCELL_SET
(
pPage
,
0
);
TDB_PAGE_NFREE_SET
(
pPage
,
TDB_PAGE_MAX_FREE_BLOCK
(
pPage
));
tdbPageInit
(
pPage
);
TDB_PAGE_NFREE_SET
(
pPage
,
TDB_PAGE_MAX_FREE_BLOCK
(
pPage
,
szAmHdr
));
pPage
->
pCellIdx
=
pPage
->
pPageHdr
+
TDB_PAGE_HDR_SIZE
(
pPage
);
pPage
->
pFreeStart
=
pPage
->
pCellIdx
;
pPage
->
pFreeEnd
=
pPage
->
pData
+
TDB_PAGE_CCELLS
(
pPage
);
pPage
->
pPageFtr
=
(
SPageFtr
*
)(
pPage
->
pData
+
pPage
->
pageSize
-
sizeof
(
SPageFtr
));
pPage
->
nOverflow
=
0
;
ASSERT
((
u8
*
)
pPage
->
pPageFtr
==
pPage
->
pFreeEnd
);
}
void
tdbPageInit
(
SPage
*
pPage
)
{
void
tdbPageInit
(
SPage
*
pPage
,
u8
szAmHdr
)
{
pPage
->
pAmHdr
=
pPage
->
pData
;
pPage
->
pPageHdr
=
pPage
->
pAmHdr
+
pPage
->
szAmHdr
;
pPage
->
pPageHdr
=
pPage
->
pAmHdr
+
szAmHdr
;
pPage
->
pCellIdx
=
pPage
->
pPageHdr
+
TDB_PAGE_HDR_SIZE
(
pPage
);
pPage
->
pFreeStart
=
pPage
->
pCellIdx
+
TDB_PAGE_OFFSET_SIZE
(
pPage
)
*
TDB_PAGE_NCELLS
(
pPage
);
pPage
->
pFreeEnd
=
pPage
->
pData
+
TDB_PAGE_CCELLS
(
pPage
);
...
...
@@ -107,7 +115,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell) {
int
lidx
;
// local idx
SCell
*
pNewCell
;
ASSERT
(
szCell
<=
TDB_PAGE_MAX_FREE_BLOCK
(
pPage
));
ASSERT
(
szCell
<=
TDB_PAGE_MAX_FREE_BLOCK
(
pPage
,
pPage
->
pPageHdr
-
pPage
->
pAmHdr
));
nFree
=
TDB_PAGE_NFREE
(
pPage
);
nCells
=
TDB_PAGE_NCELLS
(
pPage
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录