Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
55a7ce46
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
提交
55a7ce46
编写于
1月 19, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225]refactor.
上级
52a52462
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
21 deletion
+37
-21
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+12
-20
tests/script/general/parser/function.sim
tests/script/general/parser/function.sim
+25
-1
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
55a7ce46
...
...
@@ -1875,6 +1875,7 @@ static int32_t setCtxTagColumnInfo(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx
return
TSDB_CODE_SUCCESS
;
}
// todo refactor
static
int32_t
setupQueryRuntimeEnv
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int16_t
order
)
{
qDebug
(
"QInfo:%p setup runtime env"
,
GET_QINFO_ADDR
(
pRuntimeEnv
));
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
...
...
@@ -3845,11 +3846,6 @@ void setExecutionContext(SQInfo *pQInfo, int32_t groupIndex, TSKEY nextKey) {
// lastKey needs to be updated
pTableQueryInfo
->
lastKey
=
nextKey
;
if
(
pRuntimeEnv
->
hasTagResults
||
pRuntimeEnv
->
pTsBuf
!=
NULL
)
{
setAdditionalInfo
(
pQInfo
,
pTableQueryInfo
->
pTable
,
pTableQueryInfo
);
}
if
(
pRuntimeEnv
->
prevGroupId
!=
INT32_MIN
&&
pRuntimeEnv
->
prevGroupId
==
groupIndex
)
{
return
;
}
...
...
@@ -4296,7 +4292,6 @@ int32_t doFillGapsInResults(SQueryRuntimeEnv* pRuntimeEnv, tFilePage **pDst, int
pQInfo
,
pFillInfo
->
numOfRows
,
ret
,
pQuery
->
limit
.
offset
,
ret
-
pQuery
->
limit
.
offset
,
0
);
ret
-=
(
int32_t
)
pQuery
->
limit
.
offset
;
// todo !!!!there exactly number of interpo is not valid.
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
memmove
(
pDst
[
i
]
->
data
,
pDst
[
i
]
->
data
+
pQuery
->
pExpr1
[
i
].
bytes
*
pQuery
->
limit
.
offset
,
ret
*
pQuery
->
pExpr1
[
i
].
bytes
);
...
...
@@ -4777,19 +4772,17 @@ static void enableExecutionForNextTable(SQueryRuntimeEnv *pRuntimeEnv) {
}
}
// TODO refactor: setAdditionalInfo
static
FORCE_INLINE
void
setEnvForEachBlock
(
SQInfo
*
pQInfo
,
STableQueryInfo
*
pTableQueryInfo
,
SDataBlockInfo
*
pBlockInfo
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pQuery
->
order
.
order
);
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
)
)
{
TSKEY
nextKey
=
pBlockInfo
->
window
.
skey
;
setIntervalQueryRange
(
pQInfo
,
nextKey
);
if
(
pRuntimeEnv
->
hasTagResults
||
pRuntimeEnv
->
pTsBuf
!=
NULL
)
{
setAdditionalInfo
(
pQInfo
,
pTableQueryInfo
->
pTable
,
pTableQueryInfo
)
;
}
if
(
pRuntimeEnv
->
hasTagResults
||
pRuntimeEnv
->
pTsBuf
!=
NULL
)
{
setAdditionalInfo
(
pQInfo
,
pTableQueryInfo
->
pTable
,
pTableQueryInfo
);
}
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
setIntervalQueryRange
(
pQInfo
,
pBlockInfo
->
window
.
skey
);
}
else
{
// non-interval query
setExecutionContext
(
pQInfo
,
pTableQueryInfo
->
groupIndex
,
pBlockInfo
->
window
.
ekey
+
step
);
}
...
...
@@ -4812,7 +4805,7 @@ static void doTableQueryInfoTimeWindowCheck(SQuery* pQuery, STableQueryInfo* pTa
static
int64_t
scanMultiTableDataBlocks
(
SQInfo
*
pQInfo
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SQueryCostInfo
*
summary
=
&
pRuntimeEnv
->
summary
;
SQueryCostInfo
*
summary
=
&
pRuntimeEnv
->
summary
;
int64_t
st
=
taosGetTimestampMs
();
...
...
@@ -5469,7 +5462,7 @@ static void doRestoreContext(SQInfo *pQInfo) {
SET_MASTER_SCAN_FLAG
(
pRuntimeEnv
);
}
static
void
doCloseAllTimeWindow
AfterScan
(
SQInfo
*
pQInfo
)
{
static
void
doCloseAllTimeWindow
(
SQInfo
*
pQInfo
)
{
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
...
...
@@ -5521,7 +5514,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
}
// close all time window results
doCloseAllTimeWindow
AfterScan
(
pQInfo
);
doCloseAllTimeWindow
(
pQInfo
);
if
(
needReverseScan
(
pQuery
))
{
int32_t
code
=
doSaveContext
(
pQInfo
);
...
...
@@ -5846,8 +5839,7 @@ static void stableQueryImpl(SQInfo *pQInfo) {
(
isFixedOutputQuery
(
pRuntimeEnv
)
&&
(
!
isPointInterpoQuery
(
pQuery
))
&&
(
!
pRuntimeEnv
->
groupbyColumn
)))
{
multiTableQueryProcess
(
pQInfo
);
}
else
{
assert
((
pQuery
->
checkResultBuf
==
1
&&
pQuery
->
interval
.
interval
==
0
)
||
isPointInterpoQuery
(
pQuery
)
||
pRuntimeEnv
->
groupbyColumn
);
assert
(
pQuery
->
checkResultBuf
==
1
||
isPointInterpoQuery
(
pQuery
)
||
pRuntimeEnv
->
groupbyColumn
);
sequentialTableProcess
(
pQInfo
);
}
...
...
@@ -6375,7 +6367,7 @@ static int32_t createQueryFuncExprFromMsg(SQueryTableMsg *pQueryMsg, int32_t num
if
(
functId
==
TSDB_FUNC_TOP
||
functId
==
TSDB_FUNC_BOTTOM
)
{
int32_t
j
=
getColumnIndexInSource
(
pQueryMsg
,
&
pExprs
[
i
].
base
,
pTagCols
);
if
(
j
<
0
||
j
>=
pQueryMsg
->
numOfCols
)
{
assert
(
0
)
;
return
TSDB_CODE_QRY_INVALID_MSG
;
}
else
{
SColumnInfo
*
pCol
=
&
pQueryMsg
->
colList
[
j
];
int32_t
ret
=
...
...
@@ -6640,7 +6632,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
pQInfo
->
runtimeEnv
.
summary
.
tableInfoSize
+=
(
pTableGroupInfo
->
numOfTables
*
sizeof
(
STableQueryInfo
));
pQInfo
->
runtimeEnv
.
pResultRowHashTable
=
taosHashInit
(
pTableGroupInfo
->
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
pQInfo
->
runtimeEnv
.
keyBuf
=
malloc
(
TSDB_MAX_BYTES_PER_ROW
);
pQInfo
->
runtimeEnv
.
keyBuf
=
malloc
(
TSDB_MAX_BYTES_PER_ROW
);
// todo opt size
pQInfo
->
runtimeEnv
.
pool
=
initResultRowPool
(
getResultRowSize
(
&
pQInfo
->
runtimeEnv
));
pQInfo
->
runtimeEnv
.
prevRow
=
malloc
(
POINTER_BYTES
*
pQuery
->
numOfCols
+
srcSize
);
...
...
tests/script/general/parser/function.sim
浏览文件 @
55a7ce46
...
...
@@ -382,4 +382,28 @@ sql drop table cars;
sql create table cars(ts timestamp, c int) tags(id int);
sql create table car1 using cars tags(1);
sql create table car2 using cars tags(2);
sql insert into car1 (ts, c) values (now,1) car2(ts, c) values(now, 2);
\ No newline at end of file
sql insert into car1 (ts, c) values (now,1) car2(ts, c) values(now, 2);
print ========================> TD-2700
sql create table t1(ts timestamp, k int);
sql insert into t1 values(1500000001000, 0);
sql select sum(k) from t1 interval(1d) sliding(1h);
if $rows != 24 then
return -1
endi
print ========================> TD-2740
sql drop table if exists m1;
sql create table m1(ts timestamp, k int) tags(a int);
sql create table tm0 using m1 tags(0);
sql create table tm1 using m1 tags(1);
sql create table tm2 using m1 tags(2);
sql create table tm3 using m1 tags(3);
sql insert into tm0 values('2020-1-1 1:1:1', 0);
sql insert into tm1 values('2020-1-5 1:1:1', 0);
sql insert into tm2 values('2020-1-7 1:1:1', 0);
sql insert into tm3 values('2020-1-1 1:1:1', 0);
sql select count from m1 where ts='2020-1-1 1:1:1' interval(1h) group by tbname;
if $rows != 2 then
return -1
endi
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录