Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6fc38165
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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,发现更多精彩内容 >>
提交
6fc38165
编写于
8月 10, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): fix linear interpolation issue between two blocks
TD-18309
上级
249e2b12
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
54 addition
and
18 deletion
+54
-18
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-0
source/libs/executor/inc/tfill.h
source/libs/executor/inc/tfill.h
+0
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+53
-17
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
6fc38165
...
...
@@ -739,6 +739,7 @@ typedef struct STimeSliceOperatorInfo {
SArray
*
pPrevRow
;
// SArray<SGroupValue>
SArray
*
pNextRow
;
// SArray<SGroupValue>
SArray
*
pLinearInfo
;
// SArray<SFillLinearInfo>
bool
fillLastPoint
;
bool
isPrevRowSet
;
bool
isNextRowSet
;
int32_t
fillType
;
// fill type
...
...
source/libs/executor/inc/tfill.h
浏览文件 @
6fc38165
...
...
@@ -37,7 +37,6 @@ typedef struct SFillLinearInfo {
SPoint
start
;
SPoint
end
;
bool
hasNull
;
bool
fillLastPoint
;
int16_t
type
;
int32_t
bytes
;
}
SFillLinearInfo
;
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
6fc38165
...
...
@@ -2087,8 +2087,10 @@ static void doKeepNextRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
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
);
bool
fillLastPoint
=
pSliceInfo
->
fillLastPoint
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pTsCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pSliceInfo
->
tsCol
.
slotId
);
...
...
@@ -2096,16 +2098,22 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
// null data should not be kept since it can not be used to perform interpolation
if
(
!
colDataIsNull_s
(
pColInfoData
,
i
))
{
int64_t
startKey
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
);
int64_t
endKey
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
+
1
);
pLinearInfo
->
start
.
key
=
startKey
;
pLinearInfo
->
end
.
key
=
endKey
;
char
*
val
;
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
memcpy
(
pLinearInfo
->
start
.
val
,
val
,
pLinearInfo
->
bytes
);
val
=
colDataGetData
(
pColInfoData
,
rowIndex
+
1
);
memcpy
(
pLinearInfo
->
end
.
val
,
val
,
pLinearInfo
->
bytes
);
if
(
isLastRow
)
{
pLinearInfo
->
start
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
);
memcpy
(
pLinearInfo
->
start
.
val
,
colDataGetData
(
pColInfoData
,
rowIndex
),
pLinearInfo
->
bytes
);
}
else
if
(
fillLastPoint
)
{
pLinearInfo
->
end
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
);
memcpy
(
pLinearInfo
->
end
.
val
,
colDataGetData
(
pColInfoData
,
rowIndex
),
pLinearInfo
->
bytes
);
}
else
{
pLinearInfo
->
start
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
);
pLinearInfo
->
end
.
key
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
rowIndex
+
1
);
char
*
val
;
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
{
...
...
@@ -2113,6 +2121,8 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
}
}
pSliceInfo
->
fillLastPoint
=
isLastRow
?
true
:
false
;
}
static
void
genInterpolationResult
(
STimeSliceOperatorInfo
*
pSliceInfo
,
SExprSupp
*
pExprSup
,
...
...
@@ -2269,7 +2279,7 @@ static int32_t initFillLinearInfo(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
}
pInfo
->
pLinearInfo
=
taosArrayInit
(
4
,
sizeof
(
SFillLinearInfo
));
if
(
pInfo
->
p
NextRow
==
NULL
)
{
if
(
pInfo
->
p
LinearInfo
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
@@ -2283,15 +2293,20 @@ static int32_t initFillLinearInfo(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
linearInfo
.
start
.
val
=
taosMemoryCalloc
(
1
,
pColInfo
->
info
.
bytes
);
linearInfo
.
end
.
val
=
taosMemoryCalloc
(
1
,
pColInfo
->
info
.
bytes
);
linearInfo
.
hasNull
=
false
;
linearInfo
.
fillLastPoint
=
false
;
linearInfo
.
type
=
pColInfo
->
info
.
type
;
linearInfo
.
bytes
=
pColInfo
->
info
.
bytes
;
taosArrayPush
(
pInfo
->
pLinearInfo
,
&
linearInfo
);
}
pInfo
->
fillLastPoint
=
false
;
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
)
{
int32_t
code
;
code
=
initPrevRowsKeeper
(
pInfo
,
pBlock
);
...
...
@@ -2356,6 +2371,23 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
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
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
break
;
}
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
}
if
(
ts
==
pSliceInfo
->
current
)
{
for
(
int32_t
j
=
0
;
j
<
pOperator
->
exprSupp
.
numOfExprs
;
++
j
)
{
SExprInfo
*
pExprInfo
=
&
pOperator
->
exprSupp
.
pExprInfo
[
j
];
...
...
@@ -2374,9 +2406,10 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
// for linear interpolation, always fill value between this and next points;
// if its the first point in data block, also fill values between previous(if there's any) and this point;
// if its the last point in data block, no need to fill, but reserve this point as the start value for next data block.
// if its the last point in data block, no need to fill, but reserve this point as the start value and do
// the interpolation when processing next data block.
if
(
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
,
false
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
...
...
@@ -2396,6 +2429,9 @@ static SSDataBlock* doTimeslice(SOperatorInfo* 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
=
...
...
@@ -2414,7 +2450,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
if
(
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
,
false
);
// no need to increate pSliceInfo->current here
//pSliceInfo->current =
// taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
...
...
@@ -2494,7 +2530,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
if
(
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
,
false
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录