Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
650aad16
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
650aad16
编写于
11月 16, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225] refactor code.
上级
d5aa32bf
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
76 deletion
+56
-76
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+56
-76
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
650aad16
...
...
@@ -4322,6 +4322,56 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
}
}
static
TSKEY
doSkipIntervalProcess
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
STimeWindow
*
win
,
SDataBlockInfo
*
pBlockInfo
,
STableQueryInfo
*
pTableQueryInfo
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SWindowResInfo
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
assert
(
pQuery
->
limit
.
offset
==
0
);
STimeWindow
tw
=
*
win
;
getNextTimeWindow
(
pQuery
,
&
tw
);
if
((
tw
.
skey
<=
pBlockInfo
->
window
.
ekey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
tw
.
ekey
>=
pBlockInfo
->
window
.
skey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
// load the data block and check data remaining in current data block
// TODO optimize performance
SArray
*
pDataBlock
=
tsdbRetrieveDataBlock
(
pRuntimeEnv
->
pQueryHandle
,
NULL
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pDataBlock
,
0
);
tw
=
*
win
;
int32_t
startPos
=
getNextQualifiedWindow
(
pRuntimeEnv
,
&
tw
,
pBlockInfo
,
pColInfoData
->
pData
,
binarySearchForKey
,
-
1
);
assert
(
startPos
>=
0
);
// set the abort info
pQuery
->
pos
=
startPos
;
// reset the query start timestamp
pTableQueryInfo
->
win
.
skey
=
((
TSKEY
*
)
pColInfoData
->
pData
)[
startPos
];
pQuery
->
window
.
skey
=
pTableQueryInfo
->
win
.
skey
;
TSKEY
key
=
pTableQueryInfo
->
win
.
skey
;
pWindowResInfo
->
prevSKey
=
tw
.
skey
;
int32_t
index
=
pRuntimeEnv
->
windowResInfo
.
curIndex
;
int32_t
numOfRes
=
tableApplyFunctionsOnBlock
(
pRuntimeEnv
,
pBlockInfo
,
NULL
,
binarySearchForKey
,
pDataBlock
);
pRuntimeEnv
->
windowResInfo
.
curIndex
=
index
;
// restore the window index
qDebug
(
"QInfo:%p check data block, brange:%"
PRId64
"-%"
PRId64
", numOfRows:%d, numOfRes:%d, lastKey:%"
PRId64
,
GET_QINFO_ADDR
(
pRuntimeEnv
),
pBlockInfo
->
window
.
skey
,
pBlockInfo
->
window
.
ekey
,
pBlockInfo
->
rows
,
numOfRes
,
pQuery
->
current
->
lastKey
);
return
key
;
}
else
{
// do nothing
pQuery
->
window
.
skey
=
tw
.
skey
;
pWindowResInfo
->
prevSKey
=
tw
.
skey
;
return
tw
.
skey
;
}
return
true
;
}
static
bool
skipTimeInterval
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
TSKEY
*
start
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
*
start
=
pQuery
->
current
->
lastKey
;
...
...
@@ -4370,49 +4420,13 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
(
win
.
ekey
>=
blockInfo
.
window
.
skey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
pQuery
->
limit
.
offset
-=
1
;
pWindowResInfo
->
prevSKey
=
win
.
skey
;
getNextTimeWindow
(
pQuery
,
&
tw
);
}
else
{
// current window does not ended in current data block, try next data block
getNextTimeWindow
(
pQuery
,
&
tw
);
}
// current window does not ended in current data block, try next data block
getNextTimeWindow
(
pQuery
,
&
tw
);
if
(
pQuery
->
limit
.
offset
==
0
)
{
if
((
tw
.
skey
<=
blockInfo
.
window
.
ekey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
tw
.
ekey
>=
blockInfo
.
window
.
skey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
// load the data block and check data remaining in current data block
// TODO optimize performance
SArray
*
pDataBlock
=
tsdbRetrieveDataBlock
(
pRuntimeEnv
->
pQueryHandle
,
NULL
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pDataBlock
,
0
);
tw
=
win
;
int32_t
startPos
=
getNextQualifiedWindow
(
pRuntimeEnv
,
&
tw
,
&
blockInfo
,
pColInfoData
->
pData
,
binarySearchForKey
,
-
1
);
assert
(
startPos
>=
0
);
// set the abort info
pQuery
->
pos
=
startPos
;
// reset the query start timestamp
pTableQueryInfo
->
win
.
skey
=
((
TSKEY
*
)
pColInfoData
->
pData
)[
startPos
];
pQuery
->
window
.
skey
=
pTableQueryInfo
->
win
.
skey
;
*
start
=
pTableQueryInfo
->
win
.
skey
;
pWindowResInfo
->
prevSKey
=
tw
.
skey
;
int32_t
index
=
pRuntimeEnv
->
windowResInfo
.
curIndex
;
int32_t
numOfRes
=
tableApplyFunctionsOnBlock
(
pRuntimeEnv
,
&
blockInfo
,
NULL
,
binarySearchForKey
,
pDataBlock
);
pRuntimeEnv
->
windowResInfo
.
curIndex
=
index
;
// restore the window index
qDebug
(
"QInfo:%p check data block, brange:%"
PRId64
"-%"
PRId64
", numOfRows:%d, numOfRes:%d, lastKey:%"
PRId64
,
GET_QINFO_ADDR
(
pRuntimeEnv
),
blockInfo
.
window
.
skey
,
blockInfo
.
window
.
ekey
,
blockInfo
.
rows
,
numOfRes
,
pQuery
->
current
->
lastKey
);
return
true
;
}
else
{
// do nothing
*
start
=
tw
.
skey
;
pQuery
->
window
.
skey
=
tw
.
skey
;
pWindowResInfo
->
prevSKey
=
tw
.
skey
;
return
true
;
}
*
start
=
doSkipIntervalProcess
(
pRuntimeEnv
,
&
win
,
&
blockInfo
,
pTableQueryInfo
);
return
true
;
}
/*
...
...
@@ -4433,42 +4447,8 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
}
if
(
pQuery
->
limit
.
offset
==
0
)
{
if
((
tw
.
skey
<=
blockInfo
.
window
.
ekey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
tw
.
ekey
>=
blockInfo
.
window
.
skey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
// load the data block and check data remaining in current data block
// TODO optimize performance
SArray
*
pDataBlock
=
tsdbRetrieveDataBlock
(
pRuntimeEnv
->
pQueryHandle
,
NULL
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pDataBlock
,
0
);
tw
=
win
;
int32_t
startPos
=
getNextQualifiedWindow
(
pRuntimeEnv
,
&
tw
,
&
blockInfo
,
pColInfoData
->
pData
,
binarySearchForKey
,
-
1
);
assert
(
startPos
>=
0
);
// set the abort info
pQuery
->
pos
=
startPos
;
// reset the query start timestamp
pTableQueryInfo
->
win
.
skey
=
((
TSKEY
*
)
pColInfoData
->
pData
)[
startPos
];
pQuery
->
window
.
skey
=
pTableQueryInfo
->
win
.
skey
;
*
start
=
pTableQueryInfo
->
win
.
skey
;
pWindowResInfo
->
prevSKey
=
tw
.
skey
;
int32_t
index
=
pRuntimeEnv
->
windowResInfo
.
curIndex
;
int32_t
numOfRes
=
tableApplyFunctionsOnBlock
(
pRuntimeEnv
,
&
blockInfo
,
NULL
,
binarySearchForKey
,
pDataBlock
);
pRuntimeEnv
->
windowResInfo
.
curIndex
=
index
;
// restore the window index
qDebug
(
"QInfo:%p check data block, brange:%"
PRId64
"-%"
PRId64
", numOfRows:%d, numOfRes:%d, lastKey:%"
PRId64
,
GET_QINFO_ADDR
(
pRuntimeEnv
),
blockInfo
.
window
.
skey
,
blockInfo
.
window
.
ekey
,
blockInfo
.
rows
,
numOfRes
,
pQuery
->
current
->
lastKey
);
return
true
;
}
else
{
// do nothing
*
start
=
tw
.
skey
;
pQuery
->
window
.
skey
=
tw
.
skey
;
pWindowResInfo
->
prevSKey
=
tw
.
skey
;
return
true
;
}
*
start
=
doSkipIntervalProcess
(
pRuntimeEnv
,
&
win
,
&
blockInfo
,
pTableQueryInfo
);
return
true
;
}
else
{
tw
=
win
;
int32_t
startPos
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录