Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c56bb64f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
c56bb64f
编写于
4月 26, 2023
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor timeslice operator
上级
d4c783b5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
98 addition
and
87 deletion
+98
-87
source/libs/executor/src/timesliceoperator.c
source/libs/executor/src/timesliceoperator.c
+98
-87
未找到文件。
source/libs/executor/src/timesliceoperator.c
浏览文件 @
c56bb64f
...
...
@@ -38,6 +38,8 @@ typedef struct STimeSliceOperatorInfo {
struct
SFillColInfo
*
pFillColInfo
;
// fill column info
int64_t
prevTs
;
bool
prevTsSet
;
uint64_t
groupId
;
SSDataBlock
*
pNextGroupRes
;
}
STimeSliceOperatorInfo
;
static
void
destroyTimeSliceOperatorInfo
(
void
*
param
);
...
...
@@ -456,6 +458,99 @@ static int32_t initKeeperInfo(STimeSliceOperatorInfo* pInfo, SSDataBlock* pBlock
return
TSDB_CODE_SUCCESS
;
}
static
void
doTimesliceImpl
(
SOperatorInfo
*
pOperator
,
STimeSliceOperatorInfo
*
pSliceInfo
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
)
{
SSDataBlock
*
pResBlock
=
pSliceInfo
->
pRes
;
SInterval
*
pInterval
=
&
pSliceInfo
->
interval
;
SColumnInfoData
*
pTsCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pSliceInfo
->
tsCol
.
slotId
);
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
i
)
{
int64_t
ts
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
);
// check for duplicate timestamps
if
(
checkDuplicateTimestamps
(
pSliceInfo
,
pTsCol
,
i
,
pBlock
->
info
.
rows
))
{
T_LONG_JMP
(
pTaskInfo
->
env
,
TSDB_CODE_FUNC_DUP_TIMESTAMP
);
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
setOperatorCompleted
(
pOperator
);
break
;
}
if
(
ts
==
pSliceInfo
->
current
)
{
addCurrentRowToResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
,
pBlock
,
i
);
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
setOperatorCompleted
(
pOperator
);
break
;
}
}
else
if
(
ts
<
pSliceInfo
->
current
)
{
// in case of interpolation window starts and ends between two datapoints, fill(prev) need to interpolate
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
// in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate
doKeepNextRows
(
pSliceInfo
,
pBlock
,
i
+
1
);
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
if
(
nextTs
>
pSliceInfo
->
current
)
{
while
(
pSliceInfo
->
current
<
nextTs
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
if
(
!
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
,
false
)
&&
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
break
;
}
else
{
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
setOperatorCompleted
(
pOperator
);
break
;
}
}
else
{
// ignore current row, and do nothing
}
}
else
{
// it is the last row of current block
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
}
}
else
{
// ts > pSliceInfo->current
// in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate
doKeepNextRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
while
(
pSliceInfo
->
current
<
ts
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
if
(
!
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
,
true
)
&&
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
break
;
}
else
{
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
}
// add current row if timestamp match
if
(
ts
==
pSliceInfo
->
current
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
addCurrentRowToResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
,
pBlock
,
i
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
setOperatorCompleted
(
pOperator
);
break
;
}
}
}
}
static
SSDataBlock
*
doTimeslice
(
SOperatorInfo
*
pOperator
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
...
...
@@ -491,93 +586,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock
(
pSup
,
pBlock
,
order
,
MAIN_SCAN
,
true
);
SColumnInfoData
*
pTsCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pSliceInfo
->
tsCol
.
slotId
);
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
i
)
{
int64_t
ts
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
);
// check for duplicate timestamps
if
(
checkDuplicateTimestamps
(
pSliceInfo
,
pTsCol
,
i
,
pBlock
->
info
.
rows
))
{
T_LONG_JMP
(
pTaskInfo
->
env
,
TSDB_CODE_FUNC_DUP_TIMESTAMP
);
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
setOperatorCompleted
(
pOperator
);
break
;
}
if
(
ts
==
pSliceInfo
->
current
)
{
addCurrentRowToResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
,
pBlock
,
i
);
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
setOperatorCompleted
(
pOperator
);
break
;
}
}
else
if
(
ts
<
pSliceInfo
->
current
)
{
// in case of interpolation window starts and ends between two datapoints, fill(prev) need to interpolate
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
// in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate
doKeepNextRows
(
pSliceInfo
,
pBlock
,
i
+
1
);
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
if
(
nextTs
>
pSliceInfo
->
current
)
{
while
(
pSliceInfo
->
current
<
nextTs
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
if
(
!
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
,
false
)
&&
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
break
;
}
else
{
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
setOperatorCompleted
(
pOperator
);
break
;
}
}
else
{
// ignore current row, and do nothing
}
}
else
{
// it is the last row of current block
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
}
}
else
{
// ts > pSliceInfo->current
// in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate
doKeepNextRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
while
(
pSliceInfo
->
current
<
ts
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
if
(
!
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
,
true
)
&&
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
break
;
}
else
{
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
}
// add current row if timestamp match
if
(
ts
==
pSliceInfo
->
current
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
addCurrentRowToResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
,
pBlock
,
i
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
setOperatorCompleted
(
pOperator
);
break
;
}
}
}
doTimesliceImpl
(
pOperator
,
pSliceInfo
,
pBlock
,
pTaskInfo
);
}
// check if need to interpolate after last datablock
...
...
@@ -643,6 +652,8 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode
pInfo
->
current
=
pInfo
->
win
.
skey
;
pInfo
->
prevTsSet
=
false
;
pInfo
->
prevTs
=
0
;
pInfo
->
groupId
=
0
;
pInfo
->
pNextGroupRes
=
NULL
;
if
(
downstream
->
operatorType
==
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
)
{
STableScanInfo
*
pScanInfo
=
(
STableScanInfo
*
)
downstream
->
info
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录