Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0a6be10f
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看板
提交
0a6be10f
编写于
3月 21, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more tdb
上级
a84155b9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
26 deletion
+26
-26
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+20
-22
source/libs/tdb/src/inc/tdbPage.h
source/libs/tdb/src/inc/tdbPage.h
+2
-2
source/libs/tdb/src/page/tdbPage.c
source/libs/tdb/src/page/tdbPage.c
+4
-2
未找到文件。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
0a6be10f
...
...
@@ -39,8 +39,10 @@ struct SBTree {
u8
*
pTmp
;
};
#define TDB_BTREE_PAGE_COMMON_HDR u8 flags;
#define TDB_BTREE_PAGE_FLAGS(PAGE) (PAGE)->pAmHdr[0]
#define TDB_BTREE_PAGE_COMMON_HDR u8 flags;
#define TDB_BTREE_PAGE_GET_FLAGS(PAGE) (PAGE)->pAmHdr[0]
#define TDB_BTREE_PAGE_SET_FLAGS(PAGE, flags) ((PAGE)->pAmHdr[0] = (flags))
typedef
struct
__attribute__
((
__packed__
))
{
TDB_BTREE_PAGE_COMMON_HDR
...
...
@@ -274,8 +276,8 @@ static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen, int *p
}
// Move downward or break
u
16
flags
=
0
;
// TODO: TDB_PAGE
_FLAGS(pPage);
u8
leaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
u
8
flags
=
TDB_BTREE_PAGE_GET
_FLAGS
(
pPage
);
u8
leaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
if
(
leaf
)
{
pCur
->
idx
=
midx
;
*
pCRst
=
c
;
...
...
@@ -388,25 +390,23 @@ static int tdbBtreeOpenImpl(SBTree *pBt) {
static
int
tdbBtreeInitPage
(
SPage
*
pPage
,
void
*
arg
)
{
SBTree
*
pBt
;
u
16
flags
;
u
8
flags
;
u8
isLeaf
;
u8
szAmHdr
;
pBt
=
(
SBTree
*
)
arg
;
pBt
=
((
SBtreeInitPageArg
*
)
arg
)
->
pBt
;
flags
=
((
SBtreeInitPageArg
*
)
arg
)
->
flags
;
isLeaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
ASSERT
(
0
);
ASSERT
(
flags
==
TDB_BTREE_PAGE_GET_FLAGS
(
pPage
)
);
// TODO: here has problem
flags
=
0
;
// TODO: TDB_PAGE_FLAGS(pPage);
isLeaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
if
(
isLeaf
)
{
szAmHdr
=
sizeof
(
SLeafHdr
);
}
else
{
szAmHdr
=
sizeof
(
SIntHdr
);
}
pPage
->
xCellSize
=
NULL
;
// TODO
tdbPageInit
(
pPage
,
szAmHdr
);
tdbPageInit
(
pPage
,
szAmHdr
,
tdbBtreeCellSize
);
TDB_BTREE_ASSERT_FLAG
(
flags
);
...
...
@@ -426,7 +426,7 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) {
}
static
int
tdbBtreeZeroPage
(
SPage
*
pPage
,
void
*
arg
)
{
u
16
flags
;
u
8
flags
;
SBTree
*
pBt
;
u8
isLeaf
;
u8
szAmHdr
;
...
...
@@ -440,10 +440,8 @@ static int tdbBtreeZeroPage(SPage *pPage, void *arg) {
}
else
{
szAmHdr
=
sizeof
(
SIntHdr
);
}
pPage
->
xCellSize
=
NULL
;
// TODO
tdbPageZero
(
pPage
,
szAmHdr
);
// TDB_PAGE_FLAGS_SET(pPage, flags);
tdbPageZero
(
pPage
,
szAmHdr
,
tdbBtreeCellSize
);
if
(
isLeaf
)
{
pPage
->
kLen
=
pBt
->
keyLen
;
...
...
@@ -749,7 +747,7 @@ static int tdbBtreeBalance(SBtCursor *pCur) {
SPage
*
pParent
;
SPage
*
pPage
;
int
ret
;
u
16
flags
;
u
8
flags
;
u8
leaf
;
u8
root
;
...
...
@@ -757,7 +755,7 @@ static int tdbBtreeBalance(SBtCursor *pCur) {
for
(;;)
{
iPage
=
pCur
->
iPage
;
pPage
=
pCur
->
pPage
;
flags
=
0
;
// TODO: TDB_PAGE
_FLAGS(pPage);
flags
=
TDB_BTREE_PAGE_GET
_FLAGS
(
pPage
);
leaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
root
=
TDB_BTREE_PAGE_IS_ROOT
(
flags
);
...
...
@@ -840,7 +838,7 @@ static int tdbBtreeEncodePayload(SPage *pPage, u8 *pPayload, const void *pKey, i
static
int
tdbBtreeEncodeCell
(
SPage
*
pPage
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
,
SCell
*
pCell
,
int
*
szCell
)
{
u
16
flags
;
u
8
flags
;
u8
leaf
;
int
nHeader
;
int
nPayload
;
...
...
@@ -851,7 +849,7 @@ static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const vo
nPayload
=
0
;
nHeader
=
0
;
flags
=
0
;
// TODO: TDB_PAGE
_FLAGS(pPage);
flags
=
TDB_BTREE_PAGE_GET
_FLAGS
(
pPage
);
leaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
// 1. Encode Header part
...
...
@@ -914,13 +912,13 @@ static int tdbBtreeDecodePayload(SPage *pPage, const u8 *pPayload, SCellDecoder
}
static
int
tdbBtreeDecodeCell
(
SPage
*
pPage
,
const
SCell
*
pCell
,
SCellDecoder
*
pDecoder
)
{
u
16
flags
;
u
8
flags
;
u8
leaf
;
int
nHeader
;
int
ret
;
nHeader
=
0
;
flags
=
0
;
// TODO: TDB_PAGE
_FLAGS(pPage);
flags
=
TDB_BTREE_PAGE_GET
_FLAGS
(
pPage
);
leaf
=
TDB_BTREE_PAGE_IS_LEAF
(
flags
);
// Clear the state of decoder
...
...
source/libs/tdb/src/inc/tdbPage.h
浏览文件 @
0a6be10f
...
...
@@ -103,8 +103,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
,
u8
szAmHdr
);
void
tdbPageInit
(
SPage
*
pPage
,
u8
szAmHdr
);
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
);
int
tdbPageDropCell
(
SPage
*
pPage
,
int
idx
);
...
...
source/libs/tdb/src/page/tdbPage.c
浏览文件 @
0a6be10f
...
...
@@ -79,7 +79,7 @@ int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg)
return
0
;
}
void
tdbPageZero
(
SPage
*
pPage
,
u8
szAmHdr
)
{
void
tdbPageZero
(
SPage
*
pPage
,
u8
szAmHdr
,
int
(
*
xCellSize
)(
const
SPage
*
,
SCell
*
)
)
{
pPage
->
pAmHdr
=
pPage
->
pData
;
pPage
->
pPageHdr
=
pPage
->
pAmHdr
+
szAmHdr
;
TDB_PAGE_NCELLS_SET
(
pPage
,
0
);
...
...
@@ -91,11 +91,12 @@ void tdbPageZero(SPage *pPage, u8 szAmHdr) {
pPage
->
pFreeEnd
=
pPage
->
pData
+
TDB_PAGE_CCELLS
(
pPage
);
pPage
->
pPageFtr
=
(
SPageFtr
*
)(
pPage
->
pData
+
pPage
->
pageSize
-
sizeof
(
SPageFtr
));
pPage
->
nOverflow
=
0
;
pPage
->
xCellSize
=
xCellSize
;
ASSERT
((
u8
*
)
pPage
->
pPageFtr
==
pPage
->
pFreeEnd
);
}
void
tdbPageInit
(
SPage
*
pPage
,
u8
szAmHdr
)
{
void
tdbPageInit
(
SPage
*
pPage
,
u8
szAmHdr
,
int
(
*
xCellSize
)(
const
SPage
*
,
SCell
*
)
)
{
pPage
->
pAmHdr
=
pPage
->
pData
;
pPage
->
pPageHdr
=
pPage
->
pAmHdr
+
szAmHdr
;
pPage
->
pCellIdx
=
pPage
->
pPageHdr
+
TDB_PAGE_HDR_SIZE
(
pPage
);
...
...
@@ -103,6 +104,7 @@ void tdbPageInit(SPage *pPage, u8 szAmHdr) {
pPage
->
pFreeEnd
=
pPage
->
pData
+
TDB_PAGE_CCELLS
(
pPage
);
pPage
->
pPageFtr
=
(
SPageFtr
*
)(
pPage
->
pData
+
pPage
->
pageSize
-
sizeof
(
SPageFtr
));
pPage
->
nOverflow
=
0
;
pPage
->
xCellSize
=
xCellSize
;
ASSERT
(
pPage
->
pFreeEnd
>=
pPage
->
pFreeStart
);
ASSERT
(
pPage
->
pFreeEnd
-
pPage
->
pFreeStart
<=
TDB_PAGE_NFREE
(
pPage
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录