Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
51290fd1
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看板
提交
51290fd1
编写于
8月 22, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1067]
上级
0fc1c8cd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
15 deletion
+49
-15
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+48
-14
未找到文件。
src/query/inc/qExecutor.h
浏览文件 @
51290fd1
...
@@ -193,7 +193,7 @@ typedef struct SQInfo {
...
@@ -193,7 +193,7 @@ typedef struct SQInfo {
int64_t
owner
;
// if it is in execution
int64_t
owner
;
// if it is in execution
void
*
tsdb
;
void
*
tsdb
;
int32_t
vgId
;
int32_t
vgId
;
STableGroupInfo
tableGroupInfo
;
// table
id list < only includes the STable list
>
STableGroupInfo
tableGroupInfo
;
// table
<tid, last_key> list SArray<STableKeyInfo
>
STableGroupInfo
tableqinfoGroupInfo
;
// this is a group array list, including SArray<STableQueryInfo*> structure
STableGroupInfo
tableqinfoGroupInfo
;
// this is a group array list, including SArray<STableQueryInfo*> structure
SQueryRuntimeEnv
runtimeEnv
;
SQueryRuntimeEnv
runtimeEnv
;
SArray
*
arrTableIdInfo
;
SArray
*
arrTableIdInfo
;
...
...
src/query/src/qExecutor.c
浏览文件 @
51290fd1
...
@@ -124,6 +124,7 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
...
@@ -124,6 +124,7 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
#define calloc u_calloc
#define calloc u_calloc
#define malloc u_malloc
#define malloc u_malloc
#define realloc u_realloc
#endif
#endif
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
...
@@ -3146,7 +3147,8 @@ static void setupQueryRangeForReverseScan(SQInfo* pQInfo) {
...
@@ -3146,7 +3147,8 @@ static void setupQueryRangeForReverseScan(SQInfo* pQInfo) {
STableQueryInfo
*
pCheckInfo
=
taosArrayGetP
(
group
,
j
);
STableQueryInfo
*
pCheckInfo
=
taosArrayGetP
(
group
,
j
);
updateTableQueryInfoForReverseScan
(
pQuery
,
pCheckInfo
);
updateTableQueryInfoForReverseScan
(
pQuery
,
pCheckInfo
);
// update the last key in tableKeyInfo list
// update the last key in tableKeyInfo list, the tableKeyInfo is used to build the tsdbQueryHandle and decide
// the start check timestamp of tsdbQueryHandle
STableKeyInfo
*
pTableKeyInfo
=
taosArrayGet
(
tableKeyGroup
,
j
);
STableKeyInfo
*
pTableKeyInfo
=
taosArrayGet
(
tableKeyGroup
,
j
);
pTableKeyInfo
->
lastKey
=
pCheckInfo
->
lastKey
;
pTableKeyInfo
->
lastKey
=
pCheckInfo
->
lastKey
;
...
@@ -3607,12 +3609,6 @@ void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo) {
...
@@ -3607,12 +3609,6 @@ void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo) {
cleanupTimeWindowInfo
(
&
pTableQueryInfo
->
windowResInfo
);
cleanupTimeWindowInfo
(
&
pTableQueryInfo
->
windowResInfo
);
}
}
#define CHECK_QUERY_TIME_RANGE(_q, _tableInfo) \
do { \
assert((((_tableInfo)->lastKey >= (_tableInfo)->win.skey) && QUERY_IS_ASC_QUERY(_q)) || \
(((_tableInfo)->lastKey <= (_tableInfo)->win.skey) && !QUERY_IS_ASC_QUERY(_q))); \
} while (0)
/**
/**
* set output buffer for different group
* set output buffer for different group
* @param pRuntimeEnv
* @param pRuntimeEnv
...
@@ -4316,6 +4312,34 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
...
@@ -4316,6 +4312,34 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
terrno
=
TSDB_CODE_SUCCESS
;
terrno
=
TSDB_CODE_SUCCESS
;
if
(
isFirstLastRowQuery
(
pQuery
))
{
if
(
isFirstLastRowQuery
(
pQuery
))
{
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryLastRow
(
tsdb
,
&
cond
,
&
pQInfo
->
tableGroupInfo
,
pQInfo
);
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryLastRow
(
tsdb
,
&
cond
,
&
pQInfo
->
tableGroupInfo
,
pQInfo
);
// update the query time window
pQuery
->
window
=
cond
.
twindow
;
int32_t
numOfGroups
=
(
int32_t
)(
GET_NUM_OF_TABLEGROUP
(
pQInfo
));
for
(
int32_t
i
=
0
;
i
<
numOfGroups
;
++
i
)
{
SArray
*
group
=
GET_TABLEGROUP
(
pQInfo
,
i
);
SArray
*
tableKeyGroup
=
taosArrayGetP
(
pQInfo
->
tableGroupInfo
.
pGroupList
,
i
);
size_t
t
=
taosArrayGetSize
(
group
);
for
(
int32_t
j
=
0
;
j
<
t
;
++
j
)
{
STableQueryInfo
*
pCheckInfo
=
taosArrayGetP
(
group
,
j
);
updateTableQueryInfoForReverseScan
(
pQuery
,
pCheckInfo
);
// update the last key in tableKeyInfo list, the tableKeyInfo is used to build the tsdbQueryHandle and decide
// the start check timestamp of tsdbQueryHandle
STableKeyInfo
*
pTableKeyInfo
=
taosArrayGet
(
tableKeyGroup
,
j
);
pCheckInfo
->
win
.
skey
=
pTableKeyInfo
->
lastKey
;
pCheckInfo
->
win
.
ekey
=
pTableKeyInfo
->
lastKey
;
pCheckInfo
->
lastKey
=
pTableKeyInfo
->
lastKey
;
assert
(
pCheckInfo
->
pTable
==
pTableKeyInfo
->
pTable
);
}
}
}
else
if
(
isPointInterpoQuery
(
pQuery
))
{
}
else
if
(
isPointInterpoQuery
(
pQuery
))
{
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryRowsInExternalWindow
(
tsdb
,
&
cond
,
&
pQInfo
->
tableGroupInfo
,
pQInfo
);
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryRowsInExternalWindow
(
tsdb
,
&
cond
,
&
pQInfo
->
tableGroupInfo
,
pQInfo
);
}
else
{
}
else
{
...
@@ -4361,6 +4385,9 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
...
@@ -4361,6 +4385,9 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
pRuntimeEnv
->
hasTagResults
=
hasTagValOutput
(
pQuery
);
pRuntimeEnv
->
hasTagResults
=
hasTagValOutput
(
pQuery
);
setScanLimitationByResultBuffer
(
pQuery
);
setScanLimitationByResultBuffer
(
pQuery
);
// NOTE: pTableCheckInfo need to update the query time range and the lastKey info
// TODO fixme
changeExecuteScanOrder
(
pQInfo
,
false
);
changeExecuteScanOrder
(
pQInfo
,
false
);
code
=
setupQueryHandle
(
tsdb
,
pQInfo
,
isSTableQuery
);
code
=
setupQueryHandle
(
tsdb
,
pQInfo
,
isSTableQuery
);
...
@@ -4512,7 +4539,17 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
...
@@ -4512,7 +4539,17 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
}
}
pQuery
->
current
=
*
pTableQueryInfo
;
pQuery
->
current
=
*
pTableQueryInfo
;
CHECK_QUERY_TIME_RANGE
(
pQuery
,
*
pTableQueryInfo
);
if
(
QUERY_IS_ASC_QUERY
(
pQuery
))
{
assert
(
((
*
pTableQueryInfo
)
->
win
.
skey
<=
(
*
pTableQueryInfo
)
->
win
.
ekey
)
&&
((
*
pTableQueryInfo
)
->
lastKey
>=
(
*
pTableQueryInfo
)
->
win
.
skey
)
&&
((
*
pTableQueryInfo
)
->
win
.
skey
>=
pQuery
->
window
.
skey
&&
(
*
pTableQueryInfo
)
->
win
.
ekey
<=
pQuery
->
window
.
ekey
));
}
else
{
assert
(
((
*
pTableQueryInfo
)
->
win
.
skey
>=
(
*
pTableQueryInfo
)
->
win
.
ekey
)
&&
((
*
pTableQueryInfo
)
->
lastKey
<=
(
*
pTableQueryInfo
)
->
win
.
skey
)
&&
((
*
pTableQueryInfo
)
->
win
.
skey
<=
pQuery
->
window
.
skey
&&
(
*
pTableQueryInfo
)
->
win
.
ekey
>=
pQuery
->
window
.
ekey
));
}
if
(
!
pRuntimeEnv
->
groupbyNormalCol
)
{
if
(
!
pRuntimeEnv
->
groupbyNormalCol
)
{
setEnvForEachBlock
(
pQInfo
,
*
pTableQueryInfo
,
&
blockInfo
);
setEnvForEachBlock
(
pQInfo
,
*
pTableQueryInfo
,
&
blockInfo
);
...
@@ -4653,7 +4690,6 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
...
@@ -4653,7 +4690,6 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
if
(
isFirstLastRowQuery
(
pQuery
))
{
if
(
isFirstLastRowQuery
(
pQuery
))
{
assert
(
0
);
// last_row query switch to other routine to handle
assert
(
0
);
// last_row query switch to other routine to handle
// pRuntimeEnv->pQueryHandle = tsdbQueryLastRow(pQInfo->tsdb, &cond, &gp, pQInfo);
}
else
{
}
else
{
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryRowsInExternalWindow
(
pQInfo
->
tsdb
,
&
cond
,
&
gp
,
pQInfo
);
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryRowsInExternalWindow
(
pQInfo
->
tsdb
,
&
cond
,
&
gp
,
pQInfo
);
}
}
...
@@ -6069,6 +6105,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
...
@@ -6069,6 +6105,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
if
(
p1
==
NULL
)
{
if
(
p1
==
NULL
)
{
goto
_cleanup
;
goto
_cleanup
;
}
}
taosArrayPush
(
pQInfo
->
tableqinfoGroupInfo
.
pGroupList
,
&
p1
);
taosArrayPush
(
pQInfo
->
tableqinfoGroupInfo
.
pGroupList
,
&
p1
);
for
(
int32_t
j
=
0
;
j
<
s
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
s
;
++
j
)
{
...
@@ -6076,13 +6113,10 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
...
@@ -6076,13 +6113,10 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
STableId
*
id
=
TSDB_TABLEID
(
info
->
pTable
);
STableId
*
id
=
TSDB_TABLEID
(
info
->
pTable
);
STableIdInfo
*
pTableId
=
taosArraySearch
(
pTableIdList
,
id
,
compareTableIdInfo
);
STableIdInfo
*
pTableId
=
taosArraySearch
(
pTableIdList
,
id
,
compareTableIdInfo
);
if
(
pTableId
!=
NULL
)
{
window
.
skey
=
pTableId
->
key
;
}
else
{
window
.
skey
=
pQueryMsg
->
window
.
skey
;
}
window
.
skey
=
(
pTableId
!=
NULL
)
?
pTableId
->
key
:
pQueryMsg
->
window
.
skey
;
void
*
buf
=
(
char
*
)
pQInfo
->
pBuf
+
index
*
sizeof
(
STableQueryInfo
);
void
*
buf
=
(
char
*
)
pQInfo
->
pBuf
+
index
*
sizeof
(
STableQueryInfo
);
STableQueryInfo
*
item
=
createTableQueryInfo
(
&
pQInfo
->
runtimeEnv
,
info
->
pTable
,
window
,
buf
);
STableQueryInfo
*
item
=
createTableQueryInfo
(
&
pQInfo
->
runtimeEnv
,
info
->
pTable
,
window
,
buf
);
if
(
item
==
NULL
)
{
if
(
item
==
NULL
)
{
goto
_cleanup
;
goto
_cleanup
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录