Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
22470344
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
22470344
编写于
5月 26, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
scheduler async api test
上级
0c35e621
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
157 addition
and
19 deletion
+157
-19
include/libs/scheduler/scheduler.h
include/libs/scheduler/scheduler.h
+9
-17
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+97
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-0
source/libs/scheduler/src/schDbg.c
source/libs/scheduler/src/schDbg.c
+42
-0
source/libs/scheduler/src/schJob.c
source/libs/scheduler/src/schJob.c
+6
-1
source/libs/scheduler/src/schUtil.c
source/libs/scheduler/src/schUtil.c
+1
-0
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+1
-1
未找到文件。
include/libs/scheduler/scheduler.h
浏览文件 @
22470344
...
...
@@ -23,6 +23,8 @@ extern "C" {
#include "catalog.h"
#include "planner.h"
extern
tsem_t
schdRspSem
;
typedef
struct
SSchedulerCfg
{
uint32_t
maxJobNum
;
int32_t
maxNodeTableNum
;
...
...
@@ -62,6 +64,11 @@ typedef struct STaskInfo {
SSubQueryMsg
*
msg
;
}
STaskInfo
;
typedef
struct
SSchdFetchParam
{
void
**
pData
;
int32_t
*
code
;
}
SSchdFetchParam
;
typedef
void
(
*
schedulerExecCallback
)(
SQueryResult
*
pResult
,
void
*
param
,
int32_t
code
);
typedef
void
(
*
schedulerFetchCallback
)(
void
*
pResult
,
void
*
param
,
int32_t
code
);
...
...
@@ -113,23 +120,8 @@ void schedulerFreeJob(int64_t job);
void
schedulerDestroy
(
void
);
/**
* convert dag to task list
* @param pDag
* @param pTasks SArray**<STaskInfo>
* @return
*/
int32_t
schedulerConvertDagToTaskList
(
SQueryPlan
*
pDag
,
SArray
**
pTasks
);
/**
* make one task info's multiple copies
* @param src
* @param dst SArray**<STaskInfo>
* @return
*/
int32_t
schedulerCopyTask
(
STaskInfo
*
src
,
SArray
**
dst
,
int32_t
copyNum
);
void
schedulerFreeTaskList
(
SArray
*
taskList
);
void
schdExecCallback
(
SQueryResult
*
pResult
,
void
*
param
,
int32_t
code
);
void
schdFetchCallback
(
void
*
pResult
,
void
*
param
,
int32_t
code
);
#ifdef __cplusplus
...
...
source/client/src/clientImpl.c
浏览文件 @
22470344
...
...
@@ -289,6 +289,52 @@ void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) {
pResInfo
->
precision
=
precision
;
}
int32_t
scheduleAsyncQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
,
void
**
pRes
)
{
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
tsem_init
(
&
schdRspSem
,
0
,
0
);
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
};
int32_t
code
=
schedulerAsyncExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
pRequest
->
metric
.
start
,
schdExecCallback
,
&
res
);
while
(
true
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
schedulerFreeJob
(
pRequest
->
body
.
queryJob
);
}
*
pRes
=
res
.
res
;
pRequest
->
code
=
code
;
terrno
=
code
;
return
pRequest
->
code
;
}
else
{
tsem_wait
(
&
schdRspSem
);
if
(
res
.
code
)
{
code
=
res
.
code
;
}
else
{
break
;
}
}
}
if
(
TDMT_VND_SUBMIT
==
pRequest
->
type
||
TDMT_VND_CREATE_TABLE
==
pRequest
->
type
)
{
pRequest
->
body
.
resInfo
.
numOfRows
=
res
.
numOfRows
;
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
schedulerFreeJob
(
pRequest
->
body
.
queryJob
);
}
}
*
pRes
=
res
.
res
;
pRequest
->
code
=
res
.
code
;
terrno
=
res
.
code
;
return
pRequest
->
code
;
}
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
,
void
**
pRes
)
{
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
...
...
@@ -796,7 +842,58 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
}
}
void
*
doAsyncFetchRows
(
SRequestObj
*
pRequest
,
bool
setupOneRowPtr
,
bool
convertUcs4
)
{
assert
(
pRequest
!=
NULL
);
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
if
(
pResultInfo
->
pData
==
NULL
||
pResultInfo
->
current
>=
pResultInfo
->
numOfRows
)
{
// All data has returned to App already, no need to try again
if
(
pResultInfo
->
completed
)
{
pResultInfo
->
numOfRows
=
0
;
return
NULL
;
}
tsem_init
(
&
schdRspSem
,
0
,
0
);
SReqResultInfo
*
pResInfo
=
&
pRequest
->
body
.
resInfo
;
SSchdFetchParam
param
=
{.
pData
=
(
void
**
)
&
pResInfo
->
pData
,
.
code
=
&
pRequest
->
code
};
pRequest
->
code
=
schedulerAsyncFetchRows
(
pRequest
->
body
.
queryJob
,
schdFetchCallback
,
&
param
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pResultInfo
->
numOfRows
=
0
;
return
NULL
;
}
tsem_wait
(
&
schdRspSem
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pResultInfo
->
numOfRows
=
0
;
return
NULL
;
}
pRequest
->
code
=
setQueryResultFromRsp
(
&
pRequest
->
body
.
resInfo
,
(
SRetrieveTableRsp
*
)
pResInfo
->
pData
,
convertUcs4
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pResultInfo
->
numOfRows
=
0
;
return
NULL
;
}
tscDebug
(
"0x%"
PRIx64
" fetch results, numOfRows:%d total Rows:%"
PRId64
", complete:%d, reqId:0x%"
PRIx64
,
pRequest
->
self
,
pResInfo
->
numOfRows
,
pResInfo
->
totalRows
,
pResInfo
->
completed
,
pRequest
->
requestId
);
if
(
pResultInfo
->
numOfRows
==
0
)
{
return
NULL
;
}
}
if
(
setupOneRowPtr
)
{
doSetOneRowPtr
(
pResultInfo
);
pResultInfo
->
current
+=
1
;
}
return
pResultInfo
->
row
;
}
void
*
doFetchRows
(
SRequestObj
*
pRequest
,
bool
setupOneRowPtr
,
bool
convertUcs4
)
{
//return doAsyncFetchRows(pRequest, setupOneRowPtr, convertUcs4);
assert
(
pRequest
!=
NULL
);
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
22470344
...
...
@@ -2799,6 +2799,7 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt,
int32_t
code
=
getDBCfg
(
pCxt
,
pStmt
->
dbName
,
&
dbCfg
);
int32_t
num
=
taosArrayGetSize
(
dbCfg
.
pRetensions
);
if
(
TSDB_CODE_SUCCESS
!=
code
||
num
<
2
)
{
taosArrayDestroy
(
dbCfg
.
pRetensions
);
return
code
;
}
for
(
int32_t
i
=
1
;
i
<
num
;
++
i
)
{
...
...
source/libs/scheduler/src/schDbg.c
0 → 100644
浏览文件 @
22470344
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "query.h"
#include "schedulerInt.h"
tsem_t
schdRspSem
;
void
schdExecCallback
(
SQueryResult
*
pResult
,
void
*
param
,
int32_t
code
)
{
if
(
code
)
{
pResult
->
code
=
code
;
}
*
(
SQueryResult
*
)
param
=
*
pResult
;
taosMemoryFree
(
pResult
);
tsem_post
(
&
schdRspSem
);
}
void
schdFetchCallback
(
void
*
pResult
,
void
*
param
,
int32_t
code
)
{
SSchdFetchParam
*
fParam
=
(
SSchdFetchParam
*
)
param
;
*
fParam
->
pData
=
pResult
;
*
fParam
->
code
=
code
;
tsem_post
(
&
schdRspSem
);
}
source/libs/scheduler/src/schJob.c
浏览文件 @
22470344
...
...
@@ -856,7 +856,12 @@ _return:
void
schProcessOnDataFetched
(
SSchJob
*
job
)
{
atomic_val_compare_exchange_32
(
&
job
->
remoteFetch
,
1
,
0
);
if
(
job
->
attr
.
syncSchedule
)
{
tsem_post
(
&
job
->
rspSem
);
}
else
if
(
SCH_FETCH_CB
==
atomic_val_compare_exchange_32
(
&
job
->
userCb
,
SCH_FETCH_CB
,
0
))
{
schNotifyUserFetchRes
(
job
);
}
}
// Note: no more task error processing, handled in function internal
...
...
source/libs/scheduler/src/schUtil.c
浏览文件 @
22470344
...
...
@@ -66,6 +66,7 @@ void schFreeRpcCtxVal(const void *arg) {
SMsgSendInfo
*
pMsgSendInfo
=
(
SMsgSendInfo
*
)
arg
;
taosMemoryFreeClear
(
pMsgSendInfo
->
param
);
taosMemoryFreeClear
(
pMsgSendInfo
->
msgInfo
.
pData
);
taosMemoryFreeClear
(
pMsgSendInfo
);
}
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
22470344
...
...
@@ -124,7 +124,7 @@ int32_t schedulerAsyncFetchRows(int64_t job, schedulerFetchCallback fp, void* pa
pJob
->
userRes
.
fetchFp
=
fp
;
pJob
->
userRes
.
userParam
=
param
;
code
=
schFetchRows
(
pJob
);
code
=
sch
Async
FetchRows
(
pJob
);
schReleaseJob
(
job
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录