Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cfa666f2
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看板
提交
cfa666f2
编写于
8月 25, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
ffa58120
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
37 addition
and
29 deletion
+37
-29
include/util/trbtree.h
include/util/trbtree.h
+5
-5
source/dnode/vnode/src/tsdb/tsdbMerge.c
source/dnode/vnode/src/tsdb/tsdbMerge.c
+13
-5
source/util/src/trbtree.c
source/util/src/trbtree.c
+19
-19
未找到文件。
include/util/trbtree.h
浏览文件 @
cfa666f2
...
...
@@ -30,7 +30,7 @@ typedef int32_t (*tRBTreeCmprFn)(const void *, const void *);
// SRBTree =============================================
#define tRBTreeCreate(compare) \
(SRBTree) { .cmprFn = (compare), .root
Node = NULL, .minNode = NULL, .maxNode
= NULL }
(SRBTree) { .cmprFn = (compare), .root
= NULL, .min = NULL, .max
= NULL }
SRBTreeNode
*
tRBTreePut
(
SRBTree
*
pTree
,
SRBTreeNode
*
pNew
);
void
tRBTreeDrop
(
SRBTree
*
pTree
,
SRBTreeNode
*
pNode
);
...
...
@@ -39,7 +39,7 @@ SRBTreeNode *tRBTreeGet(SRBTree *pTree, void *pKey);
// SRBTreeIter =============================================
#define tRBTreeIterCreate(tree, ascend) \
(SRBTreeIter) { .asc = (ascend), .pTree = (tree), .pNode = (ascend) ? (tree)->min
Node : (tree)->maxNode
}
(SRBTreeIter) { .asc = (ascend), .pTree = (tree), .pNode = (ascend) ? (tree)->min
: (tree)->max
}
SRBTreeNode
*
tRBTreeIterNext
(
SRBTreeIter
*
pIter
);
...
...
@@ -55,9 +55,9 @@ struct SRBTreeNode {
struct
SRBTree
{
tRBTreeCmprFn
cmprFn
;
SRBTreeNode
*
root
Node
;
SRBTreeNode
*
min
Node
;
SRBTreeNode
*
max
Node
;
SRBTreeNode
*
root
;
SRBTreeNode
*
min
;
SRBTreeNode
*
max
;
};
struct
SRBTreeIter
{
...
...
source/dnode/vnode/src/tsdb/tsdbMerge.c
浏览文件 @
cfa666f2
...
...
@@ -90,8 +90,8 @@ static int32_t tDataMergeNext(SDataMerger *pMerger, SRowInfo **ppInfo) {
}
}
if
(
pMerger
->
pNode
&&
pMerger
->
rbt
.
min
Node
)
{
int32_t
c
=
tRowInfoCmprFn
(
pMerger
->
pNode
->
payload
,
pMerger
->
rbt
.
min
Node
->
payload
);
if
(
pMerger
->
pNode
&&
pMerger
->
rbt
.
min
)
{
int32_t
c
=
tRowInfoCmprFn
(
pMerger
->
pNode
->
payload
,
pMerger
->
rbt
.
min
->
payload
);
if
(
c
>
0
)
{
pMerger
->
pNode
=
tRBTreePut
(
&
pMerger
->
rbt
,
pMerger
->
pNode
);
ASSERT
(
pMerger
->
pNode
);
...
...
@@ -103,7 +103,7 @@ static int32_t tDataMergeNext(SDataMerger *pMerger, SRowInfo **ppInfo) {
}
if
(
pMerger
->
pNode
==
NULL
)
{
pMerger
->
pNode
=
pMerger
->
rbt
.
min
Node
;
pMerger
->
pNode
=
pMerger
->
rbt
.
min
;
if
(
pMerger
->
pNode
)
{
tRBTreeDrop
(
&
pMerger
->
rbt
,
pMerger
->
pNode
);
}
...
...
@@ -128,6 +128,7 @@ typedef struct {
struct
{
SDataFReader
*
pReader
;
SArray
*
aBlockIdx
;
SDataMerger
merger
;
SArray
*
aBlockL
[
TSDB_MAX_LAST_FILE
];
}
dReader
;
struct
{
...
...
@@ -222,9 +223,16 @@ static int32_t tsdbMergeFileData(STsdbMerger *pMerger, SDFileSet *pSet) {
if
(
code
)
goto
_err
;
// impl
SRowInfo
rInfo
=
{.
suid
=
INT64_MIN
};
SRowInfo
*
pInfo
;
while
(
true
)
{
if
(
1
)
break
;
// TODO
code
=
tDataMergeNext
(
&
pMerger
->
dReader
.
merger
,
&
pInfo
);
if
(
code
)
goto
_err
;
if
(
pInfo
==
NULL
)
break
;
ASSERT
(
tRowInfoCmprFn
(
pInfo
,
&
rInfo
)
>
0
);
rInfo
=
*
pInfo
;
}
// end
...
...
source/util/src/trbtree.c
浏览文件 @
cfa666f2
...
...
@@ -26,7 +26,7 @@ static void tRBTreeRotateLeft(SRBTree *pTree, SRBTreeNode *x) {
}
y
->
parent
=
x
->
parent
;
if
(
x
->
parent
==
NULL
)
{
pTree
->
root
Node
=
y
;
pTree
->
root
=
y
;
}
else
if
(
x
==
x
->
parent
->
left
)
{
x
->
parent
->
left
=
y
;
}
else
{
...
...
@@ -44,7 +44,7 @@ static void tRBTreeRotateRight(SRBTree *pTree, SRBTreeNode *x) {
}
y
->
parent
=
x
->
parent
;
if
(
x
->
parent
==
NULL
)
{
pTree
->
root
Node
=
y
;
pTree
->
root
=
y
;
}
else
if
(
x
==
x
->
parent
->
left
)
{
x
->
parent
->
left
=
y
;
}
else
{
...
...
@@ -109,11 +109,11 @@ SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *pNew) {
pNew
->
color
=
RED
;
// insert
if
(
pTree
->
root
Node
==
NULL
)
{
if
(
pTree
->
root
==
NULL
)
{
pNew
->
parent
=
NULL
;
pTree
->
root
Node
=
pNew
;
pTree
->
root
=
pNew
;
}
else
{
SRBTreeNode
*
pNode
=
pTree
->
root
Node
;
SRBTreeNode
*
pNode
=
pTree
->
root
;
while
(
true
)
{
ASSERT
(
pNode
);
...
...
@@ -181,14 +181,14 @@ SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *pNew) {
}
}
}
pTree
->
root
Node
->
color
=
BLACK
;
pTree
->
root
->
color
=
BLACK
;
// update min/max node
if
(
pTree
->
min
Node
==
NULL
||
pTree
->
cmprFn
(
pTree
->
minNode
->
payload
,
pNew
->
payload
)
>
0
)
{
pTree
->
min
Node
=
pNew
;
if
(
pTree
->
min
==
NULL
||
pTree
->
cmprFn
(
pTree
->
min
->
payload
,
pNew
->
payload
)
>
0
)
{
pTree
->
min
=
pNew
;
}
if
(
pTree
->
max
Node
==
NULL
||
pTree
->
cmprFn
(
pTree
->
maxNode
->
payload
,
pNew
->
payload
)
<
0
)
{
pTree
->
max
Node
=
pNew
;
if
(
pTree
->
max
==
NULL
||
pTree
->
cmprFn
(
pTree
->
max
->
payload
,
pNew
->
payload
)
<
0
)
{
pTree
->
max
=
pNew
;
}
return
pNew
;
...
...
@@ -196,7 +196,7 @@ SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *pNew) {
static
void
tRBTreeTransplant
(
SRBTree
*
pTree
,
SRBTreeNode
*
u
,
SRBTreeNode
*
v
)
{
if
(
u
->
parent
==
NULL
)
{
pTree
->
root
Node
=
v
;
pTree
->
root
=
v
;
}
else
if
(
u
==
u
->
parent
->
left
)
{
u
->
parent
->
left
=
v
;
}
else
{
...
...
@@ -208,7 +208,7 @@ static void tRBTreeTransplant(SRBTree *pTree, SRBTreeNode *u, SRBTreeNode *v) {
}
static
void
tRBTreeDropFixup
(
SRBTree
*
t
,
SRBTreeNode
*
x
)
{
while
(
x
!=
t
->
root
Node
&&
x
->
color
==
BLACK
)
{
while
(
x
!=
t
->
root
&&
x
->
color
==
BLACK
)
{
if
(
x
==
x
->
parent
->
left
)
{
SRBTreeNode
*
w
=
x
->
parent
->
right
;
if
(
RBTREE_NODE_COLOR
(
w
)
==
RED
)
{
...
...
@@ -231,7 +231,7 @@ static void tRBTreeDropFixup(SRBTree *t, SRBTreeNode *x) {
x
->
parent
->
color
=
BLACK
;
w
->
right
->
color
=
BLACK
;
tRBTreeRotateLeft
(
t
,
x
->
parent
);
x
=
t
->
root
Node
;
x
=
t
->
root
;
}
}
else
{
SRBTreeNode
*
w
=
x
->
parent
->
left
;
...
...
@@ -255,7 +255,7 @@ static void tRBTreeDropFixup(SRBTree *t, SRBTreeNode *x) {
x
->
parent
->
color
=
BLACK
;
w
->
left
->
color
=
BLACK
;
tRBTreeRotateRight
(
t
,
x
->
parent
);
x
=
t
->
root
Node
;
x
=
t
->
root
;
}
}
}
...
...
@@ -264,11 +264,11 @@ static void tRBTreeDropFixup(SRBTree *t, SRBTreeNode *x) {
void
tRBTreeDrop
(
SRBTree
*
t
,
SRBTreeNode
*
z
)
{
// update min/max node
if
(
t
->
min
Node
==
z
)
{
t
->
min
Node
=
tRBTreeSuccessor
(
t
->
minNode
);
if
(
t
->
min
==
z
)
{
t
->
min
=
tRBTreeSuccessor
(
t
->
min
);
}
if
(
t
->
max
Node
==
z
)
{
t
->
max
Node
=
tRBTreePredecessor
(
t
->
maxNode
);
if
(
t
->
max
==
z
)
{
t
->
max
=
tRBTreePredecessor
(
t
->
max
);
}
// drop impl
...
...
@@ -316,7 +316,7 @@ SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey) {
}
SRBTreeNode
*
tRBTreeGet
(
SRBTree
*
pTree
,
void
*
pKey
)
{
SRBTreeNode
*
pNode
=
pTree
->
root
Node
;
SRBTreeNode
*
pNode
=
pTree
->
root
;
while
(
pNode
)
{
int32_t
c
=
pTree
->
cmprFn
(
pKey
,
pNode
->
payload
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录