Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
78475201
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看板
提交
78475201
编写于
8月 06, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): fix interp fill(next) result errors
上级
70f39679
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
72 addition
and
16 deletion
+72
-16
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+3
-0
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+69
-16
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
78475201
...
...
@@ -737,6 +737,9 @@ typedef struct STimeSliceOperatorInfo {
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
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
78475201
...
...
@@ -2084,10 +2084,30 @@ static void doKeepPrevRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
memcpy
(
pkey
->
pData
,
val
,
pkey
->
bytes
);
}
}
pSliceInfo
->
isPrevRowSet
=
true
;
}
static
void
doKeepNextRows
(
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
,
int32_t
rowIndex
,
SSDataBlock
*
pResBlock
,
bool
isPrevRowSet
)
{
int32_t
rowIndex
,
SSDataBlock
*
pResBlock
)
{
int32_t
rows
=
pResBlock
->
info
.
rows
;
// todo set the correct primary timestamp column
...
...
@@ -2163,7 +2183,7 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
break
;
}
case
TSDB_FILL_PREV
:
{
if
(
!
isPrevRowSet
)
{
if
(
!
pSliceInfo
->
isPrevRowSet
)
{
break
;
}
...
...
@@ -2174,12 +2194,14 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
}
case
TSDB_FILL_NEXT
:
{
if
(
!
isPrev
RowSet
)
{
if
(
!
pSliceInfo
->
isNext
RowSet
)
{
break
;
}
char
*
p
=
colDataGetData
(
pSrc
,
rowIndex
);
colDataAppend
(
pDst
,
rows
,
p
,
colDataIsNull_s
(
pSrc
,
rowIndex
));
//char* p = colDataGetData(pSrc, rowIndex);
//colDataAppend(pDst, rows, p, colDataIsNull_s(pSrc, rowIndex));
SGroupKeys
*
pkey
=
taosArrayGet
(
pSliceInfo
->
pNextRow
,
srcSlot
);
colDataAppend
(
pDst
,
rows
,
pkey
->
pData
,
false
);
pResBlock
->
info
.
rows
+=
1
;
break
;
}
...
...
@@ -2213,6 +2235,35 @@ static int32_t initPrevRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
taosArrayPush
(
pInfo
->
pPrevRow
,
&
key
);
}
pInfo
->
isPrevRowSet
=
false
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
initNextRowsKeeper
(
STimeSliceOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
if
(
pInfo
->
pNextRow
!=
NULL
)
{
return
TSDB_CODE_SUCCESS
;
}
pInfo
->
pNextRow
=
taosArrayInit
(
4
,
sizeof
(
SGroupKeys
));
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
);
SGroupKeys
key
=
{
0
};
key
.
bytes
=
pColInfo
->
info
.
bytes
;
key
.
type
=
pColInfo
->
info
.
type
;
key
.
isNull
=
false
;
key
.
pData
=
taosMemoryCalloc
(
1
,
pColInfo
->
info
.
bytes
);
taosArrayPush
(
pInfo
->
pNextRow
,
&
key
);
}
pInfo
->
isNextRowSet
=
false
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2242,15 +2293,19 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
blockDataCleanup
(
pResBlock
);
//int32_t numOfRows = 0;
bool
isPrevRowSet
=
false
;
while
(
1
)
{
SSDataBlock
*
pBlock
=
downstream
->
fpSet
.
getNextFn
(
downstream
);
if
(
pBlock
==
NULL
)
{
break
;
}
int32_t
code
=
initPrevRowsKeeper
(
pSliceInfo
,
pBlock
);
int32_t
code
;
code
=
initPrevRowsKeeper
(
pSliceInfo
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
code
=
initNextRowsKeeper
(
pSliceInfo
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
...
...
@@ -2272,13 +2327,11 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
SColumnInfoData
*
pDst
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
dstSlot
);
char
*
v
=
colDataGetData
(
pSrc
,
i
);
//colDataAppend(pDst, numOfRows, v, false);
colDataAppend
(
pDst
,
pResBlock
->
info
.
rows
,
v
,
false
);
}
pResBlock
->
info
.
rows
+=
1
;
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
isPrevRowSet
=
true
;
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
...
...
@@ -2293,13 +2346,12 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
}
else
if
(
ts
<
pSliceInfo
->
current
)
{
//in case interpolation window starts and ends between two datapoints, fill(prev) need to interpolate
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
isPrevRowSet
=
true
;
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
,
i
,
pResBlock
,
isPrevRowSet
);
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
i
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
...
...
@@ -2316,11 +2368,13 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
}
}
else
{
// it is the last row of current block
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
isPrevRowSet
=
true
;
}
}
else
{
// ts > pSliceInfo->current
//in case interpolation window starts and ends between two datapoints, fill(next) need to interpolate
doKeepNextRows
(
pSliceInfo
,
pBlock
,
i
);
while
(
pSliceInfo
->
current
<
ts
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
i
,
pResBlock
,
isPrevRowSet
);
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
i
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
...
...
@@ -2344,7 +2398,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
pResBlock
->
info
.
rows
+=
1
;
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
isPrevRowSet
=
true
;
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
...
...
@@ -2363,7 +2416,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
//check if need to interpolate after ts range
while
(
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
pBlock
->
info
.
rows
-
1
,
pResBlock
,
isPrevRowSet
);
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
pBlock
->
info
.
rows
-
1
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录