Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a1c6c94c
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看板
提交
a1c6c94c
编写于
1月 21, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
consume skip ununsed table
上级
99984adb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
46 deletion
+80
-46
include/common/tmsg.h
include/common/tmsg.h
+2
-2
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+8
-3
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+69
-41
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+1
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
a1c6c94c
...
...
@@ -1590,8 +1590,8 @@ typedef struct SMqCVConsumeReq {
typedef
struct
SMqConsumeRspBlock
{
int32_t
bodyLen
;
char
topicName
[
TSDB_TOPIC_FNAME_LEN
];
char
body
[];
char
topicName
[
TSDB_TOPIC_FNAME_LEN
];
char
body
[];
}
SMqConsumeRspBlock
;
typedef
struct
SMqCVConsumeRsp
{
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
a1c6c94c
...
...
@@ -68,12 +68,13 @@ typedef struct {
typedef
struct
STqReadHandle
{
int64_t
ver
;
int64_t
tbUid
;
SSubmitMsg
*
pMsg
;
SSubmitBlk
*
pBlock
;
SSubmitMsgIter
msgIter
;
SSubmitBlkIter
blkIter
;
SMeta
*
pMeta
;
SArray
*
pCol
umn
IdList
;
SArray
*
pColIdList
;
}
STqReadHandle
;
/* ------------------------ SVnode ------------------------ */
...
...
@@ -199,8 +200,12 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
STqReadHandle
*
tqInitSubmitMsgScanner
(
SMeta
*
pMeta
);
static
FORCE_INLINE
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColumnIdList
)
{
pReadHandle
->
pColumnIdList
=
pColumnIdList
;
static
FORCE_INLINE
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColIdList
)
{
pReadHandle
->
pColIdList
=
pColIdList
;
}
static
FORCE_INLINE
void
tqReadHandleSetTbUid
(
STqReadHandle
*
pHandle
,
int64_t
tbUid
)
{
pHandle
->
tbUid
=
tbUid
;
}
void
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitMsg
*
pMsg
,
int64_t
ver
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
a1c6c94c
...
...
@@ -15,6 +15,7 @@
#include "tqInt.h"
#include "tqMetaStore.h"
#include "tcompare.h"
// static
// read next version data
...
...
@@ -424,7 +425,7 @@ int tqConsume(STQ* pTq, SRpcMsg* pReq, SRpcMsg** pRsp) {
/*int code = pTq->tqLogReader->logRead(, &raw, pItem->offset);*/
/*int code = pTq->tqLogHandle->logRead(pItem->pTopic->logReader, &raw, pItem->offset);*/
/*if (code < 0) {*/
// TODO: error
// TODO: error
/*}*/
// get msgType
// if submitblk
...
...
@@ -610,61 +611,91 @@ int tqItemSSize() {
int32_t
tqProcessConsumeReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
ppRsp
)
{
SMqCVConsumeReq
*
pReq
=
pMsg
->
pCont
;
SRpcMsg
rpcMsg
;
int64_t
reqId
=
pReq
->
reqId
;
int64_t
consumerId
=
pReq
->
consumerId
;
int64_t
reqOffset
=
pReq
->
offset
;
int64_t
fetchOffset
=
reqOffset
;
int64_t
blockingTime
=
pReq
->
blockingTime
;
int
rspLen
=
0
;
STqConsumerHandle
*
pConsumer
=
tqHandleGet
(
pTq
->
tqMeta
,
consumerId
);
int
sz
=
taosArrayGetSize
(
pConsumer
->
topics
);
int
sz
=
taosArrayGetSize
(
pConsumer
->
topics
);
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
STqTopicHandle
*
pTopic
=
taosArrayGet
(
pConsumer
->
topics
,
i
);
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
STqTopicHandle
*
pTopic
=
taosArrayGet
(
pConsumer
->
topics
,
i
);
int8_t
pos
=
fetchOffset
%
TQ_BUFFER_SIZE
;
int8_t
old
=
atomic_val_compare_exchange_8
(
&
pTopic
->
buffer
.
output
[
pos
].
status
,
0
,
1
);
if
(
old
==
1
)
{
// do nothing
continue
;
}
if
(
walReadWithHandle
(
pTopic
->
pReadhandle
,
fetchOffset
)
<
0
)
{
return
-
1
;
}
SWalHead
*
pHead
=
pTopic
->
pReadhandle
->
pHead
;
int8_t
pos
;
int8_t
skip
=
0
;
SWalHead
*
pHead
;
while
(
1
)
{
pos
=
fetchOffset
%
TQ_BUFFER_SIZE
;
skip
=
atomic_val_compare_exchange_8
(
&
pTopic
->
buffer
.
output
[
pos
].
status
,
0
,
1
);
if
(
skip
==
1
)
{
// do nothing
break
;
}
if
(
walReadWithHandle
(
pTopic
->
pReadhandle
,
fetchOffset
)
<
0
)
{
// check err
atomic_store_8
(
&
pTopic
->
buffer
.
output
[
pos
].
status
,
0
);
skip
=
1
;
break
;
}
// read until find TDMT_VND_SUBMIT
pHead
=
pTopic
->
pReadhandle
->
pHead
;
if
(
pHead
->
head
.
msgType
==
TDMT_VND_SUBMIT
)
{
break
;
}
if
(
walReadWithHandle
(
pTopic
->
pReadhandle
,
fetchOffset
)
<
0
)
{
return
-
1
;
atomic_store_8
(
&
pTopic
->
buffer
.
output
[
pos
].
status
,
0
);
skip
=
1
;
break
;
}
atomic_store_8
(
&
pTopic
->
buffer
.
output
[
pos
].
status
,
0
);
fetchOffset
++
;
}
if
(
skip
==
1
)
continue
;
SSubmitMsg
*
pCont
=
(
SSubmitMsg
*
)
&
pHead
->
head
.
body
;
void
*
task
=
pTopic
->
buffer
.
output
[
pos
].
task
;
qTaskInfo_t
task
=
pTopic
->
buffer
.
output
[
pos
].
task
;
qSetStreamInput
(
task
,
pCont
);
SSDataBlock
*
pDataBlock
;
uint64_t
ts
;
if
(
qExecTask
(
task
,
&
pDataBlock
,
&
ts
)
<
0
)
{
//SArray<SSDataBlock>
SArray
*
pRes
=
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
while
(
1
)
{
SSDataBlock
*
pDataBlock
;
uint64_t
ts
;
if
(
qExecTask
(
task
,
&
pDataBlock
,
&
ts
)
<
0
)
{
break
;
}
if
(
pDataBlock
!=
NULL
)
{
taosArrayPush
(
pRes
,
pDataBlock
);
}
else
{
break
;
}
}
atomic_store_8
(
&
pTopic
->
buffer
.
output
[
pos
].
status
,
0
);
if
(
taosArrayGetSize
(
pRes
)
==
0
)
{
taosArrayDestroy
(
pRes
);
fetchOffset
++
;
continue
;
}
// TODO: launch query and get output data
pTopic
->
buffer
.
output
[
pos
].
dst
=
pDataBlock
;
if
(
pTopic
->
buffer
.
firstOffset
==
-
1
||
pReq
->
offset
<
pTopic
->
buffer
.
firstOffset
)
{
pTopic
->
buffer
.
output
[
pos
].
dst
=
pRes
;
if
(
pTopic
->
buffer
.
firstOffset
==
-
1
||
pReq
->
offset
<
pTopic
->
buffer
.
firstOffset
)
{
pTopic
->
buffer
.
firstOffset
=
pReq
->
offset
;
}
if
(
pTopic
->
buffer
.
lastOffset
==
-
1
||
pReq
->
offset
>
pTopic
->
buffer
.
lastOffset
)
{
if
(
pTopic
->
buffer
.
lastOffset
==
-
1
||
pReq
->
offset
>
pTopic
->
buffer
.
lastOffset
)
{
pTopic
->
buffer
.
lastOffset
=
pReq
->
offset
;
}
atomic_store_8
(
&
pTopic
->
buffer
.
output
[
pos
].
status
,
1
);
// put output into rsp
}
// launch query
// get result
SMqCvConsumeRsp
*
pRsp
;
return
0
;
}
...
...
@@ -673,14 +704,14 @@ int32_t tqProcessSetConnReq(STQ* pTq, SMqSetCVgReq* pReq) {
if
(
pConsumer
==
NULL
)
{
return
-
1
;
}
STqTopicHandle
*
pTopic
=
calloc
(
sizeof
(
STqTopicHandle
),
1
);
if
(
pTopic
==
NULL
)
{
free
(
pConsumer
);
return
-
1
;
}
strcpy
(
pTopic
->
topicName
,
pReq
->
topicName
);
strcpy
(
pTopic
->
cgroup
,
pReq
->
cgroup
);
strcpy
(
pTopic
->
topicName
,
pReq
->
topicName
);
strcpy
(
pTopic
->
cgroup
,
pReq
->
cgroup
);
strcpy
(
pTopic
->
sql
,
pReq
->
sql
);
strcpy
(
pTopic
->
logicalPlan
,
pReq
->
logicalPlan
);
strcpy
(
pTopic
->
physicalPlan
,
pReq
->
physicalPlan
);
...
...
@@ -689,7 +720,6 @@ int32_t tqProcessSetConnReq(STQ* pTq, SMqSetCVgReq* pReq) {
pTopic
->
buffer
.
lastOffset
=
-
1
;
pTopic
->
pReadhandle
=
walOpenReadHandle
(
pTq
->
pWal
);
if
(
pTopic
->
pReadhandle
==
NULL
)
{
}
for
(
int
i
=
0
;
i
<
TQ_BUFFER_SIZE
;
i
++
)
{
pTopic
->
buffer
.
output
[
i
].
status
=
0
;
...
...
@@ -708,7 +738,7 @@ STqReadHandle* tqInitSubmitMsgScanner(SMeta* pMeta) {
pReadHandle
->
pMeta
=
pMeta
;
pReadHandle
->
pMsg
=
NULL
;
pReadHandle
->
ver
=
-
1
;
pReadHandle
->
pCol
umn
IdList
=
NULL
;
pReadHandle
->
pColIdList
=
NULL
;
return
NULL
;
}
...
...
@@ -720,20 +750,18 @@ void tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitMsg* pMsg, int64_t ve
}
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
)
{
if
(
tGetSubmitMsgNext
(
&
pHandle
->
msgIter
,
&
pHandle
->
pBlock
)
<
0
)
{
return
fals
e
;
while
(
tGetSubmitMsgNext
(
&
pHandle
->
msgIter
,
&
pHandle
->
pBlock
)
>=
0
)
{
if
(
pHandle
->
tbUid
==
pHandle
->
pBlock
->
uid
)
return
tru
e
;
}
return
tru
e
;
return
fals
e
;
}
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
)
{
SMemRow
row
;
int32_t
sversion
=
pHandle
->
pBlock
->
sversion
;
SSchemaWrapper
*
pSchema
=
metaGetTableSchema
(
pHandle
->
pMeta
,
pHandle
->
pBlock
->
uid
,
sversion
,
false
);
pBlockInfo
->
numOfCols
=
pSchema
->
nCols
;
/*int32_t sversion = pHandle->pBlock->sversion;*/
/*SSchemaWrapper* pSchema = metaGetTableSchema(pHandle->pMeta, pHandle->pBlock->uid, sversion, false);*/
pBlockInfo
->
numOfCols
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
pBlockInfo
->
rows
=
pHandle
->
pBlock
->
numOfRows
;
pBlockInfo
->
uid
=
pHandle
->
pBlock
->
uid
;
// TODO: filter out unused column
return
0
;
}
...
...
source/libs/executor/src/executor.c
浏览文件 @
a1c6c94c
...
...
@@ -29,6 +29,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input) {
return
doSetStreamBlock
(
pOperator
->
pDownstream
[
0
],
input
);
}
return
TSDB_CODE_QRY_APP_ERROR
;
}
else
{
SStreamBlockScanInfo
*
pInfo
=
pOperator
->
info
;
tqReadHandleSetMsg
(
pInfo
->
readerHandle
,
input
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录