Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1ee558fb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
1ee558fb
编写于
8月 08, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): interp + fill(linear) not working
TD-18220
上级
2e3a1cfd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
116 addition
and
21 deletion
+116
-21
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+13
-12
source/libs/executor/inc/tfill.h
source/libs/executor/inc/tfill.h
+7
-1
source/libs/executor/src/tfill.c
source/libs/executor/src/tfill.c
+1
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+95
-7
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
1ee558fb
...
...
@@ -732,18 +732,19 @@ typedef struct SStreamSessionAggOperatorInfo {
}
SStreamSessionAggOperatorInfo
;
typedef
struct
STimeSliceOperatorInfo
{
SSDataBlock
*
pRes
;
STimeWindow
win
;
SInterval
interval
;
int64_t
current
;
SArray
*
pPrevRow
;
// SArray<SGroupValue>
SArray
*
pNextRow
;
// SArray<SGroupValue>
bool
isPrevRowSet
;
bool
isNextRowSet
;
int32_t
fillType
;
// fill type
SColumn
tsCol
;
// primary timestamp column
SExprSupp
scalarSup
;
// scalar calculation
struct
SFillColInfo
*
pFillColInfo
;
// fill column info
SSDataBlock
*
pRes
;
STimeWindow
win
;
SInterval
interval
;
int64_t
current
;
SArray
*
pPrevRow
;
// SArray<SGroupValue>
SArray
*
pNextRow
;
// SArray<SGroupValue>
SArray
*
pLinearInfo
;
// SArray<SFillLinearInfo>
bool
isPrevRowSet
;
bool
isNextRowSet
;
int32_t
fillType
;
// fill type
SColumn
tsCol
;
// primary timestamp column
SExprSupp
scalarSup
;
// scalar calculation
struct
SFillColInfo
*
pFillColInfo
;
// fill column info
}
STimeSliceOperatorInfo
;
typedef
struct
SStateWindowOperatorInfo
{
...
...
source/libs/executor/inc/tfill.h
浏览文件 @
1ee558fb
...
...
@@ -33,11 +33,17 @@ typedef struct SFillColInfo {
SVariant
fillVal
;
}
SFillColInfo
;
typedef
struct
SFillLinearInfo
{
SPoint
start
;
SPoint
end
;
bool
fillLastPoint
;
}
SFillLinearInfo
;
typedef
struct
{
SSchema
col
;
char
*
tagVal
;
}
SFillTagColInfo
;
typedef
struct
SFillInfo
{
TSKEY
start
;
// start timestamp
TSKEY
end
;
// endKey for fill
...
...
source/libs/executor/src/tfill.c
浏览文件 @
1ee558fb
...
...
@@ -669,4 +669,4 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const str
}
return
pFillCol
;
}
\ No newline at end of file
}
source/libs/executor/src/timewindowoperator.c
浏览文件 @
1ee558fb
...
...
@@ -2087,6 +2087,24 @@ static void doKeepNextRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
pSliceInfo
->
isNextRowSet
=
true
;
}
static
void
doKeepLinearInfo
(
STimeSliceOperatorInfo
*
pSliceInfo
,
const
SSDataBlock
*
pBlock
,
int32_t
rowIndex
)
{
int32_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
// null data should not be kept since it can not be used to perform interpolation
if
(
!
colDataIsNull_s
(
pColInfoData
,
i
))
{
SGroupKeys
*
pkey
=
taosArrayGet
(
pSliceInfo
->
pNextRow
,
i
);
pkey
->
isNull
=
false
;
char
*
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
memcpy
(
pkey
->
pData
,
val
,
pkey
->
bytes
);
}
}
pSliceInfo
->
isNextRowSet
=
true
;
}
static
void
genInterpolationResult
(
STimeSliceOperatorInfo
*
pSliceInfo
,
SExprSupp
*
pExprSup
,
SSDataBlock
*
pBlock
,
SSDataBlock
*
pResBlock
)
{
int32_t
rows
=
pResBlock
->
info
.
rows
;
...
...
@@ -2246,6 +2264,52 @@ static int32_t initNextRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
initFillLinearInfo
(
STimeSliceOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
if
(
pInfo
->
pLinearInfo
!=
NULL
)
{
return
TSDB_CODE_SUCCESS
;
}
pInfo
->
pLinearInfo
=
taosArrayInit
(
4
,
sizeof
(
SFillLinearInfo
));
if
(
pInfo
->
pNextRow
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SFillLinearInfo
pLinearInfo
=
{
0
};
pLinearInfo
.
start
.
key
=
INT64_MIN
;
pLinearInfo
.
end
.
key
=
INT64_MAX
;
pLinearInfo
.
start
.
val
=
taosMemoryCalloc
(
1
,
pColInfo
->
info
.
bytes
);
pLinearInfo
.
end
.
val
=
taosMemoryCalloc
(
1
,
pColInfo
->
info
.
bytes
);
pLinearInfo
.
fillLastPoint
=
false
;
taosArrayPush
(
pInfo
->
pLinearInfo
,
&
pLinearInfo
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
initKeeperInfo
(
STimeSliceOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
int32_t
code
;
code
=
initPrevRowsKeeper
(
pInfo
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_FAILED
;
}
code
=
initNextRowsKeeper
(
pInfo
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_FAILED
;
}
code
=
initFillLinearInfo
(
pInfo
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_FAILED
;
}
return
TSDB_CODE_SUCCESS
;
}
static
SSDataBlock
*
doTimeslice
(
SOperatorInfo
*
pOperator
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
...
...
@@ -2278,13 +2342,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
break
;
}
int32_t
code
;
code
=
initPrevRowsKeeper
(
pSliceInfo
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
code
=
initNextRowsKeeper
(
pSliceInfo
,
pBlock
);
int32_t
code
=
initKeeperInfo
(
pSliceInfo
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
...
...
@@ -2312,6 +2370,33 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
pResBlock
->
info
.
rows
+=
1
;
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
// 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
(
pSliceInfo
->
fillType
==
TSDB_FILL_LINEAR
)
{
if
(
i
<
pBlock
->
info
.
rows
-
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
,
pBlock
,
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
;
}
}
else
{
// ignore current row, and do nothing
}
}
else
{
// it is the last row of current block
}
}
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
...
...
@@ -2446,6 +2531,9 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode
pInfo
->
fillType
=
convertFillType
(
pInterpPhyNode
->
fillMode
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
pInfo
->
pPrevRow
=
NULL
;
pInfo
->
pNextRow
=
NULL
;
pInfo
->
pLinearInfo
=
NULL
;
pInfo
->
pFillColInfo
=
createFillColInfo
(
pExprInfo
,
numOfExprs
,
(
SNodeListNode
*
)
pInterpPhyNode
->
pFillValues
);
pInfo
->
pRes
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
pInfo
->
win
=
pInterpPhyNode
->
timeRange
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录