Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fae4f2c4
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看板
提交
fae4f2c4
编写于
1月 20, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
c9a1b3ba
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
32 addition
and
78 deletion
+32
-78
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+2
-1
source/libs/executor/src/exchangeoperator.c
source/libs/executor/src/exchangeoperator.c
+8
-22
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+4
-0
source/libs/executor/src/projectoperator.c
source/libs/executor/src/projectoperator.c
+4
-25
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+7
-9
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+7
-21
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
fae4f2c4
...
...
@@ -704,9 +704,10 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG
SDiskbasedBuf
*
pBuf
);
bool
hasLimitOffsetInfo
(
SLimitInfo
*
pLimitInfo
);
bool
hasSlimitOffsetInfo
(
SLimitInfo
*
pLimitInfo
);
void
initLimitInfo
(
const
SNode
*
pLimit
,
const
SNode
*
pSLimit
,
SLimitInfo
*
pLimitInfo
);
void
resetLimitInfoForNextGroup
(
SLimitInfo
*
pLimitInfo
);
bool
applyLimitOffset
(
SLimitInfo
*
pLimitInfo
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
,
SOperatorInfo
*
pOperator
);
bool
applyLimitOffset
(
SLimitInfo
*
pLimitInfo
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
);
void
applyAggFunctionOnPartialTuples
(
SExecTaskInfo
*
taskInfo
,
SqlFunctionCtx
*
pCtx
,
SColumnInfoData
*
pTimeWindowData
,
int32_t
offset
,
int32_t
forwardStep
,
int32_t
numOfTotal
,
int32_t
numOfOutput
);
...
...
source/libs/executor/src/exchangeoperator.c
浏览文件 @
fae4f2c4
...
...
@@ -707,6 +707,8 @@ int32_t prepareLoadRemoteData(SOperatorInfo* pOperator) {
}
int32_t
handleLimitOffset
(
SOperatorInfo
*
pOperator
,
SLimitInfo
*
pLimitInfo
,
SSDataBlock
*
pBlock
,
bool
holdDataInBuf
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
if
(
pLimitInfo
->
remainGroupOffset
>
0
)
{
if
(
pLimitInfo
->
currentGroupId
==
0
)
{
// it is the first group
pLimitInfo
->
currentGroupId
=
pBlock
->
info
.
id
.
groupId
;
...
...
@@ -750,36 +752,20 @@ int32_t handleLimitOffset(SOperatorInfo* pOperator, SLimitInfo* pLimitInfo, SSDa
// set current group id
pLimitInfo
->
currentGroupId
=
pBlock
->
info
.
id
.
groupId
;
if
(
pLimitInfo
->
remainOffset
>=
pBlock
->
info
.
rows
)
{
pLimitInfo
->
remainOffset
-=
pBlock
->
info
.
rows
;
blockDataCleanup
(
pBlock
);
bool
limitReached
=
applyLimitOffset
(
pLimitInfo
,
pBlock
,
pTaskInfo
);
if
(
pBlock
->
info
.
rows
==
0
)
{
return
PROJECT_RETRIEVE_CONTINUE
;
}
else
if
(
pLimitInfo
->
remainOffset
<
pBlock
->
info
.
rows
&&
pLimitInfo
->
remainOffset
>
0
)
{
blockDataTrimFirstNRows
(
pBlock
,
pLimitInfo
->
remainOffset
);
pLimitInfo
->
remainOffset
=
0
;
}
// check for the limitation in each group
if
(
pLimitInfo
->
limit
.
limit
>=
0
&&
pLimitInfo
->
numOfOutputRows
+
pBlock
->
info
.
rows
>=
pLimitInfo
->
limit
.
limit
)
{
int32_t
keepRows
=
(
int32_t
)(
pLimitInfo
->
limit
.
limit
-
pLimitInfo
->
numOfOutputRows
);
blockDataKeepFirstNRows
(
pBlock
,
keepRows
);
if
(
pLimitInfo
->
slimit
.
limit
>
0
&&
pLimitInfo
->
slimit
.
limit
<=
pLimitInfo
->
numOfOutputGroups
)
{
}
else
{
if
(
limitReached
&&
(
pLimitInfo
->
slimit
.
limit
>
0
&&
pLimitInfo
->
slimit
.
limit
<=
pLimitInfo
->
numOfOutputGroups
))
{
setOperatorCompleted
(
pOperator
);
}
else
{
// current group limitation is reached, and future blocks of this group need to be discarded.
if
(
pBlock
->
info
.
rows
==
0
)
{
return
PROJECT_RETRIEVE_CONTINUE
;
}
return
PROJECT_RETRIEVE_DONE
;
}
return
PROJECT_RETRIEVE_DONE
;
}
// todo optimize performance
// If there are slimit/soffset value exists, multi-round result can not be packed into one group, since the
// they may not belong to the same group the limit/offset value is not valid in this case.
if
((
!
holdDataInBuf
)
||
(
pBlock
->
info
.
rows
>=
pOperator
->
resultInfo
.
threshold
)
||
pLimitInfo
->
slimit
.
offset
!=
-
1
||
pLimitInfo
->
slimit
.
limit
!=
-
1
)
{
if
((
!
holdDataInBuf
)
||
(
pBlock
->
info
.
rows
>=
pOperator
->
resultInfo
.
threshold
)
||
hasSlimitOffsetInfo
(
pLimitInfo
))
{
return
PROJECT_RETRIEVE_DONE
;
}
else
{
// not full enough, continue to accumulate the output data in the buffer.
return
PROJECT_RETRIEVE_CONTINUE
;
...
...
source/libs/executor/src/executil.c
浏览文件 @
fae4f2c4
...
...
@@ -1749,6 +1749,10 @@ bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo) {
pLimitInfo
->
slimit
.
offset
!=
-
1
);
}
bool
hasSlimitOffsetInfo
(
SLimitInfo
*
pLimitInfo
)
{
return
(
pLimitInfo
->
slimit
.
limit
!=
-
1
||
pLimitInfo
->
slimit
.
offset
!=
-
1
);
}
void
initLimitInfo
(
const
SNode
*
pLimit
,
const
SNode
*
pSLimit
,
SLimitInfo
*
pLimitInfo
)
{
SLimit
limit
=
{.
limit
=
getLimit
(
pLimit
),
.
offset
=
getOffset
(
pLimit
)};
SLimit
slimit
=
{.
limit
=
getLimit
(
pSLimit
),
.
offset
=
getOffset
(
pSLimit
)};
...
...
source/libs/executor/src/projectoperator.c
浏览文件 @
fae4f2c4
...
...
@@ -185,36 +185,15 @@ static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SS
SOperatorInfo
*
pOperator
)
{
// set current group id
pLimitInfo
->
currentGroupId
=
groupId
;
if
(
pLimitInfo
->
remainOffset
>=
pBlock
->
info
.
rows
)
{
pLimitInfo
->
remainOffset
-=
pBlock
->
info
.
rows
;
blockDataCleanup
(
pBlock
);
bool
limitReached
=
applyLimitOffset
(
pLimitInfo
,
pBlock
,
pOperator
->
pTaskInfo
);
if
(
pBlock
->
info
.
rows
==
0
)
{
return
PROJECT_RETRIEVE_CONTINUE
;
}
else
if
(
pLimitInfo
->
remainOffset
<
pBlock
->
info
.
rows
&&
pLimitInfo
->
remainOffset
>
0
)
{
blockDataTrimFirstNRows
(
pBlock
,
pLimitInfo
->
remainOffset
);
pLimitInfo
->
remainOffset
=
0
;
}
// check for the limitation in each group
if
(
pLimitInfo
->
limit
.
limit
>=
0
&&
pLimitInfo
->
numOfOutputRows
+
pBlock
->
info
.
rows
>=
pLimitInfo
->
limit
.
limit
)
{
int32_t
keepRows
=
(
int32_t
)(
pLimitInfo
->
limit
.
limit
-
pLimitInfo
->
numOfOutputRows
);
blockDataKeepFirstNRows
(
pBlock
,
keepRows
);
// TODO: optimize it later when partition by + limit
// all retrieved requirement has been fulfilled, let's finish this
if
((
pLimitInfo
->
slimit
.
limit
==
-
1
&&
pLimitInfo
->
currentGroupId
==
0
)
||
(
pLimitInfo
->
slimit
.
limit
>
0
&&
pLimitInfo
->
slimit
.
limit
<=
pLimitInfo
->
numOfOutputGroups
))
{
}
else
{
if
(
limitReached
&&
(
pLimitInfo
->
slimit
.
limit
>
0
&&
pLimitInfo
->
slimit
.
limit
<=
pLimitInfo
->
numOfOutputGroups
))
{
setOperatorCompleted
(
pOperator
);
}
else
{
// Even current group is done, there may be many vgroups remain existed, and we need to continue to retrieve data
// from next group. So let's continue this retrieve process
if
(
keepRows
==
0
)
{
return
PROJECT_RETRIEVE_CONTINUE
;
}
}
}
pLimitInfo
->
numOfOutputRows
+=
pBlock
->
info
.
rows
;
return
PROJECT_RETRIEVE_DONE
;
}
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
fae4f2c4
...
...
@@ -256,12 +256,11 @@ static void doSetTagColumnData(STableScanBase* pTableScanInfo, SSDataBlock* pBlo
}
}
// todo handle the slimit info
bool
applyLimitOffset
(
SLimitInfo
*
pLimitInfo
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
,
SOperatorInfo
*
pOperator
)
{
bool
applyLimitOffset
(
SLimitInfo
*
pLimitInfo
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
)
{
SLimit
*
pLimit
=
&
pLimitInfo
->
limit
;
const
char
*
id
=
GET_TASKID
(
pTaskInfo
);
if
(
pLimit
->
offset
>
0
&&
pLimit
Info
->
remainOffset
>
0
)
{
if
(
pLimitInfo
->
remainOffset
>
0
)
{
if
(
pLimitInfo
->
remainOffset
>=
pBlock
->
info
.
rows
)
{
pLimitInfo
->
remainOffset
-=
pBlock
->
info
.
rows
;
blockDataEmpty
(
pBlock
);
...
...
@@ -276,12 +275,14 @@ bool applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo
if
(
pLimit
->
limit
!=
-
1
&&
pLimit
->
limit
<=
(
pLimitInfo
->
numOfOutputRows
+
pBlock
->
info
.
rows
))
{
// limit the output rows
int32_t
keep
=
(
int32_t
)(
pLimit
->
limit
-
pLimitInfo
->
numOfOutputRows
);
blockDataKeepFirstNRows
(
pBlock
,
keep
);
pLimitInfo
->
numOfOutputRows
+=
pBlock
->
info
.
rows
;
qDebug
(
"output limit %"
PRId64
" has reached, %s"
,
pLimit
->
limit
,
id
);
return
true
;
}
pLimitInfo
->
numOfOutputRows
+=
pBlock
->
info
.
rows
;
return
false
;
}
...
...
@@ -393,13 +394,12 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
}
}
bool
limitReached
=
applyLimitOffset
(
&
pTableScanInfo
->
limitInfo
,
pBlock
,
pTaskInfo
,
pOperator
);
bool
limitReached
=
applyLimitOffset
(
&
pTableScanInfo
->
limitInfo
,
pBlock
,
pTaskInfo
);
if
(
limitReached
)
{
// set operator flag is done
setOperatorCompleted
(
pOperator
);
}
pCost
->
totalRows
+=
pBlock
->
info
.
rows
;
pTableScanInfo
->
limitInfo
.
numOfOutputRows
=
pCost
->
totalRows
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2714,9 +2714,7 @@ SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, SSDataBlock*
}
}
applyLimitOffset
(
&
pInfo
->
limitInfo
,
pResBlock
,
pTaskInfo
,
pOperator
);
pInfo
->
limitInfo
.
numOfOutputRows
+=
pResBlock
->
info
.
rows
;
applyLimitOffset
(
&
pInfo
->
limitInfo
,
pResBlock
,
pTaskInfo
);
qDebug
(
"%s get sorted row block, rows:%d, limit:%"
PRId64
,
GET_TASKID
(
pTaskInfo
),
pResBlock
->
info
.
rows
,
pInfo
->
limitInfo
.
numOfOutputRows
);
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
fae4f2c4
...
...
@@ -222,6 +222,7 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
}
// multi-group case not handle here
SSDataBlock
*
pBlock
=
NULL
;
while
(
1
)
{
pBlock
=
getSortedBlockData
(
pInfo
->
pSortHandle
,
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
,
...
...
@@ -236,28 +237,13 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
continue
;
}
// todo add the limit/offset info
if
(
pInfo
->
limitInfo
.
remainOffset
>
0
)
{
if
(
pInfo
->
limitInfo
.
remainOffset
>=
blockDataGetNumOfRows
(
pBlock
))
{
pInfo
->
limitInfo
.
remainOffset
-=
pBlock
->
info
.
rows
;
continue
;
}
blockDataTrimFirstNRows
(
pBlock
,
pInfo
->
limitInfo
.
remainOffset
);
pInfo
->
limitInfo
.
remainOffset
=
0
;
}
if
(
pInfo
->
limitInfo
.
limit
.
limit
>
0
&&
pInfo
->
limitInfo
.
limit
.
limit
<=
pInfo
->
limitInfo
.
numOfOutputRows
+
blockDataGetNumOfRows
(
pBlock
))
{
int32_t
remain
=
pInfo
->
limitInfo
.
limit
.
limit
-
pInfo
->
limitInfo
.
numOfOutputRows
;
blockDataKeepFirstNRows
(
pBlock
,
remain
);
bool
limitReached
=
applyLimitOffset
(
&
pInfo
->
limitInfo
,
pBlock
,
pTaskInfo
);
if
(
limitReached
)
{
resetLimitInfoForNextGroup
(
&
pInfo
->
limitInfo
);
}
size_t
numOfRows
=
blockDataGetNumOfRows
(
pBlock
);
pInfo
->
limitInfo
.
numOfOutputRows
+=
numOfRows
;
pOperator
->
resultInfo
.
totalRows
+=
numOfRows
;
if
(
numOfRows
>
0
)
{
pOperator
->
resultInfo
.
totalRows
+=
pBlock
->
info
.
rows
;
if
(
pBlock
->
info
.
rows
>
0
)
{
break
;
}
}
...
...
@@ -680,7 +666,7 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
break
;
}
bool
limitReached
=
applyLimitOffset
(
&
pInfo
->
limitInfo
,
p
,
pTaskInfo
,
pOperator
);
bool
limitReached
=
applyLimitOffset
(
&
pInfo
->
limitInfo
,
p
,
pTaskInfo
);
if
(
limitReached
)
{
resetLimitInfoForNextGroup
(
&
pInfo
->
limitInfo
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录