Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
68cfa54e
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1181
Star
22014
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,发现更多精彩内容 >>
提交
68cfa54e
编写于
6月 30, 2022
作者:
5
54liuyao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(stream): ignore close window
上级
0f922533
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
13 deletion
+50
-13
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+50
-13
未找到文件。
source/libs/executor/src/timewindowoperator.c
浏览文件 @
68cfa54e
...
...
@@ -1246,6 +1246,9 @@ void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SExprS
pCtx
[
i
].
fpSet
.
init
(
&
pCtx
[
i
],
pResInfo
);
}
}
SFilePage
*
bufPage
=
getBufPage
(
pResultBuf
,
p1
->
pageId
);
setBufPageDirty
(
bufPage
,
true
);
releaseBufPage
(
pResultBuf
,
bufPage
);
}
bool
doClearWindow
(
SAggSupporter
*
pAggSup
,
SExprSupp
*
pSup
,
char
*
pData
,
int16_t
bytes
,
uint64_t
groupId
,
...
...
@@ -3171,6 +3174,10 @@ static void doClearSessionWindows(SStreamAggSupporter* pAggSup, SExprSupp* pSup,
getSessionTimeWindow
(
pAggSup
,
tsCols
[
i
],
INT64_MIN
,
pBlock
->
info
.
groupId
,
gap
,
&
winIndex
);
step
=
updateSessionWindowInfo
(
pCurWin
,
tsCols
,
NULL
,
pBlock
->
info
.
rows
,
i
,
gap
,
NULL
);
ASSERT
(
isInWindow
(
pCurWin
,
tsCols
[
i
],
gap
));
if
(
pCurWin
->
pos
.
pageId
==
-
1
)
{
// window has been closed.
continue
;
}
doClearWindowImpl
(
&
pCurWin
->
pos
,
pAggSup
->
pResultBuf
,
pSup
,
numOfOutput
);
if
(
result
)
{
taosArrayPush
(
result
,
pCurWin
);
...
...
@@ -3246,12 +3253,12 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin
setWindowOutputBuf
(
pChWin
,
&
pChResult
,
pChild
->
exprSupp
.
pCtx
,
groupId
,
numOfOutput
,
pChild
->
exprSupp
.
rowEntryInfoOffset
,
&
pChInfo
->
streamAggSup
,
pTaskInfo
);
compactFunctions
(
pSup
->
pCtx
,
pChild
->
exprSupp
.
pCtx
,
numOfOutput
,
pTaskInfo
);
SFilePage
*
bufPage
=
getBufPage
(
pInfo
->
streamAggSup
.
pResultBuf
,
pChWin
->
pos
.
pageId
);
setBufPageDirty
(
bufPage
,
true
);
releaseBufPage
(
pInfo
->
streamAggSup
.
pResultBuf
,
bufPage
);
SFilePage
*
bufPage
=
getBufPage
(
pChInfo
->
streamAggSup
.
pResultBuf
,
pChWin
->
pos
.
pageId
);
releaseBufPage
(
pChInfo
->
streamAggSup
.
pResultBuf
,
bufPage
);
continue
;
}
else
if
(
!
pChWin
->
isClosed
)
{
break
;
}
break
;
}
}
SFilePage
*
bufPage
=
getBufPage
(
pInfo
->
streamAggSup
.
pResultBuf
,
pParentWin
->
pos
.
pageId
);
...
...
@@ -3265,7 +3272,8 @@ typedef SResultWindowInfo* (*__get_win_info_)(void*);
SResultWindowInfo
*
getResWinForSession
(
void
*
pData
)
{
return
(
SResultWindowInfo
*
)
pData
;
}
SResultWindowInfo
*
getResWinForState
(
void
*
pData
)
{
return
&
((
SStateWindowInfo
*
)
pData
)
->
winInfo
;
}
int32_t
closeSessionWindow
(
SHashObj
*
pHashMap
,
STimeWindowAggSupp
*
pTwSup
,
SArray
*
pClosed
,
__get_win_info_
fn
)
{
int32_t
closeSessionWindow
(
SHashObj
*
pHashMap
,
STimeWindowAggSupp
*
pTwSup
,
SArray
*
pClosed
,
__get_win_info_
fn
,
bool
delete
)
{
// Todo(liuyao) save window to tdb
void
**
pIte
=
NULL
;
size_t
keyLen
=
0
;
...
...
@@ -3279,10 +3287,18 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra
if
(
isCloseWindow
(
&
pSeWin
->
win
,
pTwSup
))
{
if
(
!
pSeWin
->
isClosed
)
{
pSeWin
->
isClosed
=
true
;
if
(
pTwSup
->
calTrigger
==
STREAM_TRIGGER_WINDOW_CLOSE
)
{
if
(
pTwSup
->
calTrigger
==
STREAM_TRIGGER_WINDOW_CLOSE
&&
pClosed
)
{
int32_t
code
=
saveResult
(
pSeWin
->
win
.
skey
,
pSeWin
->
pos
.
pageId
,
pSeWin
->
pos
.
offset
,
*
pGroupId
,
pClosed
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
pSeWin
->
isOutput
=
true
;
}
if
(
delete
)
{
taosArrayRemove
(
pWins
,
i
);
i
--
;
size
=
taosArrayGetSize
(
pWins
);
}
}
continue
;
}
...
...
@@ -3292,6 +3308,16 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra
return
TSDB_CODE_SUCCESS
;
}
static
void
closeChildSessionWindow
(
SArray
*
pChildren
,
TSKEY
maxTs
,
bool
delete
)
{
int32_t
size
=
taosArrayGetSize
(
pChildren
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
SOperatorInfo
*
pChildOp
=
taosArrayGetP
(
pChildren
,
i
);
SStreamSessionAggOperatorInfo
*
pChInfo
=
pChildOp
->
info
;
pChInfo
->
twAggSup
.
maxTs
=
TMAX
(
pChInfo
->
twAggSup
.
maxTs
,
maxTs
);
closeSessionWindow
(
pChInfo
->
streamAggSup
.
pResultRows
,
&
pChInfo
->
twAggSup
,
NULL
,
getResWinForSession
,
delete
);
}
}
int32_t
getAllSessionWindow
(
SHashObj
*
pHashMap
,
SArray
*
pClosed
,
__get_win_info_
fn
)
{
void
**
pIte
=
NULL
;
while
((
pIte
=
taosHashIterate
(
pHashMap
,
pIte
))
!=
NULL
)
{
...
...
@@ -3339,6 +3365,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
if
(
pBlock
==
NULL
)
{
break
;
}
printDataBlock
(
pBlock
,
IS_FINAL_OP
(
pInfo
)
?
"Final Session Recv"
:
"Single Session Recv"
);
if
(
pBlock
->
info
.
type
==
STREAM_CLEAR
)
{
SArray
*
pWins
=
taosArrayInit
(
16
,
sizeof
(
SResultWindowInfo
));
...
...
@@ -3385,7 +3412,9 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
// restore the value
pOperator
->
status
=
OP_RES_TO_RETURN
;
closeSessionWindow
(
pInfo
->
streamAggSup
.
pResultRows
,
&
pInfo
->
twAggSup
,
pUpdated
,
getResWinForSession
);
closeSessionWindow
(
pInfo
->
streamAggSup
.
pResultRows
,
&
pInfo
->
twAggSup
,
pUpdated
,
getResWinForSession
,
pInfo
->
ignoreCloseWindow
);
closeChildSessionWindow
(
pInfo
->
pChildren
,
pInfo
->
twAggSup
.
maxTs
,
pInfo
->
ignoreCloseWindow
);
copyUpdateResult
(
pStUpdated
,
pUpdated
);
taosHashCleanup
(
pStUpdated
);
...
...
@@ -3437,10 +3466,11 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
}
else
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
doBuildDeleteDataBlock
(
pInfo
->
pStDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
if
(
pInfo
->
pDelRes
->
info
.
rows
>
0
)
{
printDataBlock
(
pInfo
->
pDelRes
,
"Semi Session"
);
return
pInfo
->
pDelRes
;
}
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
if
(
p
Info
->
binfo
.
pRes
->
info
.
rows
==
0
)
{
if
(
p
BInfo
->
pRes
->
info
.
rows
==
0
)
{
pOperator
->
status
=
OP_EXEC_DONE
;
if
(
pInfo
->
pUpdateRes
->
info
.
rows
==
0
)
{
// semi interval operator clear disk buffer
...
...
@@ -3449,9 +3479,11 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
}
// process the rest of the data
pOperator
->
status
=
OP_OPENED
;
printDataBlock
(
pInfo
->
pUpdateRes
,
"Semi Session"
);
return
pInfo
->
pUpdateRes
;
}
return
pInfo
->
binfo
.
pRes
;
printDataBlock
(
pBInfo
->
pRes
,
"Semi Session"
);
return
pBInfo
->
pRes
;
}
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
...
...
@@ -3495,21 +3527,24 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
finalizeUpdatedResult
(
pOperator
->
exprSupp
.
numOfExprs
,
pInfo
->
streamAggSup
.
pResultBuf
,
pUpdated
,
pSup
->
rowEntryInfoOffset
);
initMultiResInfoFromArrayList
(
&
pInfo
->
groupResInfo
,
pUpdated
);
blockDataEnsureCapacity
(
p
Info
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
blockDataEnsureCapacity
(
p
BInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
doBuildDeleteDataBlock
(
pInfo
->
pStDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
if
(
pInfo
->
pDelRes
->
info
.
rows
>
0
)
{
printDataBlock
(
pInfo
->
pDelRes
,
"Semi Session"
);
return
pInfo
->
pDelRes
;
}
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
bi
nfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
if
(
p
Info
->
binfo
.
pRes
->
info
.
rows
==
0
)
{
doBuildResultDatablock
(
pOperator
,
pBI
nfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
if
(
p
BInfo
->
pRes
->
info
.
rows
==
0
)
{
pOperator
->
status
=
OP_EXEC_DONE
;
if
(
pInfo
->
pUpdateRes
->
info
.
rows
==
0
)
{
return
NULL
;
}
// process the rest of the data
pOperator
->
status
=
OP_OPENED
;
printDataBlock
(
pInfo
->
pUpdateRes
,
"Semi Session"
);
return
pInfo
->
pUpdateRes
;
}
printDataBlock
(
pBInfo
->
pRes
,
"Semi Session"
);
return
pBInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pBInfo
->
pRes
;
}
...
...
@@ -3867,7 +3902,9 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
// restore the value
pOperator
->
status
=
OP_RES_TO_RETURN
;
closeSessionWindow
(
pInfo
->
streamAggSup
.
pResultRows
,
&
pInfo
->
twAggSup
,
pUpdated
,
getResWinForState
);
closeSessionWindow
(
pInfo
->
streamAggSup
.
pResultRows
,
&
pInfo
->
twAggSup
,
pUpdated
,
getResWinForState
,
pInfo
->
ignoreCloseWindow
);
closeChildSessionWindow
(
pInfo
->
pChildren
,
pInfo
->
twAggSup
.
maxTs
,
pInfo
->
ignoreCloseWindow
);
copyUpdateResult
(
pSeUpdated
,
pUpdated
);
taosHashCleanup
(
pSeUpdated
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录