Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7ab2e76c
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看板
提交
7ab2e76c
编写于
5月 12, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(tmq): support get tb name
上级
4a791097
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
64 addition
and
13 deletion
+64
-13
example/src/tmq.c
example/src/tmq.c
+7
-2
include/client/taos.h
include/client/taos.h
+1
-4
include/common/tmsg.h
include/common/tmsg.h
+10
-0
source/client/src/tmq.c
source/client/src/tmq.c
+13
-0
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+2
-2
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+5
-5
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+26
-0
未找到文件。
example/src/tmq.c
浏览文件 @
7ab2e76c
...
...
@@ -32,6 +32,11 @@ static void msg_process(TAOS_RES* msg) {
int32_t
numOfFields
=
taos_field_count
(
msg
);
taos_print_row
(
buf
,
row
,
fields
,
numOfFields
);
printf
(
"%s
\n
"
,
buf
);
const
char
*
tbName
=
tmq_get_table_name
(
msg
);
if
(
tbName
)
{
printf
(
"from tb: %s
\n
"
,
tbName
);
}
}
}
...
...
@@ -101,8 +106,8 @@ int32_t create_topic() {
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create topic topic_ctb_column as abc1"
);
/*pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1, c2, c3 from ct1");*/
/*pRes = taos_query(pConn, "create topic topic_ctb_column as abc1");*/
pRes
=
taos_query
(
pConn
,
"create topic topic_ctb_column with table as select ts, c1, c2, c3 from st1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create topic topic_ctb_column, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
...
...
include/client/taos.h
浏览文件 @
7ab2e76c
...
...
@@ -257,10 +257,7 @@ DLL_EXPORT void tmq_conf_set_offset_commit_cb(tmq_conf_t *conf, tmq_co
DLL_EXPORT
const
char
*
tmq_get_topic_name
(
TAOS_RES
*
res
);
DLL_EXPORT
int32_t
tmq_get_vgroup_id
(
TAOS_RES
*
res
);
// TODO
#if 0
DLL_EXPORT char *tmq_get_table_name(TAOS_RES *res);
#endif
DLL_EXPORT
const
char
*
tmq_get_table_name
(
TAOS_RES
*
res
);
#if 0
DLL_EXPORT int64_t tmq_get_request_offset(tmq_message_t *message);
...
...
include/common/tmsg.h
浏览文件 @
7ab2e76c
...
...
@@ -2480,6 +2480,10 @@ static FORCE_INLINE int32_t tEncodeSMqDataBlkRsp(void** buf, const SMqDataBlkRsp
SSchemaWrapper
*
pSW
=
(
SSchemaWrapper
*
)
taosArrayGetP
(
pRsp
->
blockSchema
,
i
);
tlen
+=
taosEncodeSSchemaWrapper
(
buf
,
pSW
);
}
if
(
pRsp
->
withTbName
)
{
char
*
tbName
=
(
char
*
)
taosArrayGetP
(
pRsp
->
blockTbName
,
i
);
tlen
+=
taosEncodeString
(
buf
,
tbName
);
}
}
}
return
tlen
;
...
...
@@ -2492,6 +2496,7 @@ static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* p
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
blockNum
);
pRsp
->
blockData
=
taosArrayInit
(
pRsp
->
blockNum
,
sizeof
(
void
*
));
pRsp
->
blockDataLen
=
taosArrayInit
(
pRsp
->
blockNum
,
sizeof
(
void
*
));
pRsp
->
blockTbName
=
taosArrayInit
(
pRsp
->
blockNum
,
sizeof
(
void
*
));
pRsp
->
blockSchema
=
taosArrayInit
(
pRsp
->
blockNum
,
sizeof
(
void
*
));
if
(
pRsp
->
blockNum
!=
0
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pRsp
->
withTbName
);
...
...
@@ -2510,6 +2515,11 @@ static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* p
buf
=
taosDecodeSSchemaWrapper
(
buf
,
pSW
);
taosArrayPush
(
pRsp
->
blockSchema
,
&
pSW
);
}
if
(
pRsp
->
withTbName
)
{
char
*
name
=
NULL
;
buf
=
taosDecodeString
(
buf
,
&
name
);
taosArrayPush
(
pRsp
->
blockTbName
,
&
name
);
}
}
}
return
(
void
*
)
buf
;
...
...
source/client/src/tmq.c
浏览文件 @
7ab2e76c
...
...
@@ -1346,3 +1346,16 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) {
return
-
1
;
}
}
const
char
*
tmq_get_table_name
(
TAOS_RES
*
res
)
{
if
(
TD_RES_TMQ
(
res
))
{
SMqRspObj
*
pRspObj
=
(
SMqRspObj
*
)
res
;
if
(
!
pRspObj
->
rsp
.
withTbName
||
pRspObj
->
rsp
.
blockTbName
==
NULL
||
pRspObj
->
resIter
<
0
||
pRspObj
->
resIter
>=
pRspObj
->
rsp
.
blockNum
)
{
return
NULL
;
}
const
char
*
name
=
taosArrayGetP
(
pRspObj
->
rsp
.
blockTbName
,
pRspObj
->
resIter
);
return
name
;
}
return
NULL
;
}
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
7ab2e76c
...
...
@@ -297,8 +297,8 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
topicObj
.
ast
=
strdup
(
pCreate
->
ast
);
topicObj
.
astLen
=
strlen
(
pCreate
->
ast
)
+
1
;
topicObj
.
subType
=
TOPIC_SUB_TYPE__TABLE
;
topicObj
.
withTbName
=
0
;
topicObj
.
withSchema
=
0
;
topicObj
.
withTbName
=
pCreate
->
withTbName
;
topicObj
.
withSchema
=
pCreate
->
withSchema
;
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
!=
0
)
{
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
7ab2e76c
...
...
@@ -111,10 +111,10 @@ int64_t metaSmaCursorNext(SMSmaCursor* pSmaCur);
// SMetaDB
int
metaOpenDB
(
SMeta
*
pMeta
);
void
metaCloseDB
(
SMeta
*
pMeta
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
,
STbDdlH
*
pHandle
);
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaSaveSmaToDB
(
SMeta
*
pMeta
,
STSma
*
pTbCfg
);
int
metaRemoveSmaFromDb
(
SMeta
*
pMeta
,
int64_t
indexUid
);
//
int metaSaveTableToDB(SMeta* pMeta, STbCfg* pTbCfg, STbDdlH* pHandle);
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaSaveSmaToDB
(
SMeta
*
pMeta
,
STSma
*
pTbCfg
);
int
metaRemoveSmaFromDb
(
SMeta
*
pMeta
,
int64_t
indexUid
);
#endif
#endif
...
...
@@ -123,4 +123,4 @@ int metaRemoveSmaFromDb(SMeta* pMeta, int64_t indexUid);
}
#endif
#endif
/*_TD_VNODE_META_H_*/
\ No newline at end of file
#endif
/*_TD_VNODE_META_H_*/
source/dnode/vnode/src/tq/tq.c
浏览文件 @
7ab2e76c
...
...
@@ -427,9 +427,12 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
SMqDataBlkRsp
rsp
=
{
0
};
rsp
.
reqOffset
=
pReq
->
currentOffset
;
rsp
.
withSchema
=
pExec
->
withSchema
;
rsp
.
withTbName
=
pExec
->
withTbName
;
rsp
.
blockData
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
rsp
.
blockDataLen
=
taosArrayInit
(
0
,
sizeof
(
int32_t
));
rsp
.
blockSchema
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
rsp
.
blockTbName
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
while
(
1
)
{
consumerEpoch
=
atomic_load_32
(
&
pExec
->
epoch
);
...
...
@@ -535,6 +538,18 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
taosArrayPush
(
rsp
.
blockSchema
,
&
pSW
);
}
if
(
pExec
->
withTbName
)
{
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
pTq
->
pVnode
->
pMeta
,
0
);
int64_t
uid
=
pExec
->
pExecReader
[
workerId
]
->
msgIter
.
uid
;
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
ASSERT
(
0
);
}
char
*
tbName
=
strdup
(
mr
.
me
.
name
);
taosArrayPush
(
rsp
.
blockTbName
,
&
tbName
);
metaReaderClear
(
&
mr
);
}
rsp
.
blockNum
++
;
}
// db subscribe
...
...
@@ -563,6 +578,16 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
ASSERT
(
actualLen
<=
dataStrLen
);
taosArrayPush
(
rsp
.
blockDataLen
,
&
actualLen
);
taosArrayPush
(
rsp
.
blockData
,
&
buf
);
if
(
pExec
->
withTbName
)
{
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
pTq
->
pVnode
->
pMeta
,
0
);
if
(
metaGetTableEntryByUid
(
&
mr
,
block
.
info
.
uid
)
<
0
)
{
ASSERT
(
0
);
}
char
*
tbName
=
strdup
(
mr
.
me
.
name
);
taosArrayPush
(
rsp
.
blockTbName
,
&
tbName
);
metaReaderClear
(
&
mr
);
}
SSchemaWrapper
*
pSW
=
tCloneSSchemaWrapper
(
pExec
->
pExecReader
[
workerId
]
->
pSchemaWrapper
);
taosArrayPush
(
rsp
.
blockSchema
,
&
pSW
);
...
...
@@ -614,6 +639,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
taosArrayDestroy
(
rsp
.
blockData
);
taosArrayDestroy
(
rsp
.
blockDataLen
);
taosArrayDestroyP
(
rsp
.
blockSchema
,
(
FDelete
)
tDeleteSSchemaWrapper
);
taosArrayDestroyP
(
rsp
.
blockTbName
,
(
FDelete
)
taosMemoryFree
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录