Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
27d22335
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1181
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
27d22335
编写于
8月 04, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: merge multiple blocks in one rsp msg
上级
3a5fcefc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
38 deletion
+77
-38
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/libs/executor/dataSinkMgt.h
include/libs/executor/dataSinkMgt.h
+1
-0
source/libs/qworker/inc/qwInt.h
source/libs/qworker/inc/qwInt.h
+2
-0
source/libs/qworker/src/qwMsg.c
source/libs/qworker/src/qwMsg.c
+6
-3
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+67
-35
未找到文件。
include/common/tmsg.h
浏览文件 @
27d22335
...
...
@@ -1364,6 +1364,7 @@ typedef struct {
int8_t
compressed
;
int8_t
streamBlockType
;
int32_t
compLen
;
int32_t
numOfBlocks
;
int32_t
numOfRows
;
int32_t
numOfCols
;
int64_t
skey
;
...
...
include/libs/executor/dataSinkMgt.h
浏览文件 @
27d22335
...
...
@@ -67,6 +67,7 @@ typedef struct SInputData {
}
SInputData
;
typedef
struct
SOutputData
{
int32_t
numOfBlocks
;
int32_t
numOfRows
;
int32_t
numOfCols
;
int8_t
compressed
;
...
...
source/libs/qworker/inc/qwInt.h
浏览文件 @
27d22335
...
...
@@ -35,6 +35,7 @@ extern "C" {
#define QW_DEFAULT_SHORT_RUN_TIMES 2
#define QW_DEFAULT_HEARTBEAT_MSEC 5000
#define QW_SCH_TIMEOUT_MSEC 180000
#define QW_MIN_RES_ROWS 4096
enum
{
QW_PHASE_PRE_QUERY
=
1
,
...
...
@@ -135,6 +136,7 @@ typedef struct SQWTaskCtx {
int32_t
msgType
;
int32_t
fetchType
;
int32_t
execId
;
int32_t
level
;
bool
queryRsped
;
bool
queryEnd
;
...
...
source/libs/qworker/src/qwMsg.c
浏览文件 @
27d22335
...
...
@@ -12,14 +12,16 @@
int32_t
qwMallocFetchRsp
(
int32_t
length
,
SRetrieveTableRsp
**
rsp
)
{
int32_t
msgSize
=
sizeof
(
SRetrieveTableRsp
)
+
length
;
SRetrieveTableRsp
*
pRsp
=
(
SRetrieveTableRsp
*
)
rpc
MallocCont
(
msgSize
);
SRetrieveTableRsp
*
pRsp
=
(
SRetrieveTableRsp
*
)
rpc
ReallocCont
(
*
rsp
,
msgSize
);
if
(
NULL
==
pRsp
)
{
qError
(
"rpcMallocCont %d failed"
,
msgSize
);
QW_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
memset
(
pRsp
,
0
,
sizeof
(
SRetrieveTableRsp
));
if
(
NULL
==
*
rsp
)
{
memset
(
pRsp
,
0
,
sizeof
(
SRetrieveTableRsp
));
}
*
rsp
=
pRsp
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -35,6 +37,7 @@ void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete)
rsp
->
compLen
=
htonl
(
len
);
rsp
->
numOfRows
=
htonl
(
input
->
numOfRows
);
rsp
->
numOfCols
=
htonl
(
input
->
numOfCols
);
rsp
->
numOfBlocks
=
htonl
(
input
->
numOfBlocks
);
}
void
qwFreeFetchRsp
(
void
*
msg
)
{
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
27d22335
...
...
@@ -203,57 +203,88 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen,
SRetrieveTableRsp
*
rsp
=
NULL
;
bool
queryEnd
=
false
;
int32_t
code
=
0
;
SOutputData
output
=
{
0
};
dsGetDataLength
(
ctx
->
sinkHandle
,
&
len
,
&
queryEnd
)
;
*
dataLen
=
0
;
if
(
len
<
0
)
{
QW_TASK_ELOG
(
"invalid length from dsGetDataLength, length:%d"
,
len
);
QW_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
while
(
true
)
{
dsGetDataLength
(
ctx
->
sinkHandle
,
&
len
,
&
queryEnd
);
if
(
len
==
0
)
{
if
(
queryEnd
)
{
code
=
dsGetDataBlock
(
ctx
->
sinkHandle
,
pOutput
);
if
(
code
)
{
QW_TASK_ELOG
(
"dsGetDataBlock failed, code:%x - %s"
,
code
,
tstrerror
(
code
));
QW_ERR_RET
(
code
);
}
if
(
len
<
0
)
{
QW_TASK_ELOG
(
"invalid length from dsGetDataLength, length:%d"
,
len
);
QW_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
QW_TASK_DLOG_E
(
"no data in sink and query end"
);
if
(
len
==
0
)
{
if
(
queryEnd
)
{
code
=
dsGetDataBlock
(
ctx
->
sinkHandle
,
&
output
);
if
(
code
)
{
QW_TASK_ELOG
(
"dsGetDataBlock failed, code:%x - %s"
,
code
,
tstrerror
(
code
));
QW_ERR_RET
(
code
);
}
qwUpdateTaskStatus
(
QW_FPARAMS
(),
JOB_TASK_STATUS_SUCC
);
QW_ERR_RET
(
qwMallocFetchRsp
(
len
,
&
rsp
));
QW_TASK_DLOG
(
"no more data in sink and query end, fetched blocks %d rows %d"
,
pOutput
->
numOfBlocks
,
pOutput
->
numOfRows
);
*
rspMsg
=
rsp
;
*
dataLen
=
0
;
return
TSDB_CODE_SUCCESS
;
qwUpdateTaskStatus
(
QW_FPARAMS
(),
JOB_TASK_STATUS_SUCC
);
if
(
NULL
==
rsp
)
{
QW_ERR_RET
(
qwMallocFetchRsp
(
len
,
&
rsp
));
*
pOutput
=
output
;
}
else
{
pOutput
->
queryEnd
=
output
.
queryEnd
;
pOutput
->
bufStatus
=
output
.
bufStatus
;
pOutput
->
useconds
=
output
.
useconds
;
}
break
;
}
pOutput
->
bufStatus
=
DS_BUF_EMPTY
;
break
;
}
pOutput
->
bufStatus
=
DS_BUF_EMPTY
;
// Got data from sink
QW_TASK_DLOG
(
"there are data in sink, dataLength:%d"
,
len
);
return
TSDB_CODE_SUCCESS
;
}
*
dataLen
+=
len
;
// Got data from sink
QW_TASK_DLOG
(
"there are data in sink, dataLength:%d"
,
len
);
QW_ERR_RET
(
qwMallocFetchRsp
(
*
dataLen
,
&
rsp
));
*
dataLen
=
len
;
output
.
pData
=
rsp
->
data
+
*
dataLen
-
len
;
code
=
dsGetDataBlock
(
ctx
->
sinkHandle
,
&
output
);
if
(
code
)
{
QW_TASK_ELOG
(
"dsGetDataBlock failed, code:%x - %s"
,
code
,
tstrerror
(
code
));
QW_ERR_RET
(
code
);
}
QW_ERR_RET
(
qwMallocFetchRsp
(
len
,
&
rsp
));
*
rspMsg
=
rsp
;
pOutput
->
queryEnd
=
output
.
queryEnd
;
pOutput
->
precision
=
output
.
precision
;
pOutput
->
bufStatus
=
output
.
bufStatus
;
pOutput
->
useconds
=
output
.
useconds
;
pOutput
->
compressed
=
output
.
compressed
;
pOutput
->
numOfCols
=
output
.
numOfCols
;
pOutput
->
numOfRows
+=
output
.
numOfRows
;
pOutput
->
numOfBlocks
++
;
if
(
DS_BUF_EMPTY
==
pOutput
->
bufStatus
&&
pOutput
->
queryEnd
)
{
QW_TASK_DLOG
(
"task all data fetched and done, fetched blocks %d rows %d"
,
pOutput
->
numOfBlocks
,
pOutput
->
numOfRows
);
qwUpdateTaskStatus
(
QW_FPARAMS
(),
JOB_TASK_STATUS_SUCC
);
break
;
}
pOutput
->
pData
=
rsp
->
data
;
code
=
dsGetDataBlock
(
ctx
->
sinkHandle
,
pOutput
);
if
(
code
)
{
QW_TASK_ELOG
(
"dsGetDataBlock failed, code:%x - %s"
,
code
,
tstrerror
(
code
));
QW_ERR_RET
(
code
);
}
if
(
0
==
ctx
->
level
)
{
QW_TASK_DLOG
(
"task fetched blocks %d rows %d, level %d"
,
pOutput
->
numOfBlocks
,
pOutput
->
numOfRows
,
ctx
->
level
);
break
;
}
if
(
DS_BUF_EMPTY
==
pOutput
->
bufStatus
&&
pOutput
->
queryEnd
)
{
QW_TASK_DLOG_E
(
"task all data fetched, done"
);
qwUpdateTaskStatus
(
QW_FPARAMS
(),
JOB_TASK_STATUS_SUCC
);
if
(
pOutput
->
numOfRows
>=
QW_MIN_RES_ROWS
)
{
QW_TASK_DLOG
(
"task fetched blocks %d rows %d reaches the min rows"
,
pOutput
->
numOfBlocks
,
pOutput
->
numOfRows
);
break
;
}
}
*
rspMsg
=
rsp
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -551,6 +582,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, const char* sql) {
// queryRsped = true;
ctx
->
level
=
plan
->
level
;
atomic_store_ptr
(
&
ctx
->
taskHandle
,
pTaskInfo
);
atomic_store_ptr
(
&
ctx
->
sinkHandle
,
sinkHandle
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录