Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a96193cf
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看板
未验证
提交
a96193cf
编写于
8月 11, 2022
作者:
S
shenglian-zhou
提交者:
GitHub
8月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15983 from taosdata/szhou/fixbug
fix: add multi-timeline support for session and state
上级
12373271
009777a7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
16 deletion
+20
-16
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-0
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+19
-16
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
a96193cf
...
...
@@ -675,6 +675,7 @@ typedef struct SWindowRowsSup {
TSKEY
prevTs
;
int32_t
startRowIndex
;
int32_t
numOfRows
;
uint64_t
groupId
;
}
SWindowRowsSup
;
typedef
struct
SSessionAggOperatorInfo
{
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
a96193cf
...
...
@@ -90,16 +90,18 @@ static void updateTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pWin, b
ts
[
4
]
=
pWin
->
ekey
+
delta
;
// window end key
}
static
void
doKeepTuple
(
SWindowRowsSup
*
pRowSup
,
int64_t
ts
)
{
static
void
doKeepTuple
(
SWindowRowsSup
*
pRowSup
,
int64_t
ts
,
uint64_t
groupId
)
{
pRowSup
->
win
.
ekey
=
ts
;
pRowSup
->
prevTs
=
ts
;
pRowSup
->
numOfRows
+=
1
;
pRowSup
->
groupId
=
groupId
;
}
static
void
doKeepNewWindowStartInfo
(
SWindowRowsSup
*
pRowSup
,
const
int64_t
*
tsList
,
int32_t
rowIndex
)
{
static
void
doKeepNewWindowStartInfo
(
SWindowRowsSup
*
pRowSup
,
const
int64_t
*
tsList
,
int32_t
rowIndex
,
uint64_t
groupId
)
{
pRowSup
->
startRowIndex
=
rowIndex
;
pRowSup
->
numOfRows
=
0
;
pRowSup
->
win
.
skey
=
tsList
[
rowIndex
];
pRowSup
->
groupId
=
groupId
;
}
static
FORCE_INLINE
int32_t
getForwardStepsInBlock
(
int32_t
numOfRows
,
__block_search_fn_t
searchFn
,
TSKEY
ekey
,
...
...
@@ -1156,7 +1158,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
char
*
val
=
colDataGetData
(
pStateColInfoData
,
j
);
if
(
!
pInfo
->
hasKey
)
{
if
(
gid
!=
pRowSup
->
groupId
||
!
pInfo
->
hasKey
)
{
// todo extract method
if
(
IS_VAR_DATA_TYPE
(
pInfo
->
stateKey
.
type
))
{
varDataCopy
(
pInfo
->
stateKey
.
pData
,
val
);
...
...
@@ -1166,10 +1168,10 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
pInfo
->
hasKey
=
true
;
doKeepNewWindowStartInfo
(
pRowSup
,
tsList
,
j
);
doKeepTuple
(
pRowSup
,
tsList
[
j
]);
doKeepNewWindowStartInfo
(
pRowSup
,
tsList
,
j
,
gid
);
doKeepTuple
(
pRowSup
,
tsList
[
j
]
,
gid
);
}
else
if
(
compareVal
(
val
,
&
pInfo
->
stateKey
))
{
doKeepTuple
(
pRowSup
,
tsList
[
j
]);
doKeepTuple
(
pRowSup
,
tsList
[
j
]
,
gid
);
if
(
j
==
0
&&
pRowSup
->
startRowIndex
!=
0
)
{
pRowSup
->
startRowIndex
=
0
;
}
...
...
@@ -1191,8 +1193,8 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
pRowSup
->
numOfRows
,
NULL
,
pBlock
->
info
.
rows
,
numOfOutput
,
TSDB_ORDER_ASC
);
// here we start a new session window
doKeepNewWindowStartInfo
(
pRowSup
,
tsList
,
j
);
doKeepTuple
(
pRowSup
,
tsList
[
j
]);
doKeepNewWindowStartInfo
(
pRowSup
,
tsList
,
j
,
gid
);
doKeepTuple
(
pRowSup
,
tsList
[
j
]
,
gid
);
// todo extract method
if
(
IS_VAR_DATA_TYPE
(
pInfo
->
stateKey
.
type
))
{
...
...
@@ -1935,7 +1937,7 @@ _error:
return
NULL
;
}
// todo handle multiple t
ables cases.
// todo handle multiple t
imeline cases. assume no timeline interweaving
static
void
doSessionWindowAggImpl
(
SOperatorInfo
*
pOperator
,
SSessionAggOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
...
...
@@ -1959,12 +1961,13 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
// In case of ascending or descending order scan data, only one time window needs to be kepted for each table.
TSKEY
*
tsList
=
(
TSKEY
*
)
pColInfoData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
if
(
pInfo
->
winSup
.
prevTs
==
INT64_MIN
)
{
doKeepNewWindowStartInfo
(
pRowSup
,
tsList
,
j
);
doKeepTuple
(
pRowSup
,
tsList
[
j
]);
}
else
if
(
tsList
[
j
]
-
pRowSup
->
prevTs
<=
gap
&&
(
tsList
[
j
]
-
pRowSup
->
prevTs
)
>=
0
)
{
if
(
gid
!=
pRowSup
->
groupId
||
pInfo
->
winSup
.
prevTs
==
INT64_MIN
)
{
doKeepNewWindowStartInfo
(
pRowSup
,
tsList
,
j
,
gid
);
doKeepTuple
(
pRowSup
,
tsList
[
j
],
gid
);
}
else
if
((
tsList
[
j
]
-
pRowSup
->
prevTs
>=
0
)
&&
tsList
[
j
]
-
pRowSup
->
prevTs
<=
gap
||
(
pRowSup
->
prevTs
-
tsList
[
j
]
>=
0
)
&&
(
pRowSup
->
prevTs
-
tsList
[
j
]
<=
gap
))
{
// The gap is less than the threshold, so it belongs to current session window that has been opened already.
doKeepTuple
(
pRowSup
,
tsList
[
j
]);
doKeepTuple
(
pRowSup
,
tsList
[
j
]
,
gid
);
if
(
j
==
0
&&
pRowSup
->
startRowIndex
!=
0
)
{
pRowSup
->
startRowIndex
=
0
;
}
...
...
@@ -1987,8 +1990,8 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
pRowSup
->
numOfRows
,
NULL
,
pBlock
->
info
.
rows
,
numOfOutput
,
TSDB_ORDER_ASC
);
// here we start a new session window
doKeepNewWindowStartInfo
(
pRowSup
,
tsList
,
j
);
doKeepTuple
(
pRowSup
,
tsList
[
j
]);
doKeepNewWindowStartInfo
(
pRowSup
,
tsList
,
j
,
gid
);
doKeepTuple
(
pRowSup
,
tsList
[
j
]
,
gid
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录