Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
53686de9
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
53686de9
编写于
7月 30, 2022
作者:
H
Haojun Liao
提交者:
GitHub
7月 30, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15606 from taosdata/feature/3_liaohj
fix(query): remove invalid time window close ops.
上级
a8176b64
71b5cf5a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
71 addition
and
39 deletion
+71
-39
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+2
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+1
-0
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+1
-0
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+67
-38
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
53686de9
...
...
@@ -549,7 +549,8 @@ typedef struct SMergeAlignedIntervalAggOperatorInfo {
SIntervalAggOperatorInfo
*
intervalAggOperatorInfo
;
bool
hasGroupId
;
uint64_t
groupId
;
uint64_t
groupId
;
// current groupId
int64_t
curTs
;
// current ts
SSDataBlock
*
prefetchedBlock
;
bool
inputBlocksFinished
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
53686de9
...
...
@@ -1445,6 +1445,7 @@ static void doUpdateNumOfRows(SResultRow* pRow, int32_t numOfExprs, const int32_
}
}
// todo extract method with copytoSSDataBlock
int32_t
finalizeResultRowIntoResultDataBlock
(
SDiskbasedBuf
*
pBuf
,
SResultRowPosition
*
resultRowPosition
,
SqlFunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
int32_t
numOfExprs
,
const
int32_t
*
rowCellOffset
,
SSDataBlock
*
pBlock
,
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
53686de9
...
...
@@ -507,6 +507,7 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
colDataSetNull_f
(
bitmap
,
(
*
rows
));
}
else
{
memcpy
(
data
+
(
*
columnLen
),
colDataGetData
(
pColInfoData
,
j
),
bytes
);
ASSERT
((
data
+
(
*
columnLen
)
+
bytes
-
(
char
*
)
pPage
)
<=
getBufPageSize
(
pInfo
->
pBuf
));
}
contentLen
=
bytes
;
}
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
53686de9
...
...
@@ -4589,11 +4589,10 @@ void destroyMergeAlignedIntervalOperatorInfo(void* param, int32_t numOfOutput) {
static
int32_t
outputMergeAlignedIntervalResult
(
SOperatorInfo
*
pOperatorInfo
,
uint64_t
tableGroupId
,
SSDataBlock
*
pResultBlock
,
TSKEY
wstartTs
)
{
SMergeAlignedIntervalAggOperatorInfo
*
miaInfo
=
pOperatorInfo
->
info
;
SIntervalAggOperatorInfo
*
iaInfo
=
miaInfo
->
intervalAggOperatorInfo
;
SExecTaskInfo
*
pTaskInfo
=
pOperatorInfo
->
pTaskInfo
;
SExprSupp
*
pSup
=
&
pOperatorInfo
->
exprSupp
;
bool
ascScan
=
(
iaInfo
->
inputOrder
==
TSDB_ORDER_ASC
);
SIntervalAggOperatorInfo
*
iaInfo
=
miaInfo
->
intervalAggOperatorInfo
;
SExecTaskInfo
*
pTaskInfo
=
pOperatorInfo
->
pTaskInfo
;
SExprSupp
*
pSup
=
&
pOperatorInfo
->
exprSupp
;
SET_RES_WINDOW_KEY
(
iaInfo
->
aggSup
.
keyBuf
,
&
wstartTs
,
TSDB_KEYSIZE
,
tableGroupId
);
SResultRowPosition
*
p1
=
(
SResultRowPosition
*
)
taosHashGet
(
iaInfo
->
aggSup
.
pResultRowHashTable
,
iaInfo
->
aggSup
.
keyBuf
,
...
...
@@ -4603,8 +4602,9 @@ static int32_t outputMergeAlignedIntervalResult(SOperatorInfo* pOperatorInfo, ui
finalizeResultRowIntoResultDataBlock
(
iaInfo
->
aggSup
.
pResultBuf
,
p1
,
pSup
->
pCtx
,
pSup
->
pExprInfo
,
pSup
->
numOfExprs
,
pSup
->
rowEntryInfoOffset
,
pResultBlock
,
pTaskInfo
);
taosHashRemove
(
iaInfo
->
aggSup
.
pResultRowHashTable
,
iaInfo
->
aggSup
.
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
TSDB_KEYSIZE
));
ASSERT
(
taosHashGetSize
(
iaInfo
->
aggSup
.
pResultRowHashTable
)
==
0
);
return
0
;
return
TSDB_CODE_SUCCESS
;
}
static
void
doMergeAlignedIntervalAggImpl
(
SOperatorInfo
*
pOperatorInfo
,
SResultRowInfo
*
pResultRowInfo
,
...
...
@@ -4619,11 +4619,20 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR
int32_t
numOfOutput
=
pSup
->
numOfExprs
;
int64_t
*
tsCols
=
extractTsCol
(
pBlock
,
iaInfo
);
uint64_t
tableGroupId
=
pBlock
->
info
.
groupId
;
TSKEY
blockStart
Ts
=
getStartTsKey
(
&
pBlock
->
info
.
window
,
tsCols
);
TSKEY
curr
Ts
=
getStartTsKey
(
&
pBlock
->
info
.
window
,
tsCols
);
SResultRow
*
pResult
=
NULL
;
STimeWindow
win
;
win
.
skey
=
blockStartTs
;
// there is an result exists
if
(
miaInfo
->
curTs
!=
INT64_MIN
)
{
ASSERT
(
taosHashGetSize
(
iaInfo
->
aggSup
.
pResultRowHashTable
)
==
1
);
if
(
currTs
!=
miaInfo
->
curTs
)
{
outputMergeAlignedIntervalResult
(
pOperatorInfo
,
tableGroupId
,
pResultBlock
,
miaInfo
->
curTs
);
miaInfo
->
curTs
=
INT64_MIN
;
}
}
STimeWindow
win
=
{
0
};
win
.
skey
=
currTs
;
win
.
ekey
=
taosTimeAdd
(
win
.
skey
,
iaInfo
->
interval
.
interval
,
iaInfo
->
interval
.
intervalUnit
,
iaInfo
->
interval
.
precision
)
-
1
;
...
...
@@ -4634,41 +4643,48 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
TSKEY
currTs
=
blockStartTs
;
TSKEY
currPos
=
startPos
;
miaInfo
->
curTs
=
win
.
skey
;
int32_t
currPos
=
startPos
;
STimeWindow
currWin
=
win
;
while
(
1
)
{
++
currPos
;
if
(
currPos
>=
pBlock
->
info
.
rows
)
{
break
;
}
while
(
++
currPos
<
pBlock
->
info
.
rows
)
{
if
(
tsCols
[
currPos
]
==
currTs
)
{
continue
;
}
else
{
updateTimeWindowInfo
(
&
iaInfo
->
twAggSup
.
timeWindowData
,
&
currWin
,
true
);
doApplyFunctions
(
pTaskInfo
,
pSup
->
pCtx
,
&
currWin
,
&
iaInfo
->
twAggSup
.
timeWindowData
,
startPos
,
currPos
-
startPos
,
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
inputOrder
);
outputMergeAlignedIntervalResult
(
pOperatorInfo
,
tableGroupId
,
pResultBlock
,
currTs
);
currTs
=
tsCols
[
currPos
];
currWin
.
skey
=
currTs
;
currWin
.
ekey
=
taosTimeAdd
(
currWin
.
skey
,
iaInfo
->
interval
.
interval
,
iaInfo
->
interval
.
intervalUnit
,
iaInfo
->
interval
.
precision
)
-
1
;
startPos
=
currPos
;
ret
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
currWin
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
tableGroupId
,
pSup
->
pCtx
,
numOfOutput
,
pSup
->
rowEntryInfoOffset
,
&
iaInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
updateTimeWindowInfo
(
&
iaInfo
->
twAggSup
.
timeWindowData
,
&
currWin
,
true
);
doApplyFunctions
(
pTaskInfo
,
pSup
->
pCtx
,
&
currWin
,
&
iaInfo
->
twAggSup
.
timeWindowData
,
startPos
,
currPos
-
startPos
,
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
inputOrder
);
outputMergeAlignedIntervalResult
(
pOperatorInfo
,
tableGroupId
,
pResultBlock
,
currTs
);
miaInfo
->
curTs
=
INT64_MIN
;
currTs
=
tsCols
[
currPos
];
currWin
.
skey
=
currTs
;
currWin
.
ekey
=
taosTimeAdd
(
currWin
.
skey
,
iaInfo
->
interval
.
interval
,
iaInfo
->
interval
.
intervalUnit
,
iaInfo
->
interval
.
precision
)
-
1
;
startPos
=
currPos
;
ret
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
currWin
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
tableGroupId
,
pSup
->
pCtx
,
numOfOutput
,
pSup
->
rowEntryInfoOffset
,
&
iaInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
miaInfo
->
curTs
=
currWin
.
skey
;
}
updateTimeWindowInfo
(
&
iaInfo
->
twAggSup
.
timeWindowData
,
&
currWin
,
true
);
doApplyFunctions
(
pTaskInfo
,
pSup
->
pCtx
,
&
currWin
,
&
iaInfo
->
twAggSup
.
timeWindowData
,
startPos
,
currPos
-
startPos
,
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
inputOrder
);
outputMergeAlignedIntervalResult
(
pOperatorInfo
,
tableGroupId
,
pResultBlock
,
currTs
);
if
(
currPos
>=
pBlock
->
info
.
rows
)
{
// we need to see next block if exists
}
else
{
ASSERT
(
0
);
outputMergeAlignedIntervalResult
(
pOperatorInfo
,
tableGroupId
,
pResultBlock
,
currTs
);
miaInfo
->
curTs
=
INT64_MIN
;
}
}
static
SSDataBlock
*
doMergeAlignedIntervalAgg
(
SOperatorInfo
*
pOperator
)
{
...
...
@@ -4682,12 +4698,14 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
SSDataBlock
*
pRes
=
iaInfo
->
binfo
.
pRes
;
blockDataCleanup
(
pRes
);
blockDataEnsureCapacity
(
pRes
,
pOperator
->
resultInfo
.
capacity
);
if
(
!
miaInfo
->
inputBlocksFinished
)
{
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
int32_t
scanFlag
=
MAIN_SCAN
;
while
(
1
)
{
SSDataBlock
*
pBlock
=
NULL
;
if
(
miaInfo
->
prefetchedBlock
==
NULL
)
{
...
...
@@ -4699,6 +4717,14 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
}
if
(
pBlock
==
NULL
)
{
// close last unfinalized time window
if
(
miaInfo
->
curTs
!=
INT64_MIN
)
{
ASSERT
(
taosHashGetSize
(
iaInfo
->
aggSup
.
pResultRowHashTable
)
==
1
);
outputMergeAlignedIntervalResult
(
pOperator
,
miaInfo
->
groupId
,
pRes
,
miaInfo
->
curTs
);
miaInfo
->
curTs
=
INT64_MIN
;
}
doSetOperatorCompleted
(
pOperator
);
miaInfo
->
inputBlocksFinished
=
true
;
break
;
}
...
...
@@ -4707,7 +4733,11 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
miaInfo
->
hasGroupId
=
true
;
miaInfo
->
groupId
=
pBlock
->
info
.
groupId
;
}
else
if
(
miaInfo
->
groupId
!=
pBlock
->
info
.
groupId
)
{
// if there are unclosed time window, close it firstly.
ASSERT
(
miaInfo
->
curTs
!=
INT64_MIN
);
outputMergeAlignedIntervalResult
(
pOperator
,
miaInfo
->
groupId
,
pRes
,
miaInfo
->
curTs
);
miaInfo
->
prefetchedBlock
=
pBlock
;
miaInfo
->
curTs
=
INT64_MIN
;
break
;
}
...
...
@@ -4722,11 +4752,8 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
pRes
->
info
.
groupId
=
miaInfo
->
groupId
;
}
miaInfo
->
hasGroupId
=
false
;
if
(
miaInfo
->
inputBlocksFinished
)
{
doSetOperatorCompleted
(
pOperator
);
}
miaInfo
->
hasGroupId
=
false
;
size_t
rows
=
pRes
->
info
.
rows
;
pOperator
->
resultInfo
.
totalRows
+=
rows
;
...
...
@@ -4752,6 +4779,8 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
miaInfo
->
pCondition
=
pCondition
;
miaInfo
->
curTs
=
INT64_MIN
;
iaInfo
->
win
=
pTaskInfo
->
window
;
iaInfo
->
inputOrder
=
TSDB_ORDER_ASC
;
iaInfo
->
interval
=
*
pInterval
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录