Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
266b878b
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看板
提交
266b878b
编写于
5月 06, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-3299]
上级
c36a71e8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
68 addition
and
39 deletion
+68
-39
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+2
-1
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+1
-0
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+58
-36
src/query/src/qPlan.c
src/query/src/qPlan.c
+7
-2
未找到文件。
src/query/inc/qExecutor.h
浏览文件 @
266b878b
...
...
@@ -514,7 +514,8 @@ SOperatorInfo* createMultiwaySortOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SEx
int32_t
numOfRows
,
void
*
merger
,
bool
groupMix
);
SOperatorInfo
*
createGlobalAggregateOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
void
*
param
);
SOperatorInfo
*
createSLimitOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
void
*
merger
);
SOperatorInfo
*
createFilterOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createFilterOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SColumnInfo
*
pCols
,
int32_t
numOfFilter
);
SSDataBlock
*
doGlobalAggregate
(
void
*
param
,
bool
*
newgroup
);
SSDataBlock
*
doMultiwayMergeSort
(
void
*
param
,
bool
*
newgroup
);
...
...
src/query/inc/qUtil.h
浏览文件 @
266b878b
...
...
@@ -48,6 +48,7 @@ void clearResultRow(SQueryRuntimeEnv* pRuntimeEnv, SResultRow* pResultRow, in
SResultRowCellInfo
*
getResultCell
(
const
SResultRow
*
pRow
,
int32_t
index
,
int32_t
*
offset
);
void
*
destroyQueryFuncExpr
(
SExprInfo
*
pExprInfo
,
int32_t
numOfExpr
);
void
*
freeColumnInfo
(
SColumnInfo
*
pColumnInfo
,
int32_t
numOfCols
);
static
FORCE_INLINE
SResultRow
*
getResultRow
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
slot
)
{
assert
(
pResultRowInfo
!=
NULL
&&
slot
>=
0
&&
slot
<
pResultRowInfo
->
size
);
...
...
src/query/src/qExecutor.c
浏览文件 @
266b878b
...
...
@@ -167,6 +167,8 @@ static void setBlockStatisInfo(SQLFunctionCtx *pCtx, SSDataBlock* pSDataBlock, S
static
void
destroyTableQueryInfoImpl
(
STableQueryInfo
*
pTableQueryInfo
);
static
bool
hasMainOutput
(
SQueryAttr
*
pQueryAttr
);
static
SColumnInfo
*
extractColumnFilterInfo
(
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
int32_t
*
numOfFilterCols
);
static
int32_t
setTimestampListJoinInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
tVariant
*
pTag
,
STableQueryInfo
*
pTableQueryInfo
);
static
void
releaseQueryBuf
(
size_t
numOfTables
);
static
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
...
...
@@ -1765,12 +1767,25 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
}
case
OP_Filter
:
{
// todo refactor
if
(
pQueryAttr
->
stableQuery
)
{
pRuntimeEnv
->
proot
=
createFilterOperatorInfo
(
pRuntimeEnv
,
pRuntimeEnv
->
proot
,
pQueryAttr
->
pExpr3
,
pQueryAttr
->
numOfExpr3
);
int32_t
numOfFilterCols
=
0
;
if
(
pQueryAttr
->
numOfFilterCols
>
0
)
{
pRuntimeEnv
->
proot
=
createFilterOperatorInfo
(
pRuntimeEnv
,
pRuntimeEnv
->
proot
,
pQueryAttr
->
pExpr1
,
pQueryAttr
->
numOfOutput
,
pQueryAttr
->
tableCols
,
pQueryAttr
->
numOfFilterCols
);
}
else
{
pRuntimeEnv
->
proot
=
createFilterOperatorInfo
(
pRuntimeEnv
,
pRuntimeEnv
->
proot
,
pQueryAttr
->
pExpr1
,
pQueryAttr
->
numOfOutput
);
if
(
pQueryAttr
->
stableQuery
)
{
SColumnInfo
*
pColInfo
=
extractColumnFilterInfo
(
pQueryAttr
->
pExpr3
,
pQueryAttr
->
numOfExpr3
,
&
numOfFilterCols
);
pRuntimeEnv
->
proot
=
createFilterOperatorInfo
(
pRuntimeEnv
,
pRuntimeEnv
->
proot
,
pQueryAttr
->
pExpr3
,
pQueryAttr
->
numOfExpr3
,
pColInfo
,
numOfFilterCols
);
freeColumnInfo
(
pColInfo
,
pQueryAttr
->
numOfExpr3
);
}
else
{
SColumnInfo
*
pColInfo
=
extractColumnFilterInfo
(
pQueryAttr
->
pExpr1
,
pQueryAttr
->
numOfOutput
,
&
numOfFilterCols
);
pRuntimeEnv
->
proot
=
createFilterOperatorInfo
(
pRuntimeEnv
,
pRuntimeEnv
->
proot
,
pQueryAttr
->
pExpr1
,
pQueryAttr
->
numOfOutput
,
pColInfo
,
numOfFilterCols
);
freeColumnInfo
(
pColInfo
,
pQueryAttr
->
numOfOutput
);
}
}
break
;
}
...
...
@@ -5409,38 +5424,37 @@ SOperatorInfo* createArithOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorI
return
pOperator
;
}
SOperatorInfo
*
createFilterOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
)
{
SFilterOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SFilterOperatorInfo
));
static
SColumnInfo
*
extractColumnFilterInfo
(
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
int32_t
*
numOfFilterCols
)
{
SColumnInfo
*
pCols
=
calloc
(
numOfOutput
,
sizeof
(
SColumnInfo
));
{
SColumnInfo
*
pCols
=
calloc
(
numOfOutput
,
sizeof
(
SColumnInfo
));
int32_t
numOfFilter
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
if
(
pExpr
[
i
].
base
.
flist
.
numOfFilters
>
0
)
{
numOfFilter
+=
1
;
}
int32_t
numOfFilter
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
if
(
pExpr
[
i
].
base
.
flist
.
numOfFilters
>
0
)
{
numOfFilter
+=
1
;
}
pCols
[
i
].
type
=
pExpr
[
i
].
base
.
resType
;
pCols
[
i
].
bytes
=
pExpr
[
i
].
base
.
resBytes
;
pCols
[
i
].
colId
=
pExpr
[
i
].
base
.
resColId
;
pCols
[
i
].
type
=
pExpr
[
i
].
base
.
resType
;
pCols
[
i
].
bytes
=
pExpr
[
i
].
base
.
resBytes
;
pCols
[
i
].
colId
=
pExpr
[
i
].
base
.
resColId
;
pCols
[
i
].
flist
.
numOfFilters
=
pExpr
[
i
].
base
.
flist
.
numOfFilters
;
pCols
[
i
].
flist
.
filterInfo
=
calloc
(
pCols
[
i
].
flist
.
numOfFilters
,
sizeof
(
SColumnFilterInfo
));
memcpy
(
pCols
[
i
].
flist
.
filterInfo
,
pExpr
[
i
].
base
.
flist
.
filterInfo
,
pCols
[
i
].
flist
.
numOfFilters
*
sizeof
(
SColumnFilterInfo
));
}
pCols
[
i
].
flist
.
numOfFilters
=
pExpr
[
i
].
base
.
flist
.
numOfFilters
;
pCols
[
i
].
flist
.
filterInfo
=
calloc
(
pCols
[
i
].
flist
.
numOfFilters
,
sizeof
(
SColumnFilterInfo
));
memcpy
(
pCols
[
i
].
flist
.
filterInfo
,
pExpr
[
i
].
base
.
flist
.
filterInfo
,
pCols
[
i
].
flist
.
numOfFilters
*
sizeof
(
SColumnFilterInfo
));
}
assert
(
numOfFilter
>
0
);
assert
(
numOfFilter
>
0
)
;
doCreateFilterInfo
(
pCols
,
numOfOutput
,
numOfFilter
,
&
pInfo
->
pFilterInfo
,
0
)
;
pInfo
->
numOfFilterCols
=
numOfFilter
;
*
numOfFilterCols
=
numOfFilter
;
return
pCols
;
}
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
tfree
(
pCols
[
i
].
flist
.
filterInfo
);
}
SOperatorInfo
*
createFilterOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SColumnInfo
*
pCols
,
int32_t
numOfFilter
)
{
SFilterOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SFilterOperatorInfo
));
tfree
(
pCols
);
}
assert
(
numOfFilter
>
0
&&
pCols
!=
NULL
);
doCreateFilterInfo
(
pCols
,
numOfOutput
,
numOfFilter
,
&
pInfo
->
pFilterInfo
,
0
);
pInfo
->
numOfFilterCols
=
numOfFilter
;
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
...
...
@@ -7097,6 +7111,20 @@ void* destroyQueryFuncExpr(SExprInfo* pExprInfo, int32_t numOfExpr) {
return
NULL
;
}
void
*
freeColumnInfo
(
SColumnInfo
*
pColumnInfo
,
int32_t
numOfCols
)
{
if
(
pColumnInfo
!=
NULL
)
{
assert
(
numOfCols
>
0
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
i
++
)
{
freeColumnFilterInfo
(
pColumnInfo
[
i
].
flist
.
filterInfo
,
pColumnInfo
[
i
].
flist
.
numOfFilters
);
}
tfree
(
pColumnInfo
);
}
return
NULL
;
}
void
freeQInfo
(
SQInfo
*
pQInfo
)
{
if
(
!
isValidQInfo
(
pQInfo
))
{
return
;
...
...
@@ -7281,13 +7309,7 @@ void freeQueryAttr(SQueryAttr* pQueryAttr) {
tfree
(
pQueryAttr
->
tagColList
);
tfree
(
pQueryAttr
->
pFilterInfo
);
if
(
pQueryAttr
->
tableCols
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryAttr
->
numOfCols
;
i
++
)
{
SColumnInfo
*
column
=
pQueryAttr
->
tableCols
+
i
;
freeColumnFilterInfo
(
column
->
flist
.
filterInfo
,
column
->
flist
.
numOfFilters
);
}
tfree
(
pQueryAttr
->
tableCols
);
}
pQueryAttr
->
tableCols
=
freeColumnInfo
(
pQueryAttr
->
tableCols
,
pQueryAttr
->
numOfCols
);
if
(
pQueryAttr
->
pGroupbyExpr
!=
NULL
)
{
taosArrayDestroy
(
pQueryAttr
->
pGroupbyExpr
->
columnInfo
);
...
...
src/query/src/qPlan.c
浏览文件 @
266b878b
...
...
@@ -615,8 +615,13 @@ SArray* createExecOperatorPlan(SQueryAttr* pQueryAttr) {
taosArrayPush
(
plan
,
&
op
);
}
}
else
{
// diff/add/multiply/subtract/division
op
=
OP_Arithmetic
;
taosArrayPush
(
plan
,
&
op
);
if
(
pQueryAttr
->
numOfFilterCols
>
0
&&
pQueryAttr
->
vgId
==
0
)
{
// todo refactor
op
=
OP_Filter
;
taosArrayPush
(
plan
,
&
op
);
}
else
{
op
=
OP_Arithmetic
;
taosArrayPush
(
plan
,
&
op
);
}
}
if
(
pQueryAttr
->
limit
.
limit
>
0
||
pQueryAttr
->
limit
.
offset
>
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录