Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
26648a90
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,发现更多精彩内容 >>
提交
26648a90
编写于
8月 08, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): interp + fill(linear) not working
TD-18220
上级
1ee558fb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
62 deletion
+65
-62
source/libs/executor/inc/tfill.h
source/libs/executor/inc/tfill.h
+6
-3
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+59
-59
未找到文件。
source/libs/executor/inc/tfill.h
浏览文件 @
26648a90
...
...
@@ -34,9 +34,12 @@ typedef struct SFillColInfo {
}
SFillColInfo
;
typedef
struct
SFillLinearInfo
{
SPoint
start
;
SPoint
end
;
bool
fillLastPoint
;
SPoint
start
;
SPoint
end
;
bool
hasNull
;
bool
fillLastPoint
;
int16_t
type
;
int32_t
bytes
;
}
SFillLinearInfo
;
typedef
struct
{
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
26648a90
...
...
@@ -2091,18 +2091,28 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
int32_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pTsCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pSliceInfo
->
tsCol
.
slotId
);
SFillLinearInfo
*
pLinearInfo
=
taosArrayGet
(
pSliceInfo
->
pLinearInfo
,
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
);
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
);
pLinearInfo
->
hasNull
=
false
;
}
else
{
pLinearInfo
->
hasNull
=
true
;
}
}
pSliceInfo
->
isNextRowSet
=
true
;
}
static
void
genInterpolationResult
(
STimeSliceOperatorInfo
*
pSliceInfo
,
SExprSupp
*
pExprSup
,
SSDataBlock
*
pBlock
,
...
...
@@ -2133,52 +2143,36 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
if
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_FLOAT
)
{
float
v
=
0
;
GET_TYPED_DATA
(
v
,
float
,
pVar
->
nType
,
&
pVar
->
i
);
colDataAppend
(
pDst
,
rows
,
(
char
*
)
&
v
,
false
);
colDataAppend
(
pDst
,
rows
,
(
char
*
)
&
v
,
false
);
}
else
if
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
v
=
0
;
GET_TYPED_DATA
(
v
,
double
,
pVar
->
nType
,
&
pVar
->
i
);
colDataAppend
(
pDst
,
rows
,
(
char
*
)
&
v
,
false
);
colDataAppend
(
pDst
,
rows
,
(
char
*
)
&
v
,
false
);
}
else
if
(
IS_SIGNED_NUMERIC_TYPE
(
pDst
->
info
.
type
))
{
int64_t
v
=
0
;
GET_TYPED_DATA
(
v
,
int64_t
,
pVar
->
nType
,
&
pVar
->
i
);
colDataAppend
(
pDst
,
rows
,
(
char
*
)
&
v
,
false
);
colDataAppend
(
pDst
,
rows
,
(
char
*
)
&
v
,
false
);
}
pResBlock
->
info
.
rows
+=
1
;
break
;
}
case
TSDB_FILL_LINEAR
:
{
#if 0
if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs
|| pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) {
// goto interp_exit;
}
SFillLinearInfo
*
pLinearInfo
=
taosArrayGet
(
pSliceInfo
->
pLinearInfo
,
srcSlot
);
double v1 = -1, v2 = -1;
GET_TYPED_DATA(v1, double, pCtx->inputType, &pCtx->start.val);
GET_TYPED_DATA(v2, double, pCtx->inputType, &pCtx->end.val);
SPoint point1 = {.key = ts, .val = &v1};
SPoint point2 = {.key = nextTs, .val = &v2};
SPoint point = {.key = pCtx->startTs, .val = pCtx->pOutput};
int32_t srcType = pCtx->inputType;
if (isNull((char *)&pCtx->start.val, srcType) || isNull((char *)&pCtx->end.val, srcType)) {
setNull(pCtx->pOutput, srcType, pCtx->inputBytes);
} else {
bool exceedMax = false, exceedMin = false;
taosGetLinearInterpolationVal(&point, pCtx->outputType, &point1, &point2, TSDB_DATA_TYPE_DOUBLE, &exceedMax, &exceedMin);
if (exceedMax || exceedMin) {
__compar_fn_t func = getComparFunc((int32_t)pCtx->inputType, 0);
if (func(&pCtx->start.val, &pCtx->end.val) <= 0) {
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->start.val : &pCtx->end.val);
} else {
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->end.val : &pCtx->start.val);
}
}
}
#endif
// TODO: pResBlock->info.rows += 1;
SPoint
start
=
pLinearInfo
->
start
;
SPoint
end
=
pLinearInfo
->
end
;
SPoint
current
=
{.
key
=
pSliceInfo
->
current
};
current
.
val
=
taosMemoryCalloc
(
pLinearInfo
->
bytes
,
1
);
if
(
pLinearInfo
->
hasNull
)
{
colDataAppendNULL
(
pDst
,
rows
);
}
else
{
taosGetLinearInterpolationVal
(
&
current
,
pLinearInfo
->
type
,
&
start
,
&
end
,
pLinearInfo
->
type
);
colDataAppend
(
pDst
,
rows
,
(
char
*
)
current
.
val
,
false
);
}
pResBlock
->
info
.
rows
+=
1
;
break
;
}
case
TSDB_FILL_PREV
:
{
...
...
@@ -2278,13 +2272,16 @@ static int32_t initFillLinearInfo(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
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
);
SFillLinearInfo
linearInfo
=
{
0
};
linearInfo
.
start
.
key
=
INT64_MIN
;
linearInfo
.
end
.
key
=
INT64_MAX
;
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
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2374,6 +2371,9 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
// 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
)
{
doKeepLinearInfo
(
pSliceInfo
,
pBlock
,
i
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
if
(
nextTs
>
pSliceInfo
->
current
)
{
...
...
@@ -2395,24 +2395,24 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
}
}
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
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
}
else
{
// non-linear interpolation
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
break
;
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
break
;
}
}
}
else
if
(
ts
<
pSliceInfo
->
current
)
{
// in case 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
);
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
// in case 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
+
1
);
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
if
(
nextTs
>
pSliceInfo
->
current
)
{
...
...
@@ -2436,7 +2436,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
}
}
else
{
// ts > pSliceInfo->current
// in case 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
);
while
(
pSliceInfo
->
current
<
ts
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录