Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ed09566e
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
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看板
提交
ed09566e
编写于
7月 09, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bugs in group by query
上级
56891d46
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
26 deletion
+14
-26
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+14
-26
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
ed09566e
...
...
@@ -3609,20 +3609,7 @@ bool needPrimaryTimestampCol(SQuery *pQuery, SDataBlockInfo *pDataBlockInfo) {
return
loadPrimaryTS
;
}
static
int32_t
getNumOfSubset
(
SQInfo
*
pQInfo
)
{
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
int32_t
totalSubset
=
0
;
if
(
pQInfo
->
runtimeEnv
.
groupbyNormalCol
||
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
)))
{
totalSubset
=
numOfClosedTimeWindow
(
&
pQInfo
->
runtimeEnv
.
windowResInfo
);
}
else
{
totalSubset
=
GET_NUM_OF_TABLEGROUP
(
pQInfo
);
}
return
totalSubset
;
}
static
int32_t
doCopyToSData
(
SQInfo
*
pQInfo
,
SWindowResult
*
result
,
int32_t
orderType
)
{
static
int32_t
doCopyToSData
(
SQInfo
*
pQInfo
,
SWindowResInfo
*
pResultInfo
,
int32_t
orderType
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
...
...
@@ -3631,17 +3618,18 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde
int32_t
step
=
-
1
;
qDebug
(
"QInfo:%p start to copy data from windowResInfo to query buf"
,
pQInfo
);
int32_t
totalSubset
=
getNumOfSubset
(
pQInfo
);
int32_t
totalSet
=
numOfClosedTimeWindow
(
pResultInfo
);
SWindowResult
*
result
=
pResultInfo
->
pResult
;
if
(
orderType
==
TSDB_ORDER_ASC
)
{
startIdx
=
pQInfo
->
groupIndex
;
step
=
1
;
}
else
{
// desc order copy all data
startIdx
=
totalS
ubs
et
-
pQInfo
->
groupIndex
-
1
;
startIdx
=
totalSet
-
pQInfo
->
groupIndex
-
1
;
step
=
-
1
;
}
for
(
int32_t
i
=
startIdx
;
(
i
<
totalS
ubs
et
)
&&
(
i
>=
0
);
i
+=
step
)
{
for
(
int32_t
i
=
startIdx
;
(
i
<
totalSet
)
&&
(
i
>=
0
);
i
+=
step
)
{
if
(
result
[
i
].
numOfRows
==
0
)
{
pQInfo
->
offset
=
0
;
pQInfo
->
groupIndex
+=
1
;
...
...
@@ -3696,11 +3684,11 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde
* @param pQInfo
* @param result
*/
void
copyFromWindowResToSData
(
SQInfo
*
pQInfo
,
SWindowRes
ult
*
result
)
{
void
copyFromWindowResToSData
(
SQInfo
*
pQInfo
,
SWindowRes
Info
*
pResultInfo
)
{
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
int32_t
orderType
=
(
pQuery
->
pGroupbyExpr
!=
NULL
)
?
pQuery
->
pGroupbyExpr
->
orderType
:
TSDB_ORDER_ASC
;
int32_t
numOfResult
=
doCopyToSData
(
pQInfo
,
result
,
orderType
);
int32_t
numOfResult
=
doCopyToSData
(
pQInfo
,
pResultInfo
,
orderType
);
pQuery
->
rec
.
rows
+=
numOfResult
;
...
...
@@ -4523,7 +4511,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
pQInfo
->
groupIndex
=
0
;
ensureOutputBufferSimple
(
pRuntimeEnv
,
pWindowResInfo
->
size
);
copyFromWindowResToSData
(
pQInfo
,
pWindowResInfo
->
pResult
);
copyFromWindowResToSData
(
pQInfo
,
pWindowResInfo
);
pQInfo
->
groupIndex
=
currentGroupIndex
;
//restore the group index
assert
(
pQuery
->
rec
.
rows
==
pWindowResInfo
->
size
);
...
...
@@ -4538,7 +4526,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
* we need to return it to client in the first place.
*/
if
(
pQInfo
->
groupIndex
>
0
)
{
copyFromWindowResToSData
(
pQInfo
,
pRuntimeEnv
->
windowResInfo
.
pResult
);
copyFromWindowResToSData
(
pQInfo
,
&
pRuntimeEnv
->
windowResInfo
);
pQuery
->
rec
.
total
+=
pQuery
->
rec
.
rows
;
if
(
pQuery
->
rec
.
rows
>
0
)
{
...
...
@@ -4739,7 +4727,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
displayInterResult
(
pQuery
->
sdata
,
pRuntimeEnv
,
pQuery
->
sdata
[
0
]
->
num
);
#endif
}
else
{
copyFromWindowResToSData
(
pQInfo
,
pRuntimeEnv
->
windowResInfo
.
pResult
);
copyFromWindowResToSData
(
pQInfo
,
&
pRuntimeEnv
->
windowResInfo
);
}
qDebug
(
"QInfo:%p current:%"
PRId64
", total:%"
PRId64
""
,
pQInfo
,
pQuery
->
rec
.
rows
,
pQuery
->
rec
.
total
);
...
...
@@ -4790,7 +4778,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
#endif
}
}
else
{
// not a interval query
copyFromWindowResToSData
(
pQInfo
,
pRuntimeEnv
->
windowResInfo
.
pResult
);
copyFromWindowResToSData
(
pQInfo
,
&
pRuntimeEnv
->
windowResInfo
);
}
// handle the limitation of output buffer
...
...
@@ -4945,7 +4933,7 @@ static void tableIntervalProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) {
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
pQInfo
->
groupIndex
=
0
;
// always start from 0
pQuery
->
rec
.
rows
=
0
;
copyFromWindowResToSData
(
pQInfo
,
pRuntimeEnv
->
windowResInfo
.
pResult
);
copyFromWindowResToSData
(
pQInfo
,
&
pRuntimeEnv
->
windowResInfo
);
clearFirstNTimeWindow
(
pRuntimeEnv
,
pQInfo
->
groupIndex
);
}
...
...
@@ -4974,7 +4962,7 @@ static void tableIntervalProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) {
if
(
pRuntimeEnv
->
groupbyNormalCol
)
{
// todo refactor with merge interval time result
pQInfo
->
groupIndex
=
0
;
pQuery
->
rec
.
rows
=
0
;
copyFromWindowResToSData
(
pQInfo
,
pRuntimeEnv
->
windowResInfo
.
pResult
);
copyFromWindowResToSData
(
pQInfo
,
&
pRuntimeEnv
->
windowResInfo
);
clearFirstNTimeWindow
(
pRuntimeEnv
,
pQInfo
->
groupIndex
);
}
...
...
@@ -5006,7 +4994,7 @@ static void tableQueryImpl(SQInfo *pQInfo) {
pQInfo
->
groupIndex
=
0
;
// always start from 0
if
(
pRuntimeEnv
->
windowResInfo
.
size
>
0
)
{
copyFromWindowResToSData
(
pQInfo
,
pRuntimeEnv
->
windowResInfo
.
pResult
);
copyFromWindowResToSData
(
pQInfo
,
&
pRuntimeEnv
->
windowResInfo
);
clearFirstNTimeWindow
(
pRuntimeEnv
,
pQInfo
->
groupIndex
);
if
(
pQuery
->
rec
.
rows
>
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录