Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
86e230cf
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
86e230cf
编写于
2月 09, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] opt perf.
上级
ec4e6fe7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
49 addition
and
37 deletion
+49
-37
include/util/tlosertree.h
include/util/tlosertree.h
+8
-4
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+1
-1
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+31
-19
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+7
-0
source/util/src/tlosertree.c
source/util/src/tlosertree.c
+1
-12
未找到文件。
include/util/tlosertree.h
浏览文件 @
86e230cf
...
...
@@ -22,6 +22,11 @@ extern "C" {
typedef
int
(
*
__merge_compare_fn_t
)(
const
void
*
,
const
void
*
,
void
*
param
);
typedef
struct
STreeNode
{
int32_t
index
;
void
*
pData
;
// TODO remove it?
}
STreeNode
;
typedef
struct
SMultiwayMergeTreeInfo
{
int32_t
numOfSources
;
int32_t
totalSources
;
...
...
@@ -30,6 +35,9 @@ typedef struct SMultiwayMergeTreeInfo {
struct
STreeNode
*
pNode
;
}
SMultiwayMergeTreeInfo
;
#define tMergeTreeGetChosenIndex(t_) ((t_)->pNode[0].index)
#define tMergeTreeGetAdjustIndex(t_) (tMergeTreeGetChosenIndex(t_) + (t_)->numOfSources)
int32_t
tMergeTreeCreate
(
SMultiwayMergeTreeInfo
**
pTree
,
uint32_t
numOfEntries
,
void
*
param
,
__merge_compare_fn_t
compareFn
);
void
tMergeTreeDestroy
(
SMultiwayMergeTreeInfo
*
pTree
);
...
...
@@ -40,10 +48,6 @@ void tMergeTreeRebuild(SMultiwayMergeTreeInfo *pTree);
void
tMergeTreePrint
(
const
SMultiwayMergeTreeInfo
*
pTree
);
int32_t
tMergeTreeGetChosenIndex
(
const
SMultiwayMergeTreeInfo
*
pTree
);
int32_t
tMergeTreeAdjustIndex
(
const
SMultiwayMergeTreeInfo
*
pTree
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
86e230cf
...
...
@@ -2192,7 +2192,7 @@ static int32_t createDataBlocksInfo(STsdbReadHandle* pTsdbReadHandle, int32_t nu
sup
.
blockIndexArray
[
pos
]
=
sup
.
numOfBlocksPerTable
[
pos
]
+
1
;
}
tMergeTreeAdjust
(
pTree
,
tMergeTreeAdjustIndex
(
pTree
));
tMergeTreeAdjust
(
pTree
,
tMergeTree
Get
AdjustIndex
(
pTree
));
}
/*
...
...
source/libs/executor/src/executil.c
浏览文件 @
86e230cf
...
...
@@ -612,7 +612,7 @@ static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv
}
}
tMergeTreeAdjust
(
pTree
,
tMergeTreeAdjustIndex
(
pTree
));
tMergeTreeAdjust
(
pTree
,
tMergeTree
Get
AdjustIndex
(
pTree
));
}
int64_t
endt
=
taosGetTimestampMs
();
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
86e230cf
...
...
@@ -5548,31 +5548,39 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
int32_t
pRightIdx
=
*
(
int32_t
*
)
pRight
;
SMsortComparParam
*
pParam
=
(
SMsortComparParam
*
)
param
;
SExternalMemSource
**
pSources
=
pParam
->
pSources
;
SArray
*
pInfo
=
pParam
->
orderInfo
;
SExternalMemSource
*
pLeftSource
=
pParam
->
pSources
[
pLeftIdx
];
SExternalMemSource
*
pRightSource
=
pParam
->
pSources
[
pRightIdx
];
// this input is exhausted, set the special value to denote this
if
(
p
Sources
[
pLeftIdx
]
->
rowIndex
==
-
1
)
{
if
(
p
LeftSource
->
rowIndex
==
-
1
)
{
return
1
;
}
if
(
p
Sources
[
pRightIdx
]
->
rowIndex
==
-
1
)
{
if
(
p
RightSource
->
rowIndex
==
-
1
)
{
return
-
1
;
}
SSDataBlock
*
pLeftBlock
=
p
Sources
[
pLeftIdx
]
->
pBlock
;
SSDataBlock
*
pRightBlock
=
p
Sources
[
pRightIdx
]
->
pBlock
;
SSDataBlock
*
pLeftBlock
=
p
LeftSource
->
pBlock
;
SSDataBlock
*
pRightBlock
=
p
RightSource
->
pBlock
;
size_t
num
=
taosArrayGetSize
(
pInfo
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SBlockOrderInfo
*
pOrder
=
taosArrayGet
(
pInfo
,
i
);
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
SBlockOrderInfo
*
pOrder
=
TARRAY_GET_ELEM
(
pInfo
,
i
);
SColumnInfoData
*
pLeftColInfoData
=
taosArrayGet
(
pLeftBlock
->
pDataBlock
,
pOrder
->
colIndex
);
bool
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pSources
[
pLeftIdx
]
->
rowIndex
,
pLeftBlock
->
pBlockAgg
);
SColumnInfoData
*
pLeftColInfoData
=
TARRAY_GET_ELEM
(
pLeftBlock
->
pDataBlock
,
pOrder
->
colIndex
);
SColumnInfoData
*
pRightColInfoData
=
taosArrayGet
(
pRightBlock
->
pDataBlock
,
pOrder
->
colIndex
);
bool
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pSources
[
pRightIdx
]
->
rowIndex
,
pRightBlock
->
pBlockAgg
);
bool
leftNull
=
false
;
if
(
pLeftColInfoData
->
hasNull
)
{
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
rowIndex
,
pLeftBlock
->
pBlockAgg
);
}
SColumnInfoData
*
pRightColInfoData
=
TARRAY_GET_ELEM
(
pRightBlock
->
pDataBlock
,
pOrder
->
colIndex
);
bool
rightNull
=
false
;
if
(
pRightColInfoData
->
hasNull
)
{
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
rowIndex
,
pRightBlock
->
pBlockAgg
);
}
if
(
leftNull
&&
rightNull
)
{
continue
;
// continue to next slot
...
...
@@ -5586,20 +5594,24 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
return
pParam
->
nullFirst
?
-
1
:
1
;
}
void
*
left1
=
colDataGet
(
pLeftColInfoData
,
p
Sources
[
pLeftIdx
]
->
rowIndex
);
void
*
right1
=
colDataGet
(
pRightColInfoData
,
p
Sources
[
pRightIdx
]
->
rowIndex
);
void
*
left1
=
colDataGet
(
pLeftColInfoData
,
p
LeftSource
->
rowIndex
);
void
*
right1
=
colDataGet
(
pRightColInfoData
,
p
RightSource
->
rowIndex
);
switch
(
pLeftColInfoData
->
info
.
type
)
{
case
TSDB_DATA_TYPE_INT
:
if
(
*
(
int32_t
*
)
left1
==
*
(
int32_t
*
)
right1
)
{
case
TSDB_DATA_TYPE_INT
:
{
int32_t
leftv
=
*
(
int32_t
*
)
left1
;
int32_t
rightv
=
*
(
int32_t
*
)
right1
;
if
(
leftv
==
rightv
)
{
break
;
}
else
{
if
(
pOrder
->
order
==
TSDB_ORDER_ASC
)
{
return
*
(
int32_t
*
)
left1
<=
*
(
int32_t
*
)
right1
?
-
1
:
1
;
return
leftv
<
rightv
?
-
1
:
1
;
}
else
{
return
*
(
int32_t
*
)
left1
<=
*
(
int32_t
*
)
right1
?
1
:
-
1
;
return
leftv
<
rightv
?
1
:
-
1
;
}
}
}
default:
assert
(
0
);
}
...
...
@@ -5634,7 +5646,7 @@ static int32_t adjustMergeTreeForNextTuple(SExternalMemSource *pSource, SMultiwa
* Adjust loser tree otherwise, according to new candidate data
* if the loser tree is rebuild completed, we do not need to adjust
*/
int32_t
leafNodeIndex
=
tMergeTreeAdjustIndex
(
pTree
);
int32_t
leafNodeIndex
=
tMergeTree
Get
AdjustIndex
(
pTree
);
#ifdef _DEBUG_VIEW
printf
(
"before adjust:
\t
"
);
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
86e230cf
...
...
@@ -262,6 +262,9 @@ TEST(testCase, external_sort_Test) {
int32_t
total
=
1
;
int64_t
s1
=
taosGetTimestampUs
();
while
(
1
)
{
int64_t
s
=
taosGetTimestampUs
();
pRes
=
pOperator
->
exec
(
pOperator
,
&
newgroup
);
...
...
@@ -281,6 +284,10 @@ TEST(testCase, external_sort_Test) {
// }
}
int64_t
s2
=
taosGetTimestampUs
();
printf
(
"total:%ld
\n
"
,
s2
-
s1
);
pOperator
->
cleanupFn
(
pOperator
->
info
,
2
);
tfree
(
exp
);
tfree
(
exp1
);
...
...
source/util/src/tlosertree.c
浏览文件 @
86e230cf
...
...
@@ -18,10 +18,7 @@
#include "tlosertree.h"
#include "taoserror.h"
typedef
struct
STreeNode
{
int32_t
index
;
void
*
pData
;
// TODO remove it?
}
STreeNode
;
// Set the initial value of the multiway merge tree.
static
void
tMergeTreeInit
(
SMultiwayMergeTreeInfo
*
pTree
)
{
...
...
@@ -137,11 +134,3 @@ void tMergeTreePrint(const SMultiwayMergeTreeInfo* pTree) {
printf
(
"
\n
"
);
}
int32_t
tMergeTreeGetChosenIndex
(
const
SMultiwayMergeTreeInfo
*
pTree
)
{
return
pTree
->
pNode
[
0
].
index
;
}
int32_t
tMergeTreeAdjustIndex
(
const
SMultiwayMergeTreeInfo
*
pTree
)
{
return
tMergeTreeGetChosenIndex
(
pTree
)
+
pTree
->
numOfSources
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录