Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b771748e
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b771748e
编写于
3月 29, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-13039] fix bug in sort.
上级
d537387a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
53 addition
and
33 deletion
+53
-33
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+45
-32
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+7
-0
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
b771748e
...
...
@@ -653,7 +653,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
S
ExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
S
SDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SArray
*
pSortInfo
,
SArray
*
pGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
SSDataBlock
*
pResBlock
,
const
SName
*
pName
,
SNode
*
pCondition
,
SEpSet
epset
,
SArray
*
colList
,
SExecTaskInfo
*
pTaskInfo
,
bool
showRewrite
,
int32_t
accountId
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
b771748e
...
...
@@ -69,6 +69,7 @@ typedef enum SResultTsInterpType {
typedef
struct
SColMatchInfo
{
int32_t
colId
;
int32_t
targetSlotId
;
bool
output
;
}
SColMatchInfo
;
#if 0
...
...
@@ -330,15 +331,16 @@ SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) {
pBlock
->
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
pBlock
->
info
.
blockId
=
pNode
->
dataBlockId
;
pBlock
->
info
.
rowSize
=
pNode
->
resultRowSize
;
pBlock
->
info
.
rowSize
=
pNode
->
resultRowSize
;
// todo ??
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
idata
=
{{
0
}};
SSlotDescNode
*
pDescNode
=
nodesListGetNode
(
pNode
->
pSlots
,
i
);
idata
.
info
.
type
=
pDescNode
->
dataType
.
type
;
if
(
pDescNode
->
dataType
.
bytes
>
1000
)
{
pDescNode
->
dataType
.
bytes
=
4
;
if
(
!
pDescNode
->
output
)
{
continue
;
}
idata
.
info
.
type
=
pDescNode
->
dataType
.
type
;
idata
.
info
.
bytes
=
pDescNode
->
dataType
.
bytes
;
idata
.
info
.
scale
=
pDescNode
->
dataType
.
scale
;
idata
.
info
.
slotId
=
pDescNode
->
slotId
;
...
...
@@ -2864,11 +2866,14 @@ int32_t loadDataBlock(SExecTaskInfo *pTaskInfo, STableScanInfo* pTableScanInfo,
}
int32_t
numOfCols
=
pBlock
->
info
.
numOfCols
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
p
=
taosArrayGet
(
pCols
,
i
);
SColMatchInfo
*
pColMatchInfo
=
taosArrayGet
(
pTableScanInfo
->
pColMatchInfo
,
i
);
ASSERT
(
pColMatchInfo
->
colId
==
p
->
info
.
colId
);
if
(
!
pColMatchInfo
->
output
)
{
continue
;
}
ASSERT
(
pColMatchInfo
->
colId
==
p
->
info
.
colId
);
taosArraySet
(
pBlock
->
pDataBlock
,
pColMatchInfo
->
targetSlotId
,
p
);
}
...
...
@@ -6249,7 +6254,7 @@ static SSDataBlock* doSort(SOperatorInfo *pOperator, bool* newgroup) {
return
getSortedBlockData
(
pInfo
->
pSortHandle
,
pInfo
->
pDataBlock
,
hasVarCol
,
pInfo
->
numOfRowsInRes
);
}
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
S
ExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
S
SDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SSortOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
...
@@ -8474,17 +8479,17 @@ static int32_t doCreateTableGroup(void* metaHandle, int32_t tableType, uint64_t
static
SArray
*
extractTableIdList
(
const
STableGroupInfo
*
pTableGroupInfo
);
static
SArray
*
extractScanColumnId
(
SNodeList
*
pNodeList
);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
,
SDataBlockDescNode
*
pOutputNodeList
,
int32_t
*
numOfOutputCols
);
static
SArray
*
createSortInfo
(
SNodeList
*
pNodeList
);
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
nodeType
(
pPhyNode
))
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
size_t
numOfCols
=
LIST_LENGTH
(
pScanPhyNode
->
pScanCols
)
;
int32_t
numOfCols
=
0
;
tsdbReaderT
pDataReader
=
doCreateDataReader
((
STableScanPhysiNode
*
)
pPhyNode
,
pHandle
,
pTableGroupInfo
,
(
uint64_t
)
queryId
,
taskId
);
SArray
*
pColList
=
extractColMatchInfo
(
pScanPhyNode
->
pScanCols
);
SArray
*
pColList
=
extractColMatchInfo
(
pScanPhyNode
->
pScanCols
,
pScanPhyNode
->
node
.
pOutputDataBlockDesc
,
&
numOfCols
);
return
createTableScanOperatorInfo
(
pDataReader
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pColList
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
nodeType
(
pPhyNode
))
{
...
...
@@ -8523,15 +8528,13 @@ static SArray* createSortInfo(SNodeList* pNodeList);
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
assert
(
size
==
1
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
i
);
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
0
);
SOperatorInfo
*
op
=
doCreateOperatorTreeNode
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(((
SProjectPhysiNode
*
)
pPhyNode
)
->
pProjections
,
NULL
,
&
num
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
return
createProjectOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
pTaskInfo
);
}
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_AGG
==
nodeType
(
pPhyNode
))
{
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
assert
(
size
==
1
);
...
...
@@ -8584,12 +8587,9 @@ static SArray* createSortInfo(SNodeList* pNodeList);
SSortPhysiNode
*
pSortPhyNode
=
(
SSortPhysiNode
*
)
pPhyNode
;
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pSortPhyNode
->
pExprs
,
NULL
,
&
num
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SArray
*
info
=
createSortInfo
(
pSortPhyNode
->
pSortKeys
);
return
createSortOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
info
,
pTaskInfo
);
return
createSortOperatorInfo
(
op
,
pResBlock
,
info
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
==
nodeType
(
pPhyNode
))
{
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
assert
(
size
==
1
);
...
...
@@ -8730,7 +8730,7 @@ SArray* createSortInfo(SNodeList* pNodeList) {
return
pList
;
}
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
)
{
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
,
SDataBlockDescNode
*
pOutputNodeList
,
int32_t
*
numOfOutputCols
)
{
size_t
numOfCols
=
LIST_LENGTH
(
pNodeList
);
SArray
*
pList
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColMatchInfo
));
if
(
pList
==
NULL
)
{
...
...
@@ -8745,10 +8745,23 @@ SArray* extractColMatchInfo(SNodeList* pNodeList) {
SColMatchInfo
c
=
{
0
};
c
.
colId
=
pColNode
->
colId
;
c
.
targetSlotId
=
pNode
->
slotId
;
c
.
output
=
true
;
taosArrayPush
(
pList
,
&
c
);
}
*
numOfOutputCols
=
0
;
int32_t
num
=
LIST_LENGTH
(
pOutputNodeList
->
pSlots
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SSlotDescNode
*
pNode
=
(
SSlotDescNode
*
)
nodesListGetNode
(
pOutputNodeList
->
pSlots
,
i
);
SColMatchInfo
*
info
=
taosArrayGet
(
pList
,
pNode
->
slotId
);
if
(
!
pNode
->
output
)
{
info
->
output
=
false
;
}
else
{
(
*
numOfOutputCols
)
+=
1
;
}
}
return
pList
;
}
...
...
source/libs/executor/src/tsort.c
浏览文件 @
b771748e
...
...
@@ -414,6 +414,9 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
static
int32_t
doInternalMergeSort
(
SSortHandle
*
pHandle
)
{
size_t
numOfSources
=
taosArrayGetSize
(
pHandle
->
pOrderedSource
);
if
(
numOfSources
==
0
)
{
return
0
;
}
// Calculate the I/O counts to complete the data sort.
double
sortPass
=
floorl
(
log2
(
numOfSources
)
/
log2
(
pHandle
->
numOfPages
));
...
...
@@ -602,6 +605,10 @@ int32_t tsortOpen(SSortHandle* pHandle) {
ASSERT
(
numOfSources
<=
getNumOfInMemBufPages
(
pHandle
->
pBuf
));
}
if
(
numOfSources
==
0
)
{
return
0
;
}
code
=
sortComparInit
(
&
pHandle
->
cmpParam
,
pHandle
->
pOrderedSource
,
0
,
numOfSources
-
1
,
pHandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录