Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
~笨蛋陪你哭
TDengine
提交
f1657736
T
TDengine
项目概览
~笨蛋陪你哭
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f1657736
编写于
1月 23, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225]refactor.
上级
af428c4d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
64 addition
and
56 deletion
+64
-56
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+62
-54
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+2
-2
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
f1657736
...
...
@@ -3704,6 +3704,67 @@ static void restoreTimeWindow(STableGroupInfo* pTableGroupInfo, STsdbQueryCond*
pKeyInfo
->
lastKey
=
pCond
->
twindow
.
skey
;
}
static
void
handleInterpolationQuery
(
SQInfo
*
pQInfo
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
if
(
pQuery
->
numOfCheckedBlocks
>
0
||
!
isPointInterpoQuery
(
pQuery
))
{
return
;
}
SArray
*
prev
=
tsdbGetExternalRow
(
pRuntimeEnv
->
pQueryHandle
,
&
pQInfo
->
memRef
,
TSDB_PREV_ROW
);
SArray
*
next
=
tsdbGetExternalRow
(
pRuntimeEnv
->
pQueryHandle
,
&
pQInfo
->
memRef
,
TSDB_NEXT_ROW
);
if
(
prev
==
NULL
||
next
==
NULL
)
{
return
;
}
// setup the pCtx->start/end info and calculate the interpolation value
SColumnInfoData
*
startTs
=
taosArrayGet
(
prev
,
0
);
SColumnInfoData
*
endTs
=
taosArrayGet
(
next
,
0
);
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
SQLFunctionCtx
*
pCtx
=
&
pRuntimeEnv
->
pCtx
[
i
];
int32_t
functionId
=
pQuery
->
pExpr1
[
i
].
base
.
functionId
;
SColIndex
*
pColIndex
=
&
pQuery
->
pExpr1
[
i
].
base
.
colInfo
;
if
(
!
TSDB_COL_IS_NORMAL_COL
(
pColIndex
->
flag
))
{
aAggs
[
functionId
].
xFunction
(
pCtx
);
continue
;
}
SColumnInfoData
*
p
=
taosArrayGet
(
prev
,
pColIndex
->
colIndex
);
SColumnInfoData
*
n
=
taosArrayGet
(
next
,
pColIndex
->
colIndex
);
assert
(
p
->
info
.
colId
==
pColIndex
->
colId
);
pCtx
->
start
.
key
=
*
(
TSKEY
*
)
startTs
->
pData
;
pCtx
->
end
.
key
=
*
(
TSKEY
*
)
endTs
->
pData
;
if
(
p
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
&&
p
->
info
.
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
GET_TYPED_DATA
(
pCtx
->
start
.
val
,
double
,
p
->
info
.
type
,
p
->
pData
);
GET_TYPED_DATA
(
pCtx
->
end
.
val
,
double
,
n
->
info
.
type
,
n
->
pData
);
}
else
{
// string pointer
pCtx
->
start
.
ptr
=
p
->
pData
;
pCtx
->
end
.
ptr
=
n
->
pData
;
}
pCtx
->
param
[
2
].
i64
=
(
int8_t
)
pQuery
->
fillType
;
pCtx
->
nStartQueryTimestamp
=
pQuery
->
window
.
skey
;
if
(
pQuery
->
fillVal
!=
NULL
)
{
if
(
isNull
((
const
char
*
)
&
pQuery
->
fillVal
[
i
],
pCtx
->
inputType
))
{
pCtx
->
param
[
1
].
nType
=
TSDB_DATA_TYPE_NULL
;
}
else
{
// todo refactor, tVariantCreateFromBinary should handle the NULL value
if
(
pCtx
->
inputType
!=
TSDB_DATA_TYPE_BINARY
&&
pCtx
->
inputType
!=
TSDB_DATA_TYPE_NCHAR
)
{
tVariantCreateFromBinary
(
&
pCtx
->
param
[
1
],
(
char
*
)
&
pQuery
->
fillVal
[
i
],
pCtx
->
inputBytes
,
pCtx
->
inputType
);
}
}
}
aAggs
[
functionId
].
xFunction
(
pCtx
);
}
}
void
scanOneTableDataBlocks
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
TSKEY
start
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
GET_QINFO_ADDR
(
pRuntimeEnv
);
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
...
...
@@ -3769,60 +3830,7 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) {
clearEnvAfterReverseScan
(
pRuntimeEnv
,
&
qstatus
);
}
if
(
isPointInterpoQuery
(
pQuery
)
&&
pQuery
->
numOfCheckedBlocks
==
0
)
{
SArray
*
prev
=
tsdbGetExternalRow
(
pRuntimeEnv
->
pQueryHandle
,
&
pQInfo
->
memRef
,
TSDB_PREV_ROW
);
SArray
*
next
=
tsdbGetExternalRow
(
pRuntimeEnv
->
pQueryHandle
,
&
pQInfo
->
memRef
,
TSDB_NEXT_ROW
);
if
(
prev
==
NULL
||
next
==
NULL
)
{
return
;
}
// setup the pCtx->start/end info and calculate the interpolation value
SColumnInfoData
*
startTs
=
taosArrayGet
(
prev
,
0
);
SColumnInfoData
*
endTs
=
taosArrayGet
(
next
,
0
);
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
SQLFunctionCtx
*
pCtx
=
&
pRuntimeEnv
->
pCtx
[
i
];
int32_t
functionId
=
pQuery
->
pExpr1
[
i
].
base
.
functionId
;
SColIndex
*
pColIndex
=
&
pQuery
->
pExpr1
[
i
].
base
.
colInfo
;
if
(
!
TSDB_COL_IS_NORMAL_COL
(
pColIndex
->
flag
))
{
aAggs
[
functionId
].
xFunction
(
pCtx
);
continue
;
}
SColumnInfoData
*
p
=
taosArrayGet
(
prev
,
pColIndex
->
colIndex
);
SColumnInfoData
*
n
=
taosArrayGet
(
next
,
pColIndex
->
colIndex
);
assert
(
p
->
info
.
colId
==
pColIndex
->
colId
);
pCtx
->
start
.
key
=
*
(
TSKEY
*
)
startTs
->
pData
;
pCtx
->
end
.
key
=
*
(
TSKEY
*
)
endTs
->
pData
;
if
(
p
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
&&
p
->
info
.
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
GET_TYPED_DATA
(
pCtx
->
start
.
val
,
double
,
p
->
info
.
type
,
p
->
pData
);
GET_TYPED_DATA
(
pCtx
->
end
.
val
,
double
,
n
->
info
.
type
,
n
->
pData
);
}
else
{
// string pointer
pCtx
->
start
.
ptr
=
p
->
pData
;
pCtx
->
end
.
ptr
=
n
->
pData
;
}
pCtx
->
param
[
2
].
i64
=
(
int8_t
)
pQuery
->
fillType
;
pCtx
->
nStartQueryTimestamp
=
pQuery
->
window
.
skey
;
if
(
pQuery
->
fillVal
!=
NULL
)
{
if
(
isNull
((
const
char
*
)
&
pQuery
->
fillVal
[
i
],
pCtx
->
inputType
))
{
pCtx
->
param
[
1
].
nType
=
TSDB_DATA_TYPE_NULL
;
}
else
{
// todo refactor, tVariantCreateFromBinary should handle the NULL value
if
(
pCtx
->
inputType
!=
TSDB_DATA_TYPE_BINARY
&&
pCtx
->
inputType
!=
TSDB_DATA_TYPE_NCHAR
)
{
tVariantCreateFromBinary
(
&
pCtx
->
param
[
1
],
(
char
*
)
&
pQuery
->
fillVal
[
i
],
pCtx
->
inputBytes
,
pCtx
->
inputType
);
}
}
}
aAggs
[
functionId
].
xFunction
(
pCtx
);
}
}
handleInterpolationQuery
(
pQInfo
);
}
void
finalizeQueryResult
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
f1657736
...
...
@@ -1929,8 +1929,8 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) {
STableCheckInfo
*
pCheckInfo
=
taosArrayGet
(
pQueryHandle
->
pTableCheckInfo
,
i
);
// the first qualified table for interpolation query
if
(
pQueryHandle
->
window
.
skey
<=
pCheckInfo
->
pTableObj
->
lastKey
&&
pCheckInfo
->
pTableObj
->
lastKey
!=
TSKEY_INITIAL_VAL
)
{
if
(
(
pQueryHandle
->
window
.
skey
<=
pCheckInfo
->
pTableObj
->
lastKey
)
&&
(
pCheckInfo
->
pTableObj
->
lastKey
!=
TSKEY_INITIAL_VAL
)
)
{
break
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录