Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
电商架构修炼
TDengine
提交
40cafb49
TDengine
项目概览
电商架构修炼
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
40cafb49
编写于
3月 10, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-2895] refactor.
上级
d57b3f38
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
25 deletion
+22
-25
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+3
-8
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+18
-16
src/query/src/queryMain.c
src/query/src/queryMain.c
+1
-1
未找到文件。
src/query/inc/qExecutor.h
浏览文件 @
40cafb49
...
...
@@ -260,6 +260,7 @@ typedef struct SQueryRuntimeEnv {
int64_t
currentOffset
;
// dynamic offset value
SRspResultInfo
resultInfo
;
SHashObj
*
pTableRetrieveTsMap
;
}
SQueryRuntimeEnv
;
enum
{
...
...
@@ -307,17 +308,11 @@ enum {
typedef
struct
SQInfo
{
void
*
signature
;
int32_t
code
;
// error code to returned to client
int64_t
owner
;
// if it is in execution
int32_t
code
;
// error code to returned to client
int64_t
owner
;
// if it is in execution
SQueryRuntimeEnv
runtimeEnv
;
SQuery
query
;
SHashObj
*
arrTableIdInfo
;
/*
* the query is executed position on which meter of the whole list.
* when the index reaches the last one of the list, it means the query is completed.
*/
void
*
pBuf
;
// allocated buffer for STableQueryInfo, sizeof(STableQueryInfo)*numOfTables;
pthread_mutex_t
lock
;
// used to synchronize the rsp/query threads
...
...
src/query/src/qExecutor.c
浏览文件 @
40cafb49
...
...
@@ -157,7 +157,7 @@ static bool hasMainOutput(SQuery *pQuery);
static
void
releaseQueryBuf
(
size_t
numOfTables
);
static
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
static
STsdbQueryCond
createTsdbQueryCond
(
SQuery
*
pQuery
,
STimeWindow
*
win
);
static
STableIdInfo
createTableIdInfo
(
S
Query
*
pQuery
);
static
STableIdInfo
createTableIdInfo
(
S
TableQueryInfo
*
pTableQueryInfo
);
static
void
setTableScanFilterOperatorInfo
(
STableScanInfo
*
pTableScanInfo
,
SOperatorInfo
*
pDownstream
);
...
...
@@ -1619,6 +1619,9 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
pRuntimeEnv
->
tagVal
=
malloc
(
pQuery
->
tagLen
);
pRuntimeEnv
->
currentOffset
=
pQuery
->
limit
.
offset
;
// NOTE: pTableCheckInfo need to update the query time range and the lastKey info
pRuntimeEnv
->
pTableRetrieveTsMap
=
taosHashInit
(
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
pRuntimeEnv
->
sasArray
=
calloc
(
pQuery
->
numOfOutput
,
sizeof
(
SArithmeticSupport
));
if
(
pRuntimeEnv
->
sasArray
==
NULL
||
pRuntimeEnv
->
pResultRowHashTable
==
NULL
||
pRuntimeEnv
->
keyBuf
==
NULL
||
...
...
@@ -1755,6 +1758,9 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
taosArrayDestroyEx
(
pRuntimeEnv
->
prevResult
,
freeInterResult
);
pRuntimeEnv
->
prevResult
=
NULL
;
taosHashCleanup
(
pRuntimeEnv
->
pTableRetrieveTsMap
);
pRuntimeEnv
->
pTableRetrieveTsMap
=
NULL
;
destroyOperatorInfo
(
pRuntimeEnv
->
proot
);
}
...
...
@@ -3476,12 +3482,12 @@ static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data
}
}
int32_t
numOfTables
=
(
int32_t
)
taosHashGetSize
(
p
QInfo
->
arrTableIdInfo
);
int32_t
numOfTables
=
(
int32_t
)
taosHashGetSize
(
p
RuntimeEnv
->
pTableRetrieveTsMap
);
*
(
int32_t
*
)
data
=
htonl
(
numOfTables
);
data
+=
sizeof
(
int32_t
);
int32_t
total
=
0
;
STableIdInfo
*
item
=
taosHashIterate
(
p
QInfo
->
arrTableIdInfo
,
NULL
);
STableIdInfo
*
item
=
taosHashIterate
(
p
RuntimeEnv
->
pTableRetrieveTsMap
,
NULL
);
while
(
item
)
{
STableIdInfo
*
pDst
=
(
STableIdInfo
*
)
data
;
...
...
@@ -3493,7 +3499,7 @@ static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data
total
++
;
qDebug
(
"QInfo:%p set subscribe info, tid:%d, uid:%"
PRIu64
", skey:%"
PRId64
,
pQInfo
,
item
->
tid
,
item
->
uid
,
item
->
key
);
item
=
taosHashIterate
(
p
QInfo
->
arrTableIdInfo
,
item
);
item
=
taosHashIterate
(
p
RuntimeEnv
->
pTableRetrieveTsMap
,
item
);
}
qDebug
(
"QInfo:%p set %d subscribe info"
,
pQInfo
,
total
);
...
...
@@ -4006,22 +4012,20 @@ STsdbQueryCond createTsdbQueryCond(SQuery* pQuery, STimeWindow* win) {
return
cond
;
}
static
STableIdInfo
createTableIdInfo
(
SQuery
*
pQuery
)
{
assert
(
pQuery
!=
NULL
&&
pQuery
->
current
!=
NULL
);
static
STableIdInfo
createTableIdInfo
(
STableQueryInfo
*
pTableQueryInfo
)
{
STableIdInfo
tidInfo
;
STableId
*
id
=
TSDB_TABLEID
(
p
Query
->
current
->
pTable
);
STableId
*
id
=
TSDB_TABLEID
(
p
TableQueryInfo
->
pTable
);
tidInfo
.
uid
=
id
->
uid
;
tidInfo
.
tid
=
id
->
tid
;
tidInfo
.
key
=
p
Query
->
current
->
lastKey
;
tidInfo
.
key
=
p
TableQueryInfo
->
lastKey
;
return
tidInfo
;
}
static
UNUSED_FUNC
void
updateTableIdInfo
(
SQuery
*
pQuery
,
SHashObj
*
pTableIdInfo
)
{
STableIdInfo
tidInfo
=
createTableIdInfo
(
p
Query
);
STableIdInfo
*
idinfo
=
taosHashGet
(
pTableIdInfo
,
&
tidInfo
.
tid
,
sizeof
(
tidInfo
.
tid
));
static
void
updateTableIdInfo
(
STableQueryInfo
*
pTableQueryInfo
,
SHashObj
*
pTableIdInfo
)
{
STableIdInfo
tidInfo
=
createTableIdInfo
(
p
TableQueryInfo
);
STableIdInfo
*
idinfo
=
taosHashGet
(
pTableIdInfo
,
&
tidInfo
.
tid
,
sizeof
(
tidInfo
.
tid
));
if
(
idinfo
!=
NULL
)
{
assert
(
idinfo
->
tid
==
tidInfo
.
tid
&&
idinfo
->
uid
==
tidInfo
.
uid
);
idinfo
->
key
=
tidInfo
.
key
;
...
...
@@ -4465,6 +4469,8 @@ static SSDataBlock* doArithmeticOperation(void* param) {
arithmeticApplyFunctions
(
pRuntimeEnv
,
pInfo
->
pCtx
,
pOperator
->
numOfOutput
);
pInfo
->
pRes
->
info
.
rows
=
getNumOfResult
(
pRuntimeEnv
,
pInfo
->
pCtx
,
pOperator
->
numOfOutput
);
updateTableIdInfo
(
pRuntimeEnv
->
pQuery
->
current
,
pRuntimeEnv
->
pTableRetrieveTsMap
);
if
(
pInfo
->
pRes
->
info
.
rows
>=
pRuntimeEnv
->
resultInfo
.
threshold
)
{
break
;
}
...
...
@@ -6038,8 +6044,6 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SSqlGroupbyExpr* pGroupbyExpr
goto
_cleanup
;
}
// NOTE: pTableCheckInfo need to update the query time range and the lastKey info
pQInfo
->
arrTableIdInfo
=
taosHashInit
(
pTableGroupInfo
->
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
pQInfo
->
dataReady
=
QUERY_RESULT_NOT_READY
;
pQInfo
->
rspContext
=
NULL
;
pQInfo
->
sql
=
sql
;
...
...
@@ -6293,10 +6297,8 @@ void freeQInfo(SQInfo *pQInfo) {
tfree
(
pQInfo
->
sql
);
tsdbDestroyTableGroup
(
&
pQuery
->
tableGroupInfo
);
taosHashCleanup
(
pQInfo
->
arrTableIdInfo
);
taosArrayDestroy
(
pRuntimeEnv
->
groupResInfo
.
pRows
);
pQInfo
->
signature
=
0
;
qDebug
(
"QInfo:%p QInfo is freed"
,
pQInfo
);
...
...
src/query/src/queryMain.c
浏览文件 @
40cafb49
...
...
@@ -308,7 +308,7 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co
int32_t
s
=
GET_NUM_OF_RESULTS
(
pRuntimeEnv
);
size_t
size
=
pQuery
->
resultRowSize
*
s
;
size
+=
sizeof
(
int32_t
);
size
+=
sizeof
(
STableIdInfo
)
*
taosHashGetSize
(
p
QInfo
->
arrTableIdInfo
);
size
+=
sizeof
(
STableIdInfo
)
*
taosHashGetSize
(
p
RuntimeEnv
->
pTableRetrieveTsMap
);
*
contLen
=
(
int32_t
)(
size
+
sizeof
(
SRetrieveTableRsp
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录