Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
09962c00
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
09962c00
编写于
3月 23, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-32] refactor codes
上级
74b54610
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
54 deletion
+60
-54
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+60
-54
未找到文件。
src/query/src/queryExecutor.c
浏览文件 @
09962c00
...
...
@@ -5469,34 +5469,60 @@ static int32_t validateQueryMeterMsg(SQueryTableMsg *pQueryTableMsg) {
return
0
;
}
static
int32_t
convertQueryTableMsg
(
SQueryTableMsg
*
pQueryTableMsg
,
SArray
**
pTableIdList
)
{
pQueryTableMsg
->
vgId
=
htons
(
pQueryTableMsg
->
vgId
);
pQueryTableMsg
->
numOfTables
=
htonl
(
pQueryTableMsg
->
numOfTables
);
pQueryTableMsg
->
window
.
skey
=
htobe64
(
pQueryTableMsg
->
window
.
skey
);
pQueryTableMsg
->
window
.
ekey
=
htobe64
(
pQueryTableMsg
->
window
.
ekey
);
static
char
*
createTableIdList
(
SQueryTableMsg
*
pQueryTableMsg
,
char
*
pMsg
,
SArray
**
pTableIdList
)
{
assert
(
pQueryTableMsg
->
numOfTables
>
0
);
*
pTableIdList
=
taosArrayInit
(
pQueryTableMsg
->
numOfTables
,
sizeof
(
STableIdInfo
));
STableIdInfo
*
pTableIdInfo
=
(
STableIdInfo
*
)
pMsg
;
pTableIdInfo
->
sid
=
htonl
(
pTableIdInfo
->
sid
);
pTableIdInfo
->
uid
=
htobe64
(
pTableIdInfo
->
uid
);
pTableIdInfo
->
key
=
htobe64
(
pTableIdInfo
->
key
);
taosArrayPush
(
*
pTableIdList
,
pTableIdInfo
);
pMsg
+=
sizeof
(
STableIdInfo
);
for
(
int32_t
j
=
1
;
j
<
pQueryTableMsg
->
numOfTables
;
++
j
)
{
pTableIdInfo
=
(
STableIdInfo
*
)
pMsg
;
pTableIdInfo
->
sid
=
htonl
(
pTableIdInfo
->
sid
);
pTableIdInfo
->
uid
=
htobe64
(
pTableIdInfo
->
uid
);
pTableIdInfo
->
key
=
htobe64
(
pTableIdInfo
->
key
);
taosArrayPush
(
*
pTableIdList
,
pTableIdInfo
);
pMsg
+=
sizeof
(
STableIdInfo
);
}
return
pMsg
;
}
pQueryTableMsg
->
order
=
htons
(
pQueryTableMsg
->
order
);
pQueryTableMsg
->
orderColId
=
htons
(
pQueryTableMsg
->
orderColId
);
static
int32_t
convertQueryMsg
(
SQueryTableMsg
*
pQueryTableMsg
,
SArray
**
pTableIdList
)
{
pQueryTableMsg
->
vgId
=
htons
(
pQueryTableMsg
->
vgId
);
pQueryTableMsg
->
numOfTables
=
htonl
(
pQueryTableMsg
->
numOfTables
);
pQueryTableMsg
->
queryType
=
htons
(
pQueryTableMsg
->
queryType
);
pQueryTableMsg
->
window
.
skey
=
htobe64
(
pQueryTableMsg
->
window
.
skey
);
pQueryTableMsg
->
window
.
ekey
=
htobe64
(
pQueryTableMsg
->
window
.
ekey
);
pQueryTableMsg
->
intervalTime
=
htobe64
(
pQueryTableMsg
->
intervalTime
);
pQueryTableMsg
->
slidingTime
=
htobe64
(
pQueryTableMsg
->
slidingTime
);
pQueryTableMsg
->
limit
=
htobe64
(
pQueryTableMsg
->
limit
);
pQueryTableMsg
->
offset
=
htobe64
(
pQueryTableMsg
->
offset
);
pQueryTableMsg
->
order
=
htons
(
pQueryTableMsg
->
order
);
pQueryTableMsg
->
orderColId
=
htons
(
pQueryTableMsg
->
orderColId
);
pQueryTableMsg
->
intervalTime
=
htobe64
(
pQueryTableMsg
->
intervalTime
);
pQueryTableMsg
->
slidingTime
=
htobe64
(
pQueryTableMsg
->
slidingTime
);
pQueryTableMsg
->
queryType
=
htons
(
pQueryTableMsg
->
queryType
);
pQueryTableMsg
->
numOfTagsCols
=
htons
(
pQueryTableMsg
->
numOfTagsCols
);
pQueryTableMsg
->
numOfCols
=
htons
(
pQueryTableMsg
->
numOfCols
);
pQueryTableMsg
->
numOfCols
=
htons
(
pQueryTableMsg
->
numOfCols
);
pQueryTableMsg
->
numOfOutputCols
=
htons
(
pQueryTableMsg
->
numOfOutputCols
);
pQueryTableMsg
->
numOfGroupCols
=
htons
(
pQueryTableMsg
->
numOfGroupCols
);
pQueryTableMsg
->
tagLength
=
htons
(
pQueryTableMsg
->
tagLength
);
pQueryTableMsg
->
tagLength
=
htons
(
pQueryTableMsg
->
tagLength
);
pQueryTableMsg
->
limit
=
htobe64
(
pQueryTableMsg
->
limit
);
pQueryTableMsg
->
offset
=
htobe64
(
pQueryTableMsg
->
offset
);
pQueryTableMsg
->
tsOffset
=
htonl
(
pQueryTableMsg
->
tsOffset
);
pQueryTableMsg
->
tsLen
=
htonl
(
pQueryTableMsg
->
tsLen
);
pQueryTableMsg
->
tsOffset
=
htonl
(
pQueryTableMsg
->
tsOffset
);
pQueryTableMsg
->
tsLen
=
htonl
(
pQueryTableMsg
->
tsLen
);
pQueryTableMsg
->
tsNumOfBlocks
=
htonl
(
pQueryTableMsg
->
tsNumOfBlocks
);
pQueryTableMsg
->
tsOrder
=
htonl
(
pQueryTableMsg
->
tsOrder
);
pQueryTableMsg
->
tsOrder
=
htonl
(
pQueryTableMsg
->
tsOrder
);
// query msg safety check
if
(
validateQueryMeterMsg
(
pQueryTableMsg
)
!=
0
)
{
...
...
@@ -5506,23 +5532,23 @@ static int32_t convertQueryTableMsg(SQueryTableMsg *pQueryTableMsg, SArray **pTa
char
*
pMsg
=
(
char
*
)(
pQueryTableMsg
->
colList
)
+
sizeof
(
SColumnInfo
)
*
pQueryTableMsg
->
numOfCols
;
for
(
int32_t
col
=
0
;
col
<
pQueryTableMsg
->
numOfCols
;
++
col
)
{
pQueryTableMsg
->
colList
[
col
].
colId
=
htons
(
pQueryTableMsg
->
colList
[
col
].
colId
);
pQueryTableMsg
->
colList
[
col
].
type
=
htons
(
pQueryTableMsg
->
colList
[
col
].
type
);
pQueryTableMsg
->
colList
[
col
].
bytes
=
htons
(
pQueryTableMsg
->
colList
[
col
].
bytes
);
pQueryTableMsg
->
colList
[
col
].
numOfFilters
=
htons
(
pQueryTableMsg
->
colList
[
col
].
numOfFilters
);
assert
(
pQueryTableMsg
->
colList
[
col
].
type
>=
TSDB_DATA_TYPE_BOOL
&&
pQueryTableMsg
->
colList
[
col
].
type
<=
TSDB_DATA_TYPE_NCHAR
);
SColumnInfo
*
pColInfo
=
&
pQueryTableMsg
->
colList
[
col
];
pColInfo
->
colId
=
htons
(
pColInfo
->
colId
);
pColInfo
->
type
=
htons
(
pColInfo
->
type
);
pColInfo
->
bytes
=
htons
(
pColInfo
->
bytes
);
pColInfo
->
numOfFilters
=
htons
(
pColInfo
->
numOfFilters
);
int32_t
numOfFilters
=
pQueryTableMsg
->
colList
[
col
].
numOfFilters
;
assert
(
pColInfo
->
type
>=
TSDB_DATA_TYPE_BOOL
&&
pColInfo
->
type
<=
TSDB_DATA_TYPE_NCHAR
)
;
int32_t
numOfFilters
=
pColInfo
->
numOfFilters
;
if
(
numOfFilters
>
0
)
{
p
QueryTableMsg
->
colList
[
col
].
filters
=
calloc
(
numOfFilters
,
sizeof
(
SColumnFilterInfo
));
p
ColInfo
->
filters
=
calloc
(
numOfFilters
,
sizeof
(
SColumnFilterInfo
));
}
for
(
int32_t
f
=
0
;
f
<
numOfFilters
;
++
f
)
{
SColumnFilterInfo
*
pFilterInfo
=
(
SColumnFilterInfo
*
)
pMsg
;
SColumnFilterInfo
*
pDestFilterInfo
=
&
p
QueryTableMsg
->
colList
[
col
].
filters
[
f
];
SColumnFilterInfo
*
pDestFilterInfo
=
&
p
ColInfo
->
filters
[
f
];
pDestFilterInfo
->
filterOnBinary
=
htons
(
pFilterInfo
->
filterOnBinary
);
...
...
@@ -5599,27 +5625,8 @@ static int32_t convertQueryTableMsg(SQueryTableMsg *pQueryTableMsg, SArray **pTa
pQueryTableMsg
->
colNameList
=
(
int64_t
)
pMsg
;
pMsg
+=
pQueryTableMsg
->
colNameLen
;
}
*
pTableIdList
=
taosArrayInit
(
pQueryTableMsg
->
numOfTables
,
sizeof
(
STableIdInfo
));
STableIdInfo
*
pTableIdInfo
=
(
STableIdInfo
*
)
pMsg
;
pTableIdInfo
->
sid
=
htonl
(
pTableIdInfo
->
sid
);
pTableIdInfo
->
uid
=
htobe64
(
pTableIdInfo
->
uid
);
pTableIdInfo
->
key
=
htobe64
(
pTableIdInfo
->
key
);
taosArrayPush
(
*
pTableIdList
,
pTableIdInfo
);
pMsg
+=
sizeof
(
STableIdInfo
);
for
(
int32_t
j
=
1
;
j
<
pQueryTableMsg
->
numOfTables
;
++
j
)
{
pTableIdInfo
=
(
STableIdInfo
*
)
pMsg
;
pTableIdInfo
->
sid
=
htonl
(
pTableIdInfo
->
sid
);
pTableIdInfo
->
uid
=
htobe64
(
pTableIdInfo
->
uid
);
pTableIdInfo
->
key
=
htobe64
(
pTableIdInfo
->
key
);
taosArrayPush
(
*
pTableIdList
,
pTableIdInfo
);
pMsg
+=
sizeof
(
STableIdInfo
);
}
pMsg
=
createTableIdList
(
pQueryTableMsg
,
pMsg
,
pTableIdList
);
if
(
pQueryTableMsg
->
numOfGroupCols
>
0
||
pQueryTableMsg
->
numOfTagsCols
>
0
)
{
// group by tag columns
pQueryTableMsg
->
pTagSchema
=
(
uint64_t
)
pMsg
;
...
...
@@ -5653,9 +5660,7 @@ static int32_t convertQueryTableMsg(SQueryTableMsg *pQueryTableMsg, SArray **pTa
dTrace
(
"qmsg:%p query on %d meter(s), qrange:%"
PRId64
"-%"
PRId64
", numOfGroupbyTagCols:%d, numOfTagCols:%d, timestamp order:%d, "
"tags order:%d, tags order col:%d, numOfOutputCols:%d, numOfCols:%d, interval:%"
PRId64
", fillType:%d, comptslen:%d, limit:%"
PRId64
", "
"offset:%"
PRId64
,
", fillType:%d, comptslen:%d, limit:%"
PRId64
", offset:%"
PRId64
,
pQueryTableMsg
,
pQueryTableMsg
->
numOfTables
,
pQueryTableMsg
->
window
.
skey
,
pQueryTableMsg
->
window
.
ekey
,
pQueryTableMsg
->
numOfGroupCols
,
pQueryTableMsg
->
numOfTagsCols
,
pQueryTableMsg
->
order
,
pQueryTableMsg
->
orderType
,
pQueryTableMsg
->
orderByIdx
,
pQueryTableMsg
->
numOfOutputCols
,
...
...
@@ -6181,8 +6186,9 @@ int32_t qCreateQueryInfo(void* tsdb, SQueryTableMsg *pQueryTableMsg, SQInfo **pQ
assert
(
pQueryTableMsg
!=
NULL
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
SArray
*
pTableIdList
=
NULL
;
if
((
code
=
convertQuery
Table
Msg
(
pQueryTableMsg
,
&
pTableIdList
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
convertQueryMsg
(
pQueryTableMsg
,
&
pTableIdList
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录