Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bd518f3f
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看板
提交
bd518f3f
编写于
6月 16, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): remove group info during sort.
上级
87300b2a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
149 deletion
+37
-149
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+0
-8
source/libs/executor/inc/tsort.h
source/libs/executor/inc/tsort.h
+0
-6
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+7
-24
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+1
-13
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+12
-58
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+17
-40
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
bd518f3f
...
...
@@ -696,10 +696,6 @@ typedef struct SSortedMergeOperatorInfo {
int32_t
numOfResPerPage
;
char
**
groupVal
;
SArray
*
groupInfo
;
bool
hasGroupId
;
uint64_t
groupId
;
STupleHandle
*
prefetchedTuple
;
}
SSortedMergeOperatorInfo
;
typedef
struct
SSortOperatorInfo
{
...
...
@@ -712,10 +708,6 @@ typedef struct SSortOperatorInfo {
int64_t
startTs
;
// sort start time
uint64_t
sortElapsed
;
// sort elapsed time, time to flush to disk not included.
STupleHandle
*
prefetchedTuple
;
bool
hasGroupId
;
uint64_t
groupId
;
}
SSortOperatorInfo
;
typedef
struct
STagFilterOperatorInfo
{
...
...
source/libs/executor/inc/tsort.h
浏览文件 @
bd518f3f
...
...
@@ -130,12 +130,6 @@ bool tsortIsNullVal(STupleHandle* pVHandle, int32_t colId);
*/
void
*
tsortGetValue
(
STupleHandle
*
pVHandle
,
int32_t
colId
);
/**
*
* @param pVHandle
* @return
*/
uint64_t
tsortGetGroupId
(
STupleHandle
*
pVHandle
);
/**
*
* @param pSortHandle
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
bd518f3f
...
...
@@ -3030,31 +3030,12 @@ SSDataBlock* getSortedMergeBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlo
blockDataEnsureCapacity
(
p
,
capacity
);
while
(
1
)
{
STupleHandle
*
pTupleHandle
=
NULL
;
if
(
pInfo
->
prefetchedTuple
==
NULL
)
{
pTupleHandle
=
tsortNextTuple
(
pHandle
);
}
else
{
pTupleHandle
=
pInfo
->
prefetchedTuple
;
pInfo
->
groupId
=
tsortGetGroupId
(
pTupleHandle
);
pInfo
->
prefetchedTuple
=
NULL
;
}
STupleHandle
*
pTupleHandle
=
tsortNextTuple
(
pHandle
);
if
(
pTupleHandle
==
NULL
)
{
break
;
}
uint64_t
tupleGroupId
=
tsortGetGroupId
(
pTupleHandle
);
if
(
!
pInfo
->
hasGroupId
)
{
pInfo
->
groupId
=
tupleGroupId
;
pInfo
->
hasGroupId
=
true
;
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
if
(
pInfo
->
groupId
==
tupleGroupId
)
{
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
{
pInfo
->
prefetchedTuple
=
pTupleHandle
;
break
;
}
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
if
(
p
->
info
.
rows
>=
capacity
)
{
break
;
}
...
...
@@ -3073,7 +3054,6 @@ SSDataBlock* getSortedMergeBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlo
pDataBlock
->
info
.
rows
=
p
->
info
.
rows
;
pDataBlock
->
info
.
capacity
=
p
->
info
.
rows
;
pDataBlock
->
info
.
groupId
=
pInfo
->
groupId
;
}
blockDataDestroy
(
p
);
...
...
@@ -3339,7 +3319,7 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) {
doSetOperatorCompleted
(
pOperator
);
}
size_t
rows
=
blockDataGetNumOfRows
(
pInfo
->
pRes
);
// pInfo->pRes : NULL;
size_t
rows
=
blockDataGetNumOfRows
(
pInfo
->
pRes
);
pOperator
->
resultInfo
.
totalRows
+=
rows
;
return
(
rows
==
0
)
?
NULL
:
pInfo
->
pRes
;
...
...
@@ -4920,7 +4900,10 @@ SArray* extractColumnInfo(SNodeList* pNodeList) {
}
SArray
*
extractPartitionColInfo
(
SNodeList
*
pNodeList
)
{
if
(
!
pNodeList
)
return
NULL
;
if
(
!
pNodeList
)
{
return
NULL
;
}
size_t
numOfCols
=
LIST_LENGTH
(
pNodeList
);
SArray
*
pList
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumn
));
if
(
pList
==
NULL
)
{
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
bd518f3f
...
...
@@ -2175,25 +2175,13 @@ SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, int32_t capa
pTupleHandle
=
tsortNextTuple
(
pHandle
);
}
else
{
pTupleHandle
=
pInfo
->
prefetchedTuple
;
pInfo
->
groupId
=
tsortGetGroupId
(
pTupleHandle
);
pInfo
->
prefetchedTuple
=
NULL
;
}
if
(
pTupleHandle
==
NULL
)
{
break
;
}
uint64_t
tupleGroupId
=
tsortGetGroupId
(
pTupleHandle
);
if
(
!
pInfo
->
hasGroupId
)
{
pInfo
->
groupId
=
tupleGroupId
;
pInfo
->
hasGroupId
=
true
;
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
if
(
pInfo
->
groupId
==
tupleGroupId
)
{
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
{
pInfo
->
prefetchedTuple
=
pTupleHandle
;
break
;
}
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
if
(
p
->
info
.
rows
>=
capacity
)
{
break
;
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
bd518f3f
...
...
@@ -40,15 +40,13 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR
initResultSizeInfo
(
pOperator
,
1024
);
pInfo
->
pSortInfo
=
pSortInfo
;
pInfo
->
pColMatchInfo
=
pColMatchColInfo
;
pInfo
->
hasGroupId
=
false
;
pInfo
->
prefetchedTuple
=
NULL
;
pOperator
->
name
=
"SortOperator"
;
pInfo
->
pSortInfo
=
pSortInfo
;
pInfo
->
pColMatchInfo
=
pColMatchColInfo
;
pOperator
->
name
=
"SortOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SORT
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
// lazy evaluation for the following parameter since the input datablock is not known till now.
// pInfo->bufPageSize = rowSize < 1024 ? 1024 * 2 : rowSize * 2; // there are headers, so pageSize = rowSize +
...
...
@@ -97,31 +95,12 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i
blockDataEnsureCapacity
(
p
,
capacity
);
while
(
1
)
{
STupleHandle
*
pTupleHandle
=
NULL
;
if
(
pInfo
->
prefetchedTuple
==
NULL
)
{
pTupleHandle
=
tsortNextTuple
(
pHandle
);
}
else
{
pTupleHandle
=
pInfo
->
prefetchedTuple
;
pInfo
->
groupId
=
tsortGetGroupId
(
pTupleHandle
);
pInfo
->
prefetchedTuple
=
NULL
;
}
STupleHandle
*
pTupleHandle
=
tsortNextTuple
(
pHandle
);
if
(
pTupleHandle
==
NULL
)
{
break
;
}
uint64_t
tupleGroupId
=
tsortGetGroupId
(
pTupleHandle
);
if
(
!
pInfo
->
hasGroupId
)
{
pInfo
->
groupId
=
tupleGroupId
;
pInfo
->
hasGroupId
=
true
;
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
if
(
pInfo
->
groupId
==
tupleGroupId
)
{
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
{
pInfo
->
prefetchedTuple
=
pTupleHandle
;
break
;
}
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
if
(
p
->
info
.
rows
>=
capacity
)
{
break
;
}
...
...
@@ -140,7 +119,6 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i
pDataBlock
->
info
.
rows
=
p
->
info
.
rows
;
pDataBlock
->
info
.
capacity
=
p
->
info
.
rows
;
pDataBlock
->
info
.
groupId
=
pInfo
->
groupId
;
}
blockDataDestroy
(
p
);
...
...
@@ -255,10 +233,7 @@ typedef struct SMultiwaySortMergeOperatorInfo {
SSDataBlock
*
pInputBlock
;
int64_t
startTs
;
// sort start time
bool
hasGroupId
;
uint64_t
groupId
;
STupleHandle
*
prefetchedTuple
;
uint64_t
groupId
;
}
SMultiwaySortMergeOperatorInfo
;
int32_t
doOpenMultiwaySortMergeOperator
(
SOperatorInfo
*
pOperator
)
{
...
...
@@ -312,31 +287,12 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
blockDataEnsureCapacity
(
p
,
capacity
);
while
(
1
)
{
STupleHandle
*
pTupleHandle
=
NULL
;
if
(
pInfo
->
prefetchedTuple
==
NULL
)
{
pTupleHandle
=
tsortNextTuple
(
pHandle
);
}
else
{
pTupleHandle
=
pInfo
->
prefetchedTuple
;
pInfo
->
groupId
=
tsortGetGroupId
(
pTupleHandle
);
pInfo
->
prefetchedTuple
=
NULL
;
}
STupleHandle
*
pTupleHandle
=
tsortNextTuple
(
pHandle
);
if
(
pTupleHandle
==
NULL
)
{
break
;
}
uint64_t
tupleGroupId
=
tsortGetGroupId
(
pTupleHandle
);
if
(
!
pInfo
->
hasGroupId
)
{
pInfo
->
groupId
=
tupleGroupId
;
pInfo
->
hasGroupId
=
true
;
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
if
(
pInfo
->
groupId
==
tupleGroupId
)
{
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
{
pInfo
->
prefetchedTuple
=
pTupleHandle
;
break
;
}
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
if
(
p
->
info
.
rows
>=
capacity
)
{
break
;
}
...
...
@@ -432,14 +388,12 @@ SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams,
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pInfo
->
hasGroupId
=
false
;
pInfo
->
prefetchedTuple
=
NULL
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pInfo
->
bufPageSize
=
getProperSortPageSize
(
rowSize
);
uint32_t
numOfSources
=
taosArrayGetSize
(
pSortInfo
);
numOfSources
=
TMAX
(
2
,
numOfSources
);
numOfSources
=
TMAX
(
4
,
numOfSources
);
pInfo
->
sortBufSize
=
numOfSources
*
pInfo
->
bufPageSize
;
...
...
source/libs/executor/src/tsort.c
浏览文件 @
bd518f3f
...
...
@@ -557,59 +557,40 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
SSortSource
*
source
=
taosArrayGetP
(
pHandle
->
pOrderedSource
,
0
);
taosArrayClear
(
pHandle
->
pOrderedSource
);
bool
hasGroupId
=
false
;
SSDataBlock
*
prefetchedDataBlock
=
NULL
;
while
(
1
)
{
SSDataBlock
*
pBlock
=
NULL
;
if
(
prefetchedDataBlock
==
NULL
)
{
pBlock
=
pHandle
->
fetchfp
(
source
->
param
);
}
else
{
pBlock
=
prefetchedDataBlock
;
prefetchedDataBlock
=
NULL
;
}
SSDataBlock
*
pBlock
=
pHandle
->
fetchfp
(
source
->
param
);
if
(
pBlock
==
NULL
)
{
break
;
}
if
(
!
hasGroupId
)
{
// calculate the buffer pages according to the total available buffers.
if
(
pHandle
->
pDataBlock
==
NULL
)
{
pHandle
->
pageSize
=
getProperSortPageSize
(
blockDataGetRowSize
(
pBlock
));
// todo, number of pages are set according to the total available sort buffer
pHandle
->
numOfPages
=
1024
;
sortBufSize
=
pHandle
->
numOfPages
*
pHandle
->
pageSize
;
hasGroupId
=
true
;
pHandle
->
pDataBlock
=
createOneDataBlock
(
pBlock
,
false
);
}
if
(
pHandle
->
pDataBlock
->
info
.
groupId
==
pBlock
->
info
.
groupId
)
{
// perform the scalar function calculation before apply the sort
if
(
pHandle
->
beforeFp
!=
NULL
)
{
pHandle
->
beforeFp
(
pBlock
,
pHandle
->
param
);
}
if
(
pHandle
->
beforeFp
!=
NULL
)
{
pHandle
->
beforeFp
(
pBlock
,
pHandle
->
param
);
}
int32_t
code
=
blockDataMerge
(
pHandle
->
pDataBlock
,
pBlock
);
if
(
code
!=
0
)
{
return
code
;
}
int32_t
code
=
blockDataMerge
(
pHandle
->
pDataBlock
,
pBlock
);
if
(
code
!=
0
)
{
return
code
;
}
size_t
size
=
blockDataGetSize
(
pHandle
->
pDataBlock
);
if
(
size
>
sortBufSize
)
{
// Perform the in-memory sort and then flush data in the buffer into disk.
int64_t
p
=
taosGetTimestampUs
();
blockDataSort
(
pHandle
->
pDataBlock
,
pHandle
->
pSortInfo
);
size_t
size
=
blockDataGetSize
(
pHandle
->
pDataBlock
);
if
(
size
>
sortBufSize
)
{
// Perform the in-memory sort and then flush data in the buffer into disk.
int64_t
p
=
taosGetTimestampUs
();
blockDataSort
(
pHandle
->
pDataBlock
,
pHandle
->
pSortInfo
);
int64_t
el
=
taosGetTimestampUs
()
-
p
;
pHandle
->
sortElapsed
+=
el
;
int64_t
el
=
taosGetTimestampUs
()
-
p
;
pHandle
->
sortElapsed
+=
el
;
doAddToBuf
(
pHandle
->
pDataBlock
,
pHandle
);
}
}
else
{
prefetchedDataBlock
=
pBlock
;
pHandle
->
pDataBlock
=
createOneDataBlock
(
pBlock
,
false
);
doAddToBuf
(
pHandle
->
pDataBlock
,
pHandle
);
}
}
...
...
@@ -758,10 +739,6 @@ void* tsortGetValue(STupleHandle* pVHandle, int32_t colIndex) {
}
}
uint64_t
tsortGetGroupId
(
STupleHandle
*
pVHandle
)
{
return
pVHandle
->
pBlock
->
info
.
groupId
;
}
SSortExecInfo
tsortGetSortExecInfo
(
SSortHandle
*
pHandle
)
{
SSortExecInfo
info
=
{
0
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录