Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
797af537
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
797af537
编写于
11月 29, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(query): improve the multi-way merge performance.
上级
5a3e4dc1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
28 deletion
+30
-28
source/libs/executor/src/exchangeoperator.c
source/libs/executor/src/exchangeoperator.c
+2
-5
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+3
-2
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+25
-21
未找到文件。
source/libs/executor/src/exchangeoperator.c
浏览文件 @
797af537
...
...
@@ -209,7 +209,7 @@ static SSDataBlock* doLoadRemoteDataImpl(SOperatorInfo* pOperator) {
}
}
static
SSDataBlock
*
doL
oadRemoteData
(
SOperatorInfo
*
pOperator
)
{
static
SSDataBlock
*
l
oadRemoteData
(
SOperatorInfo
*
pOperator
)
{
SExchangeInfo
*
pExchangeInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
...
...
@@ -318,7 +318,7 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode
pOperator
->
exprSupp
.
numOfExprs
=
taosArrayGetSize
(
pInfo
->
pDummyBlock
->
pDataBlock
);
pOperator
->
fpSet
=
createOperatorFpSet
(
prepareLoadRemoteData
,
doL
oadRemoteData
,
NULL
,
destroyExchangeOperatorInfo
,
NULL
);
createOperatorFpSet
(
prepareLoadRemoteData
,
l
oadRemoteData
,
NULL
,
destroyExchangeOperatorInfo
,
NULL
);
return
pOperator
;
_error:
...
...
@@ -581,13 +581,10 @@ int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) {
pOperator
->
status
=
OP_RES_TO_RETURN
;
pOperator
->
cost
.
openCost
=
taosGetTimestampUs
()
-
startTs
;
tsem_wait
(
&
pExchangeInfo
->
ready
);
if
(
isTaskKilled
(
pTaskInfo
))
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
tsem_post
(
&
pExchangeInfo
->
ready
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
797af537
...
...
@@ -559,7 +559,7 @@ typedef struct SMultiwayMergeOperatorInfo {
STupleHandle
*
prefetchedTuple
;
}
SMultiwayMergeOperatorInfo
;
int32_t
doO
penMultiwayMergeOperator
(
SOperatorInfo
*
pOperator
)
{
int32_t
o
penMultiwayMergeOperator
(
SOperatorInfo
*
pOperator
)
{
SMultiwayMergeOperatorInfo
*
pInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
...
...
@@ -580,6 +580,7 @@ int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) {
SSortSource
*
ps
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortSource
));
ps
->
param
=
pOperator
->
pDownstream
[
i
];
ps
->
onlyRef
=
true
;
tsortAddSource
(
pInfo
->
pSortHandle
,
ps
);
}
...
...
@@ -792,7 +793,7 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size
pInfo
->
sortBufSize
=
pInfo
->
bufPageSize
*
(
numStreams
+
1
);
// one additional is reserved for merged result.
setOperatorInfo
(
pOperator
,
"MultiwayMergeOperator"
,
QUERY_NODE_PHYSICAL_PLAN_MERGE
,
false
,
OP_NOT_OPENED
,
pInfo
,
pTaskInfo
);
pOperator
->
fpSet
=
createOperatorFpSet
(
doO
penMultiwayMergeOperator
,
doMultiwayMerge
,
NULL
,
pOperator
->
fpSet
=
createOperatorFpSet
(
o
penMultiwayMergeOperator
,
doMultiwayMerge
,
NULL
,
destroyMultiwayMergeOperatorInfo
,
getMultiwayMergeExplainExecInfo
);
code
=
appendDownstream
(
pOperator
,
downStreams
,
numStreams
);
...
...
source/libs/executor/src/tsort.c
浏览文件 @
797af537
...
...
@@ -34,14 +34,12 @@ struct SSortHandle {
int32_t
pageSize
;
int32_t
numOfPages
;
SDiskbasedBuf
*
pBuf
;
SArray
*
pSortInfo
;
SArray
*
pOrderedSource
;
int32_t
loops
;
uint64_t
sortElapsed
;
int64_t
startTs
;
uint64_t
totalElapsed
;
SArray
*
pSortInfo
;
SArray
*
pOrderedSource
;
int32_t
loops
;
uint64_t
sortElapsed
;
int64_t
startTs
;
uint64_t
totalElapsed
;
int32_t
sourceId
;
SSDataBlock
*
pDataBlock
;
...
...
@@ -99,9 +97,9 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
}
static
int32_t
sortComparCleanup
(
SMsortComparParam
*
cmpParam
)
{
// NOTICE: pSource may be, if it is SORT_MULTISOURCE_MERGE
for
(
int32_t
i
=
0
;
i
<
cmpParam
->
numOfSources
;
++
i
)
{
SSortSource
*
pSource
=
cmpParam
->
pSources
[
i
];
// NOTICE: pSource may be SGenericSource *, if it is SORT_MULTISOURCE_MERGE
SSortSource
*
pSource
=
cmpParam
->
pSources
[
i
];
blockDataDestroy
(
pSource
->
src
.
pBlock
);
taosMemoryFreeClear
(
pSource
);
}
...
...
@@ -228,15 +226,15 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
return
doAddNewExternalMemSource
(
pHandle
->
pBuf
,
pHandle
->
pOrderedSource
,
pBlock
,
&
pHandle
->
sourceId
,
pPageIdList
);
}
static
void
setCurrentSource
Is
Done
(
SSortSource
*
pSource
,
SSortHandle
*
pHandle
)
{
static
void
setCurrentSourceDone
(
SSortSource
*
pSource
,
SSortHandle
*
pHandle
)
{
pSource
->
src
.
rowIndex
=
-
1
;
++
pHandle
->
numOfCompletedSources
;
}
static
int32_t
sortComparInit
(
SMsortComparParam
*
cm
pParam
,
SArray
*
pSources
,
int32_t
startIndex
,
int32_t
endIndex
,
static
int32_t
sortComparInit
(
SMsortComparParam
*
pParam
,
SArray
*
pSources
,
int32_t
startIndex
,
int32_t
endIndex
,
SSortHandle
*
pHandle
)
{
cm
pParam
->
pSources
=
taosArrayGet
(
pSources
,
startIndex
);
cm
pParam
->
numOfSources
=
(
endIndex
-
startIndex
+
1
);
pParam
->
pSources
=
taosArrayGet
(
pSources
,
startIndex
);
pParam
->
numOfSources
=
(
endIndex
-
startIndex
+
1
);
int32_t
code
=
0
;
...
...
@@ -244,7 +242,7 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
if
(
pHandle
->
pBuf
==
NULL
)
{
if
(
!
osTempSpaceAvailable
())
{
code
=
TSDB_CODE_NO_AVAIL_DISK
;
qError
(
"Sort compare init failed since %s
"
,
terrstr
(
code
)
);
qError
(
"Sort compare init failed since %s
, %s"
,
terrstr
(
code
),
pHandle
->
idStr
);
return
code
;
}
...
...
@@ -257,12 +255,12 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
}
if
(
pHandle
->
type
==
SORT_SINGLESOURCE_SORT
)
{
for
(
int32_t
i
=
0
;
i
<
cm
pParam
->
numOfSources
;
++
i
)
{
SSortSource
*
pSource
=
cm
pParam
->
pSources
[
i
];
for
(
int32_t
i
=
0
;
i
<
pParam
->
numOfSources
;
++
i
)
{
SSortSource
*
pSource
=
pParam
->
pSources
[
i
];
// set current source is done
if
(
taosArrayGetSize
(
pSource
->
pageIdList
)
==
0
)
{
setCurrentSource
Is
Done
(
pSource
,
pHandle
);
setCurrentSourceDone
(
pSource
,
pHandle
);
continue
;
}
...
...
@@ -277,15 +275,21 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
releaseBufPage
(
pHandle
->
pBuf
,
pPage
);
}
}
else
{
for
(
int32_t
i
=
0
;
i
<
cmpParam
->
numOfSources
;
++
i
)
{
SSortSource
*
pSource
=
cmpParam
->
pSources
[
i
];
qDebug
(
"start init for the multiway merge sort, %s"
,
pHandle
->
idStr
);
int64_t
st
=
taosGetTimestampUs
();
for
(
int32_t
i
=
0
;
i
<
pParam
->
numOfSources
;
++
i
)
{
SSortSource
*
pSource
=
pParam
->
pSources
[
i
];
pSource
->
src
.
pBlock
=
pHandle
->
fetchfp
(
pSource
->
param
);
// set current source is done
if
(
pSource
->
src
.
pBlock
==
NULL
)
{
setCurrentSource
Is
Done
(
pSource
,
pHandle
);
setCurrentSourceDone
(
pSource
,
pHandle
);
}
}
int64_t
et
=
taosGetTimestampUs
();
qDebug
(
"init for merge sort completed, elapsed time:%.2f ms, %s"
,
(
et
-
st
)
/
1000
.
0
,
pHandle
->
idStr
);
}
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录