Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a7d21c9e
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
a7d21c9e
编写于
11月 08, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: interp fill linear ignore null values during calculation
上级
d590a38d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
135 deletion
+34
-135
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+0
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+34
-134
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
a7d21c9e
...
@@ -782,7 +782,6 @@ typedef struct STimeSliceOperatorInfo {
...
@@ -782,7 +782,6 @@ typedef struct STimeSliceOperatorInfo {
SArray
*
pPrevRow
;
// SArray<SGroupValue>
SArray
*
pPrevRow
;
// SArray<SGroupValue>
SArray
*
pNextRow
;
// SArray<SGroupValue>
SArray
*
pNextRow
;
// SArray<SGroupValue>
SArray
*
pLinearInfo
;
// SArray<SFillLinearInfo>
SArray
*
pLinearInfo
;
// SArray<SFillLinearInfo>
bool
fillLastPoint
;
bool
isPrevRowSet
;
bool
isPrevRowSet
;
bool
isNextRowSet
;
bool
isNextRowSet
;
int32_t
fillType
;
// fill type
int32_t
fillType
;
// fill type
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
a7d21c9e
...
@@ -1991,10 +1991,8 @@ static void doKeepNextRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
...
@@ -1991,10 +1991,8 @@ static void doKeepNextRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
pSliceInfo
->
isNextRowSet
=
true
;
pSliceInfo
->
isNextRowSet
=
true
;
}
}
static
void
doKeepLinearInfo
(
STimeSliceOperatorInfo
*
pSliceInfo
,
const
SSDataBlock
*
pBlock
,
int32_t
rowIndex
,
static
void
doKeepLinearInfo
(
STimeSliceOperatorInfo
*
pSliceInfo
,
const
SSDataBlock
*
pBlock
,
int32_t
rowIndex
)
{
bool
isLastRow
)
{
int32_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
bool
fillLastPoint
=
pSliceInfo
->
fillLastPoint
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pTsCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pSliceInfo
->
tsCol
.
slotId
);
SColumnInfoData
*
pTsCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pSliceInfo
->
tsCol
.
slotId
);
...
@@ -2002,30 +2000,21 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
...
@@ -2002,30 +2000,21 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
// null data should not be kept since it can not be used to perform interpolation
// null data should not be kept since it can not be used to perform interpolation
if
(
!
colDataIsNull_s
(
pColInfoData
,
i
))
{
if
(
!
colDataIsNull_s
(
pColInfoData
,
i
))
{
if
(
isLastRow
)
{
if
(
pLinearInfo
->
start
.
key
==
INT64_MIN
)
{
pLinearInfo
->
start
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
);
pLinearInfo
->
start
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
);
memcpy
(
pLinearInfo
->
start
.
val
,
colDataGetData
(
pColInfoData
,
rowIndex
),
pLinearInfo
->
bytes
);
memcpy
(
pLinearInfo
->
start
.
val
,
colDataGetData
(
pColInfoData
,
rowIndex
),
pLinearInfo
->
bytes
);
}
else
if
(
fillLastPoint
)
{
}
else
if
(
pLinearInfo
->
end
.
key
==
INT64_MAX
)
{
pLinearInfo
->
end
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
);
pLinearInfo
->
end
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
);
memcpy
(
pLinearInfo
->
end
.
val
,
colDataGetData
(
pColInfoData
,
rowIndex
),
pLinearInfo
->
bytes
);
memcpy
(
pLinearInfo
->
end
.
val
,
colDataGetData
(
pColInfoData
,
rowIndex
),
pLinearInfo
->
bytes
);
}
else
{
}
else
{
pLinearInfo
->
start
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
);
pLinearInfo
->
start
.
key
=
pLinearInfo
->
end
.
key
;
pLinearInfo
->
end
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
+
1
);
pLinearInfo
->
end
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
);
memcpy
(
pLinearInfo
->
start
.
val
,
pLinearInfo
->
end
.
val
,
pLinearInfo
->
bytes
);
char
*
val
;
memcpy
(
pLinearInfo
->
end
.
val
,
colDataGetData
(
pColInfoData
,
rowIndex
),
pLinearInfo
->
bytes
);
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
memcpy
(
pLinearInfo
->
start
.
val
,
val
,
pLinearInfo
->
bytes
);
val
=
colDataGetData
(
pColInfoData
,
rowIndex
+
1
);
memcpy
(
pLinearInfo
->
end
.
val
,
val
,
pLinearInfo
->
bytes
);
}
}
pLinearInfo
->
hasNull
=
false
;
}
else
{
pLinearInfo
->
hasNull
=
true
;
}
}
}
}
pSliceInfo
->
fillLastPoint
=
isLastRow
;
}
}
static
void
genInterpolationResult
(
STimeSliceOperatorInfo
*
pSliceInfo
,
SExprSupp
*
pExprSup
,
SSDataBlock
*
pResBlock
)
{
static
void
genInterpolationResult
(
STimeSliceOperatorInfo
*
pSliceInfo
,
SExprSupp
*
pExprSup
,
SSDataBlock
*
pResBlock
)
{
...
@@ -2209,15 +2198,9 @@ static int32_t initFillLinearInfo(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
...
@@ -2209,15 +2198,9 @@ static int32_t initFillLinearInfo(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
taosArrayPush
(
pInfo
->
pLinearInfo
,
&
linearInfo
);
taosArrayPush
(
pInfo
->
pLinearInfo
,
&
linearInfo
);
}
}
pInfo
->
fillLastPoint
=
false
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
bool
needToFillLastPoint
(
STimeSliceOperatorInfo
*
pSliceInfo
)
{
return
(
pSliceInfo
->
fillLastPoint
==
true
&&
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
);
}
static
int32_t
initKeeperInfo
(
STimeSliceOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
static
int32_t
initKeeperInfo
(
STimeSliceOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
int32_t
code
;
int32_t
code
;
code
=
initPrevRowsKeeper
(
pInfo
,
pBlock
);
code
=
initPrevRowsKeeper
(
pInfo
,
pBlock
);
...
@@ -2273,15 +2256,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
...
@@ -2273,15 +2256,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
i
)
{
int64_t
ts
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
);
int64_t
ts
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
);
if
(
i
==
0
&&
needToFillLastPoint
(
pSliceInfo
))
{
// first row in current block
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
,
false
);
while
(
pSliceInfo
->
current
<
ts
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
break
;
break
;
...
@@ -2313,94 +2287,44 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
...
@@ -2313,94 +2287,44 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
pResBlock
->
info
.
rows
+=
1
;
pResBlock
->
info
.
rows
+=
1
;
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
// for linear interpolation, always fill value between this and next points;
pSliceInfo
->
current
=
// if its the first point in data block, also fill values between previous(if there's any) and this point;
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
// if its the last point in data block, no need to fill, but reserve this point as the start value and do
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
// the interpolation when processing next data block.
doSetOperatorCompleted
(
pOperator
);
if
(
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
break
;
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
,
false
);
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
if
(
nextTs
>
pSliceInfo
->
current
)
{
while
(
pSliceInfo
->
current
<
nextTs
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
}
}
else
{
// it is the last row of current block
// store ts value as start, and calculate interp value when processing next block
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
,
true
);
}
}
else
{
// non-linear interpolation
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
}
}
}
else
if
(
ts
<
pSliceInfo
->
current
)
{
}
else
if
(
ts
<
pSliceInfo
->
current
)
{
// in case of interpolation window starts and ends between two datapoints, fill(prev) need to interpolate
// in case of interpolation window starts and ends between two datapoints, fill(prev) need to interpolate
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
if
(
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
// no need to increate pSliceInfo->current here
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
// pSliceInfo->current =
// in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate
// taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
doKeepNextRows
(
pSliceInfo
,
pBlock
,
i
+
1
);
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
,
false
);
if
(
nextTs
>
pSliceInfo
->
current
)
{
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
while
(
pSliceInfo
->
current
<
nextTs
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
if
(
nextTs
>
pSliceInfo
->
current
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
);
while
(
pSliceInfo
->
current
<
nextTs
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
);
pInterval
->
precision
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
}
}
}
else
{
// store ts value as start, and calculate interp value when processing next block
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
,
true
);
}
}
else
{
// non-linear interpolation
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
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
break
;
break
;
}
}
else
{
// ignore current row, and do nothing
}
}
}
else
{
// it is the last row of current block
}
else
{
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
// ignore current row, and do nothing
}
}
}
else
{
// it is the last row of current block
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
}
}
}
else
{
// ts > pSliceInfo->current
}
else
{
// ts > pSliceInfo->current
// in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate
// in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate
doKeepNextRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepNextRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
while
(
pSliceInfo
->
current
<
ts
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
while
(
pSliceInfo
->
current
<
ts
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
);
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
);
...
@@ -2436,32 +2360,8 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
...
@@ -2436,32 +2360,8 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
pResBlock
->
info
.
rows
+=
1
;
pResBlock
->
info
.
rows
+=
1
;
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
if
(
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
pSliceInfo
->
current
=
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
,
false
);
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
if
(
nextTs
>
pSliceInfo
->
current
)
{
while
(
pSliceInfo
->
current
<
nextTs
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
}
}
else
{
// it is the last row of current block
// store ts value as start, and calculate interp value when processing next block
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
,
true
);
}
}
else
{
// non-linear interpolation
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
}
}
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录