Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a20640f0
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看板
提交
a20640f0
编写于
12月 29, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix/TD-21210' of
https://github.com/taosdata/TDengine
into fix/TD-21210
上级
1269d20c
858e5321
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
14 deletion
+42
-14
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+42
-14
未找到文件。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
a20640f0
...
...
@@ -374,7 +374,9 @@ static int tdbDefaultKeyCmprFn(const void *pKey1, int keyLen1, const void *pKey2
int
mlen
;
int
cret
;
ASSERT
(
keyLen1
>
0
&&
keyLen2
>
0
&&
pKey1
!=
NULL
&&
pKey2
!=
NULL
);
if
(
ASSERT
(
keyLen1
>
0
&&
keyLen2
>
0
&&
pKey1
!=
NULL
&&
pKey2
!=
NULL
))
{
// -1 is less than
}
mlen
=
keyLen1
<
keyLen2
?
keyLen1
:
keyLen2
;
cret
=
memcmp
(
pKey1
,
pKey2
,
mlen
);
...
...
@@ -525,11 +527,15 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
nOlds
=
3
;
}
for
(
int
i
=
0
;
i
<
nOlds
;
i
++
)
{
ASSERT
(
sIdx
+
i
<=
nCells
);
if
(
ASSERT
(
sIdx
+
i
<=
nCells
))
{
return
-
1
;
}
SPgno
pgno
;
if
(
sIdx
+
i
==
nCells
)
{
ASSERT
(
!
TDB_BTREE_PAGE_IS_LEAF
(
pParent
));
if
(
ASSERT
(
!
TDB_BTREE_PAGE_IS_LEAF
(
pParent
)))
{
return
-
1
;
}
pgno
=
((
SIntHdr
*
)(
pParent
->
pData
))
->
pgno
;
}
else
{
pCell
=
tdbPageGetCell
(
pParent
,
sIdx
+
i
);
...
...
@@ -658,7 +664,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
szRCell
=
tdbBtreeCellSize
(
pPage
,
pCell
,
0
,
NULL
,
NULL
);
}
ASSERT
(
infoNews
[
iNew
-
1
].
cnt
>
0
);
if
(
ASSERT
(
infoNews
[
iNew
-
1
].
cnt
>
0
))
{
return
-
1
;
}
if
(
infoNews
[
iNew
].
size
+
szRCell
>=
infoNews
[
iNew
-
1
].
size
-
szRCell
)
{
break
;
...
...
@@ -746,8 +754,12 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
pCell
=
tdbPageGetCell
(
pPage
,
oIdx
);
szCell
=
tdbBtreeCellSize
(
pPage
,
pCell
,
0
,
NULL
,
NULL
);
ASSERT
(
nNewCells
<=
infoNews
[
iNew
].
cnt
);
ASSERT
(
iNew
<
nNews
);
if
(
ASSERT
(
nNewCells
<=
infoNews
[
iNew
].
cnt
))
{
return
-
1
;
}
if
(
ASSERT
(
iNew
<
nNews
))
{
return
-
1
;
}
if
(
nNewCells
<
infoNews
[
iNew
].
cnt
)
{
tdbPageInsertCell
(
pNews
[
iNew
],
nNewCells
,
pCell
,
szCell
,
0
);
...
...
@@ -786,14 +798,20 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
}
}
}
else
{
ASSERT
(
childNotLeaf
);
ASSERT
(
iNew
<
nNews
-
1
);
if
(
ASSERT
(
childNotLeaf
))
{
return
-
1
;
}
if
(
ASSERT
(
iNew
<
nNews
-
1
))
{
return
-
1
;
}
// set current new page right-most child
((
SIntHdr
*
)
pNews
[
iNew
]
->
pData
)
->
pgno
=
((
SPgno
*
)
pCell
)[
0
];
// insert to parent as divider cell
ASSERT
(
iNew
<
nNews
-
1
);
if
(
ASSERT
(
iNew
<
nNews
-
1
))
{
return
-
1
;
}
((
SPgno
*
)
pCell
)[
0
]
=
TDB_PAGE_PGNO
(
pNews
[
iNew
]);
tdbPageInsertCell
(
pParent
,
sIdx
++
,
pCell
,
szCell
,
0
);
...
...
@@ -808,7 +826,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
}
if
(
childNotLeaf
)
{
ASSERT
(
TDB_PAGE_TOTAL_CELLS
(
pNews
[
nNews
-
1
])
==
infoNews
[
nNews
-
1
].
cnt
);
if
(
ASSERT
(
TDB_PAGE_TOTAL_CELLS
(
pNews
[
nNews
-
1
])
==
infoNews
[
nNews
-
1
].
cnt
))
{
return
-
1
;
}
((
SIntHdr
*
)(
pNews
[
nNews
-
1
]
->
pData
))
->
pgno
=
rPgno
;
SIntHdr
*
pIntHdr
=
(
SIntHdr
*
)
pParent
->
pData
;
...
...
@@ -998,7 +1018,9 @@ static int tdbBtreeEncodePayload(SPage *pPage, SCell *pCell, int nHeader, const
nLeft
-=
kLen
;
// pack partial val to local if any space left
if
(
nLocal
>
nHeader
+
kLen
+
sizeof
(
SPgno
))
{
ASSERT
(
pVal
!=
NULL
&&
vLen
!=
0
);
if
(
ASSERT
(
pVal
!=
NULL
&&
vLen
!=
0
))
{
return
-
1
;
}
memcpy
(
pCell
+
nHeader
+
kLen
,
pVal
,
nLocal
-
nHeader
-
kLen
-
sizeof
(
SPgno
));
nLeft
-=
nLocal
-
nHeader
-
kLen
-
sizeof
(
SPgno
);
}
...
...
@@ -1160,9 +1182,15 @@ static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const vo
int
nPayload
;
int
ret
;
ASSERT
(
pPage
->
kLen
==
TDB_VARIANT_LEN
||
pPage
->
kLen
==
kLen
);
ASSERT
(
pPage
->
vLen
==
TDB_VARIANT_LEN
||
pPage
->
vLen
==
vLen
);
ASSERT
(
pKey
!=
NULL
&&
kLen
>
0
);
if
(
ASSERT
(
pPage
->
kLen
==
TDB_VARIANT_LEN
||
pPage
->
kLen
==
kLen
))
{
return
-
1
;
}
if
(
ASSERT
(
pPage
->
vLen
==
TDB_VARIANT_LEN
||
pPage
->
vLen
==
vLen
))
{
return
-
1
;
}
if
(
ASSERT
(
pKey
!=
NULL
&&
kLen
>
0
))
{
return
-
1
;
}
nPayload
=
0
;
nHeader
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录