Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4e8f8445
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
4e8f8445
编写于
3月 21, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more TDB
上级
03eaa648
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
23 deletion
+42
-23
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+24
-17
source/libs/tdb/src/inc/tdbPage.h
source/libs/tdb/src/inc/tdbPage.h
+4
-0
source/libs/tdb/src/page/tdbPage.c
source/libs/tdb/src/page/tdbPage.c
+7
-3
source/libs/tdb/src/page/tdbPageL.c
source/libs/tdb/src/page/tdbPageL.c
+7
-3
未找到文件。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
4e8f8445
...
...
@@ -39,9 +39,16 @@ struct SBTree {
u8
*
pTmp
;
};
#define TDB_BTREE_PAGE_COMMON_HDR u8 flags;
typedef
struct
__attribute__
((
__packed__
))
{
TDB_BTREE_PAGE_COMMON_HDR
}
SLeafHdr
;
typedef
struct
__attribute__
((
__packed__
))
{
SPgno
rChild
;
}
SBtPageHdr
;
TDB_BTREE_PAGE_COMMON_HDR
;
SPgno
pgno
;
// right-most child
}
SIntHdr
;
typedef
struct
{
u16
flags
;
...
...
@@ -220,7 +227,7 @@ static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen, int *p
if
(
TDB_PAGE_TOTAL_CELLS
(
pCur
->
pPage
)
==
0
)
{
// Current page is empty
ASSERT
(
TDB_FLAG_IS
(
TDB_PAGE_FLAGS
(
pCur
->
pPage
),
TDB_BTREE_ROOT
|
TDB_BTREE_LEAF
));
//
ASSERT(TDB_FLAG_IS(TDB_PAGE_FLAGS(pCur->pPage), TDB_BTREE_ROOT | TDB_BTREE_LEAF));
return
0
;
}
...
...
@@ -265,7 +272,7 @@ static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen, int *p
}
// Move downward or break
u16
flags
=
TDB_PAGE_FLAGS
(
pPage
);
u16
flags
=
0
;
// TODO:
TDB_PAGE_FLAGS(pPage);
u8
leaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
if
(
leaf
)
{
pCur
->
idx
=
midx
;
...
...
@@ -279,7 +286,7 @@ static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen, int *p
if
(
midx
==
nCells
-
1
)
{
/* Move to right-most child */
pCur
->
idx
=
midx
+
1
;
tdbBtCursorMoveToChild
(
pCur
,
((
SBtPageHdr
*
)(
pPage
->
pAmHdr
))
->
rChild
);
//
tdbBtCursorMoveToChild(pCur, ((SBtPageHdr *)(pPage->pAmHdr))->rChild);
}
else
{
// TODO: reset cd as uninitialized
pCur
->
idx
=
midx
+
1
;
...
...
@@ -388,12 +395,12 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) {
ASSERT
(
0
);
// TODO: here has problem
flags
=
TDB_PAGE_FLAGS
(
pPage
);
flags
=
0
;
// TODO:
TDB_PAGE_FLAGS(pPage);
isLeaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
if
(
isLeaf
)
{
szAmHdr
=
0
;
szAmHdr
=
sizeof
(
SLeafHdr
)
;
}
else
{
szAmHdr
=
sizeof
(
S
BtPage
Hdr
);
szAmHdr
=
sizeof
(
S
Int
Hdr
);
}
pPage
->
xCellSize
=
NULL
;
// TODO
...
...
@@ -427,14 +434,14 @@ static int tdbBtreeZeroPage(SPage *pPage, void *arg) {
isLeaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
if
(
isLeaf
)
{
szAmHdr
=
0
;
szAmHdr
=
sizeof
(
SLeafHdr
)
;
}
else
{
szAmHdr
=
sizeof
(
S
BtPage
Hdr
);
szAmHdr
=
sizeof
(
S
Int
Hdr
);
}
pPage
->
xCellSize
=
NULL
;
// TODO
tdbPageZero
(
pPage
,
szAmHdr
);
TDB_PAGE_FLAGS_SET
(
pPage
,
flags
);
//
TDB_PAGE_FLAGS_SET(pPage, flags);
if
(
isLeaf
)
{
pPage
->
kLen
=
pBt
->
keyLen
;
...
...
@@ -522,7 +529,7 @@ static int tdbBtreeBalanceDeeper(SBTree *pBt, SPage *pRoot, SPage **ppChild) {
return
-
1
;
}
((
SBtPageHdr
*
)
pRoot
->
pAmHdr
)[
0
].
rChild
=
pgnoChild
;
// TODO:
((SBtPageHdr *)pRoot->pAmHdr)[0].rChild = pgnoChild;
*
ppChild
=
pChild
;
return
0
;
...
...
@@ -566,7 +573,7 @@ static int tdbBtreeBalanceStep1(SBtreeBalanceHelper *pBlh) {
i
=
pBlh
->
nOld
-
1
;
if
(
idxStart
+
i
==
nCells
)
{
pgno
=
((
SBtPageHdr
*
)(
pParent
->
pAmHdr
))[
0
].
rChild
;
//
pgno = ((SBtPageHdr *)(pParent->pAmHdr))[0].rChild;
}
else
{
pCell
=
tdbPageGetCell
(
pParent
,
idxStart
+
i
);
// TODO: no need to decode the payload part, and even the kLen, vLen part
...
...
@@ -676,7 +683,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
int
ret
;
SBtreeBalanceHelper
blh
;
ASSERT
(
!
TDB_BTREE_PA
GE_IS_LEAF
(
TDB_PAGE_FLAGS
(
pParent
)));
// ASSERT(!TDB_BTREE_P
GE_IS_LEAF(TDB_PAGE_FLAGS(pParent)));
blh
.
pBt
=
pBt
;
blh
.
pParent
=
pParent
;
...
...
@@ -748,7 +755,7 @@ static int tdbBtreeBalance(SBtCursor *pCur) {
for
(;;)
{
iPage
=
pCur
->
iPage
;
pPage
=
pCur
->
pPage
;
flags
=
TDB_PAGE_FLAGS
(
pPage
);
flags
=
0
;
// TODO:
TDB_PAGE_FLAGS(pPage);
leaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
root
=
TDB_BTREE_PAGE_IS_ROOT
(
flags
);
...
...
@@ -842,7 +849,7 @@ static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const vo
nPayload
=
0
;
nHeader
=
0
;
flags
=
TDB_PAGE_FLAGS
(
pPage
);
flags
=
0
;
// TODO:
TDB_PAGE_FLAGS(pPage);
leaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
// 1. Encode Header part
...
...
@@ -911,7 +918,7 @@ static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pD
int
ret
;
nHeader
=
0
;
flags
=
TDB_PAGE_FLAGS
(
pPage
);
flags
=
0
;
// TODO:
TDB_PAGE_FLAGS(pPage);
leaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
// Clear the state of decoder
...
...
source/libs/tdb/src/inc/tdbPage.h
浏览文件 @
4e8f8445
...
...
@@ -27,9 +27,11 @@ typedef struct {
int
szOffset
;
int
szPageHdr
;
int
szFreeCell
;
#if 0
// flags
u16 (*getFlags)(SPage *);
void (*setFlags)(SPage *, u16);
#endif
// cell number
int
(
*
getCellNum
)(
SPage
*
);
void
(
*
setCellNum
)(
SPage
*
,
int
);
...
...
@@ -79,9 +81,11 @@ struct SPage {
TDB_PCACHE_PAGE
};
#if 0
/* For page */
#define TDB_PAGE_FLAGS(pPage) (*(pPage)->pPageMethods->getFlags)(pPage)
#define TDB_PAGE_FLAGS_SET(pPage, FLAGS) (*(pPage)->pPageMethods->setFlags)(pPage, FLAGS)
#endif
// For page lock
#define P_LOCK_SUCC 0
...
...
source/libs/tdb/src/page/tdbPage.c
浏览文件 @
4e8f8445
...
...
@@ -399,9 +399,11 @@ typedef struct __attribute__((__packed__)) {
u16
nxOffset
;
}
SFreeCell
;
#if 0
// flags
static inline u16 getPageFlags(SPage *pPage) { return ((SPageHdr *)(pPage->pPageHdr))[0].flags; }
static inline void setPageFlags(SPage *pPage, u16 flags) { ((SPageHdr *)(pPage->pPageHdr))[0].flags = flags; }
#endif
// cellNum
static
inline
int
getPageCellNum
(
SPage
*
pPage
)
{
return
((
SPageHdr
*
)(
pPage
->
pPageHdr
))[
0
].
cellNum
;
}
...
...
@@ -456,11 +458,13 @@ static inline void setPageFreeCellInfo(SCell *pCell, int szCell, int nxOffset) {
}
SPageMethods
pageMethods
=
{
2
,
// szOffset
sizeof
(
SPageHdr
),
// szPageHdr
sizeof
(
SFreeCell
),
// szFreeCell
2
,
// szOffset
sizeof
(
SPageHdr
),
// szPageHdr
sizeof
(
SFreeCell
),
// szFreeCell
#if 0
getPageFlags, // getPageFlags
setPageFlags, // setFlagsp
#endif
getPageCellNum
,
// getCellNum
setPageCellNum
,
// setCellNum
getPageCellBody
,
// getCellBody
...
...
source/libs/tdb/src/page/tdbPageL.c
浏览文件 @
4e8f8445
...
...
@@ -28,9 +28,11 @@ typedef struct __attribute__((__packed__)) {
u8
nxOffset
[
3
];
}
SFreeCellL
;
#if 0
// flags
static inline u16 getPageFlags(SPage *pPage) { return ((SPageHdrL *)(pPage->pPageHdr))[0].flags; }
static inline void setPageFlags(SPage *pPage, u16 flags) { ((SPageHdrL *)(pPage->pPageHdr))[0].flags = flags; }
#endif
// cellNum
static
inline
int
getPageCellNum
(
SPage
*
pPage
)
{
return
TDB_GET_U24
(((
SPageHdrL
*
)(
pPage
->
pPageHdr
))[
0
].
cellNum
);
}
...
...
@@ -80,11 +82,13 @@ static inline void setPageFreeCellInfo(SCell *pCell, int szCell, int nxOffset) {
}
SPageMethods
pageLargeMethods
=
{
3
,
// szOffset
sizeof
(
SPageHdrL
),
// szPageHdr
sizeof
(
SFreeCellL
),
// szFreeCell
3
,
// szOffset
sizeof
(
SPageHdrL
),
// szPageHdr
sizeof
(
SFreeCellL
),
// szFreeCell
#if 0
getPageFlags, // getPageFlags
setPageFlags, // setFlagsp
#endif
getPageCellNum
,
// getCellNum
setPageCellNum
,
// setCellNum
getPageCellBody
,
// getCellBody
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录