Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f78208c3
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看板
未验证
提交
f78208c3
编写于
8月 01, 2023
作者:
H
Haojun Liao
提交者:
GitHub
8月 01, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22280 from taosdata/fix/TD-25496
reload state window state
上级
4245077b
71b000f0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
7 deletion
+32
-7
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+30
-7
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+1
-0
source/libs/stream/src/streamState.c
source/libs/stream/src/streamState.c
+1
-0
未找到文件。
source/libs/executor/src/timewindowoperator.c
浏览文件 @
f78208c3
...
...
@@ -4057,13 +4057,20 @@ bool isEqualStateKey(SStateWindowInfo* pWin, char* pKeyData) {
bool
compareStateKey
(
void
*
data
,
void
*
key
)
{
if
(
!
data
||
!
key
)
{
return
fals
e
;
return
tru
e
;
}
SStateKeys
*
stateKey
=
(
SStateKeys
*
)
key
;
stateKey
->
pData
=
(
char
*
)
key
+
sizeof
(
SStateKeys
);
return
compareVal
(
data
,
stateKey
);
}
bool
compareWinStateKey
(
SStateKeys
*
left
,
SStateKeys
*
right
)
{
if
(
!
left
||
!
right
)
{
return
false
;
}
return
compareVal
(
left
->
pData
,
right
);
}
void
setStateOutputBuf
(
SStreamAggSupporter
*
pAggSup
,
TSKEY
ts
,
uint64_t
groupId
,
char
*
pKeyData
,
SStateWindowInfo
*
pCurWin
,
SStateWindowInfo
*
pNextWin
)
{
int32_t
size
=
pAggSup
->
resultRowSize
;
...
...
@@ -4086,10 +4093,14 @@ void setStateOutputBuf(SStreamAggSupporter* pAggSup, TSKEY ts, uint64_t groupId,
pCurWin
->
winInfo
.
pOutputBuf
=
taosMemoryCalloc
(
1
,
size
);
pCurWin
->
pStateKey
=
(
SStateKeys
*
)((
char
*
)
pCurWin
->
winInfo
.
pOutputBuf
+
(
pAggSup
->
resultRowSize
-
pAggSup
->
stateKeySize
));
pCurWin
->
pStateKey
->
bytes
=
pAggSup
->
stateKeySize
-
sizeof
(
SStateKeys
);
pCurWin
->
pStateKey
->
type
=
pAggSup
->
stateKeyType
;
pCurWin
->
pStateKey
->
pData
=
(
char
*
)
pCurWin
->
pStateKey
+
sizeof
(
SStateKeys
);
pCurWin
->
pStateKey
->
isNull
=
false
;
pCurWin
->
pStateKey
->
bytes
=
pAggSup
->
stateKeySize
-
sizeof
(
SStateKeys
);
pCurWin
->
pStateKey
->
type
=
pAggSup
->
stateKeyType
;
pCurWin
->
pStateKey
->
pData
=
(
char
*
)
pCurWin
->
pStateKey
+
sizeof
(
SStateKeys
);
pCurWin
->
pStateKey
->
isNull
=
false
;
pCurWin
->
winInfo
.
sessionWin
.
groupId
=
groupId
;
pCurWin
->
winInfo
.
sessionWin
.
win
.
skey
=
ts
;
pCurWin
->
winInfo
.
sessionWin
.
win
.
ekey
=
ts
;
qDebug
(
"===stream===reset state win key. skey:%"
PRId64
", endkey:%"
PRId64
,
pCurWin
->
winInfo
.
sessionWin
.
win
.
skey
,
pCurWin
->
winInfo
.
sessionWin
.
win
.
ekey
);
}
if
(
code
==
TSDB_CODE_SUCCESS
)
{
...
...
@@ -4241,6 +4252,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
SStreamStateAggOperatorInfo
*
pInfo
=
pOperator
->
info
;
SOptrBasicInfo
*
pBInfo
=
&
pInfo
->
binfo
;
qDebug
(
"===stream=== stream state agg"
);
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
doBuildDeleteDataBlock
(
pOperator
,
pInfo
->
pSeDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
if
(
pInfo
->
pDelRes
->
info
.
rows
>
0
)
{
...
...
@@ -4340,6 +4352,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
void
streamStateReleaseState
(
SOperatorInfo
*
pOperator
)
{
SStreamStateAggOperatorInfo
*
pInfo
=
pOperator
->
info
;
int32_t
resSize
=
taosArrayGetSize
(
pInfo
->
historyWins
)
*
sizeof
(
SSessionKey
);
qDebug
(
"===stream=== relase state. save result count:%d"
,
(
int32_t
)
taosArrayGetSize
(
pInfo
->
historyWins
));
pInfo
->
streamAggSup
.
stateStore
.
streamStateSaveInfo
(
pInfo
->
streamAggSup
.
pState
,
STREAM_STATE_OP_STATE_NAME
,
strlen
(
STREAM_STATE_OP_STATE_NAME
),
pInfo
->
historyWins
->
pData
,
resSize
);
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
if
(
downstream
->
fpSet
.
releaseStreamStateFn
)
{
...
...
@@ -4365,6 +4378,7 @@ static void compactStateWindow(SOperatorInfo* pOperator, SResultWindowInfo* pCur
compactFunctions
(
pSup
->
pCtx
,
pAggSup
->
pDummyCtx
,
numOfOutput
,
pTaskInfo
,
&
pInfo
->
twAggSup
.
timeWindowData
);
tSimpleHashRemove
(
pStUpdated
,
&
pNextWin
->
sessionWin
,
sizeof
(
SSessionKey
));
if
(
pNextWin
->
isOutput
&&
pStDeleted
)
{
qDebug
(
"===stream=== save delete window info %"
PRId64
", %"
PRIu64
,
pNextWin
->
sessionWin
.
win
.
skey
,
pNextWin
->
sessionWin
.
groupId
);
saveDeleteRes
(
pStDeleted
,
pNextWin
->
sessionWin
);
}
removeSessionResult
(
pStUpdated
,
pAggSup
->
pResultRows
,
pNextWin
->
sessionWin
);
...
...
@@ -4383,19 +4397,28 @@ void streamStateReloadState(SOperatorInfo* pOperator) {
int32_t
code
=
pAggSup
->
stateStore
.
streamStateGetInfo
(
pAggSup
->
pState
,
STREAM_STATE_OP_STATE_NAME
,
strlen
(
STREAM_STATE_OP_STATE_NAME
),
&
pBuf
,
&
size
);
int32_t
num
=
size
/
sizeof
(
SSessionKey
);
qDebug
(
"===stream=== reload state. get result count:%d"
,
num
);
SSessionKey
*
pSeKeyBuf
=
(
SSessionKey
*
)
pBuf
;
ASSERT
(
size
==
num
*
sizeof
(
SSessionKey
));
if
(
!
pInfo
->
pSeUpdated
&&
num
>
0
)
{
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
pInfo
->
pSeUpdated
=
tSimpleHashInit
(
64
,
hashFn
);
}
if
(
!
pInfo
->
pSeDeleted
&&
num
>
0
)
{
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
pInfo
->
pSeDeleted
=
tSimpleHashInit
(
64
,
hashFn
);
}
for
(
int32_t
i
=
0
;
i
<
num
;
i
++
)
{
SStateWindowInfo
curInfo
=
{
0
};
SStateWindowInfo
nextInfo
=
{
0
};
SStateWindowInfo
dummy
=
{
0
};
qDebug
(
"===stream=== reload state. try process result %"
PRId64
", %"
PRIu64
", index:%d"
,
pSeKeyBuf
[
i
].
win
.
skey
,
pSeKeyBuf
[
i
].
groupId
,
i
);
setStateOutputBuf
(
pAggSup
,
pSeKeyBuf
[
i
].
win
.
skey
,
pSeKeyBuf
[
i
].
groupId
,
NULL
,
&
curInfo
,
&
nextInfo
);
if
(
compareStateKey
(
curInfo
.
pStateKey
,
nextInfo
.
pStateKey
))
{
compactStateWindow
(
pOperator
,
&
curInfo
.
winInfo
,
&
nextInfo
.
winInfo
,
pInfo
->
pSeUpdated
,
pInfo
->
pSeUpdated
);
bool
cpRes
=
compareWinStateKey
(
curInfo
.
pStateKey
,
nextInfo
.
pStateKey
);
qDebug
(
"===stream=== reload state. next window info %"
PRId64
", %"
PRIu64
", compare:%d"
,
nextInfo
.
winInfo
.
sessionWin
.
win
.
skey
,
nextInfo
.
winInfo
.
sessionWin
.
groupId
,
cpRes
);
if
(
cpRes
)
{
compactStateWindow
(
pOperator
,
&
curInfo
.
winInfo
,
&
nextInfo
.
winInfo
,
pInfo
->
pSeUpdated
,
pInfo
->
pSeDeleted
);
qDebug
(
"===stream=== reload state. save result %"
PRId64
", %"
PRIu64
,
curInfo
.
winInfo
.
sessionWin
.
win
.
skey
,
curInfo
.
winInfo
.
sessionWin
.
groupId
);
if
(
pInfo
->
twAggSup
.
calTrigger
==
STREAM_TRIGGER_AT_ONCE
)
{
saveResult
(
curInfo
.
winInfo
,
pInfo
->
pSeUpdated
);
}
else
if
(
pInfo
->
twAggSup
.
calTrigger
==
STREAM_TRIGGER_WINDOW_CLOSE
)
{
...
...
source/libs/stream/src/streamExec.c
浏览文件 @
f78208c3
...
...
@@ -581,6 +581,7 @@ int32_t streamTryExec(SStreamTask* pTask) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
streamSchedExec
(
pTask
);
}
else
{
atomic_store_8
(
&
pTask
->
status
.
schedStatus
,
TASK_SCHED_STATUS__INACTIVE
);
qDebug
(
"s-task:%s exec completed, status:%s, sched-status:%d"
,
id
,
streamGetTaskStatusStr
(
pTask
->
status
.
taskStatus
),
...
...
source/libs/stream/src/streamState.c
浏览文件 @
f78208c3
...
...
@@ -729,6 +729,7 @@ void streamStateFreeVal(void* val) {
int32_t
streamStateSessionPut
(
SStreamState
*
pState
,
const
SSessionKey
*
key
,
const
void
*
value
,
int32_t
vLen
)
{
#ifdef USE_ROCKSDB
qDebug
(
"===stream===save skey:%"
PRId64
", ekey:%"
PRId64
", groupId:%"
PRIu64
,
key
->
win
.
skey
,
key
->
win
.
ekey
,
key
->
groupId
);
return
streamStateSessionPut_rocksdb
(
pState
,
key
,
value
,
vLen
);
#else
SStateSessionKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录