Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9dbb925a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
9dbb925a
编写于
10月 28, 2021
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add serialization and deserialization for tq
上级
e2622c7c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
97 addition
and
62 deletion
+97
-62
include/server/vnode/tq/tq.h
include/server/vnode/tq/tq.h
+11
-13
source/server/vnode/tq/src/tq.c
source/server/vnode/tq/src/tq.c
+86
-49
未找到文件。
include/server/vnode/tq/tq.h
浏览文件 @
9dbb925a
...
...
@@ -135,7 +135,7 @@ typedef struct tqBufferHandle {
}
tqBufferHandle
;
typedef
struct
tqListHandle
{
tqBufferHandle
*
bufHandle
;
tqBufferHandle
bufHandle
;
struct
tqListHandle
*
next
;
}
tqListHandle
;
...
...
@@ -176,22 +176,20 @@ int tqMoveOffsetToNext(tqGroupHandle*);
int
tqResetOffset
(
STQ
*
,
int64_t
topicId
,
int64_t
cgId
,
int64_t
offset
);
int
tqRegisterContext
(
tqGroupHandle
*
,
void
*
);
int
tqLaunchQuery
(
tqGroupHandle
*
);
int
tqSendLaunchQuery
(
STQ
*
,
int64_t
topicId
,
int64_t
cgId
,
void
*
query
);
int
tqSendLaunchQuery
(
tqGroupHandle
*
);
int
tqSerializeGroupHandle
(
tqGroupHandle
*
gHandle
,
void
**
ppBytes
,
int32_t
offset
);
int
tqSerializeListHandle
(
tqListHandle
*
listHandle
,
void
**
ppBytes
,
int32_t
offset
);
int
tqSerializeBufHandle
(
tqBufferHandle
*
bufHandle
,
void
**
ppBytes
,
int32_t
offset
);
int
tqSerializeBufItem
(
tqBufferItem
*
bufItem
,
void
**
ppBytes
,
int32_t
offset
);
int
tqSerializeGroupHandle
(
tqGroupHandle
*
gHandle
,
void
**
ppBytes
);
void
*
tqSerializeListHandle
(
tqListHandle
*
listHandle
,
void
*
ptr
);
void
*
tqSerializeBufHandle
(
tqBufferHandle
*
bufHandle
,
void
*
ptr
);
void
*
tqSerializeBufItem
(
tqBufferItem
*
bufItem
,
void
*
ptr
);
int
tqDeserializeGroupHandle
(
const
void
*
pBytes
,
tqGroupHandle
**
pGhandle
);
int
tqDeserializeListHandle
(
const
void
*
pBytes
,
tqListHandle
**
pListHandle
);
int
tqDeserializeBufHandle
(
const
void
*
pBytes
,
tqBufferHandle
**
pBufHandle
);
int
tqDeserializeBufItem
(
const
void
*
pBytes
,
tqBufferItem
**
pBufItem
);
const
void
*
tqDeserializeGroupHandle
(
const
void
*
pBytes
,
tqGroupHandle
*
ghandle
);
const
void
*
tqDeserializeBufHandle
(
const
void
*
pBytes
,
tqBufferHandle
*
bufHandle
);
const
void
*
tqDeserializeBufItem
(
const
void
*
pBytes
,
tqBufferItem
*
bufItem
);
int
tqGetGHandleSSize
(
const
tqGroupHandle
*
gHandle
);
int
tqListHandleSSize
(
const
tqListHandle
*
listHandle
);
int
tqBufHandleSSize
(
const
tqBufferHandle
*
bufHandle
);
int
tqBufItemSSize
(
const
tqBufferItem
*
bufItem
);
int
tqBufHandleSSize
();
int
tqBufItemSSize
();
#ifdef __cplusplus
}
...
...
source/server/vnode/tq/src/tq.c
浏览文件 @
9dbb925a
...
...
@@ -58,10 +58,10 @@ static int tqAck(tqGroupHandle* ghandle, tmqAcks* pAcks) {
int
ackCnt
=
0
;
tqQueryMsg
*
pQuery
=
NULL
;
while
(
i
<
ackNum
&&
node
->
next
)
{
if
(
acks
[
i
].
topicId
==
node
->
next
->
bufHandle
->
topicId
)
{
if
(
acks
[
i
].
topicId
==
node
->
next
->
bufHandle
.
topicId
)
{
ackCnt
++
;
tqAckOneTopic
(
node
->
next
->
bufHandle
,
&
acks
[
i
],
&
pQuery
);
}
else
if
(
acks
[
i
].
topicId
<
node
->
next
->
bufHandle
->
topicId
)
{
tqAckOneTopic
(
&
node
->
next
->
bufHandle
,
&
acks
[
i
],
&
pQuery
);
}
else
if
(
acks
[
i
].
topicId
<
node
->
next
->
bufHandle
.
topicId
)
{
i
++
;
}
else
{
node
=
node
->
next
;
...
...
@@ -114,7 +114,7 @@ static int tqFetch(tqGroupHandle* ghandle, void** msg) {
//until all topic iterated or msgs over sizeLimit
while
(
node
->
next
)
{
node
=
node
->
next
;
tqBufferHandle
*
bufHandle
=
node
->
bufHandle
;
tqBufferHandle
*
bufHandle
=
&
node
->
bufHandle
;
int
idx
=
bufHandle
->
nextConsumeOffset
%
TQ_BUFFER_SIZE
;
if
(
bufHandle
->
buffer
[
idx
].
content
!=
NULL
&&
bufHandle
->
buffer
[
idx
].
offset
==
bufHandle
->
nextConsumeOffset
...
...
@@ -140,11 +140,6 @@ static int tqFetch(tqGroupHandle* ghandle, void** msg) {
}
}
}
if
(
totSize
==
0
)
{
//no msg
return
-
1
;
}
return
totSize
;
}
...
...
@@ -157,7 +152,7 @@ int tqLaunchQuery(tqGroupHandle* ghandle) {
return
0
;
}
int
tqSendLaunchQuery
(
STQ
*
pTq
,
int64_t
topicId
,
int64_t
cgId
,
void
*
query
)
{
int
tqSendLaunchQuery
(
tqGroupHandle
*
gHandle
)
{
return
0
;
}
...
...
@@ -196,7 +191,7 @@ int tqConsume(STQ* pTq, tmqConsumeReq* pMsg) {
tmqConsumeRsp
*
pRsp
=
(
tmqConsumeRsp
*
)
pMsg
;
if
(
tqFetch
(
ghandle
,
(
void
**
)
&
pRsp
->
msgs
)
<
0
)
{
if
(
tqFetch
(
ghandle
,
(
void
**
)
&
pRsp
->
msgs
)
<
=
0
)
{
//fetch error
return
-
1
;
}
...
...
@@ -209,14 +204,9 @@ int tqConsume(STQ* pTq, tmqConsumeReq* pMsg) {
return
0
;
}
int
tqSerializeGroupHandle
(
tqGroupHandle
*
gHandle
,
void
**
ppBytes
,
int32_t
offset
)
{
int
tqSerializeGroupHandle
(
tqGroupHandle
*
gHandle
,
void
**
ppBytes
)
{
//calculate size
int
sz
=
tqGetGHandleSSize
(
gHandle
);
if
(
sz
<=
0
)
{
//TODO: err
return
-
1
;
}
void
*
ptr
=
realloc
(
*
ppBytes
,
sz
);
if
(
ptr
==
NULL
)
{
free
(
ppBytes
);
...
...
@@ -224,29 +214,30 @@ int tqSerializeGroupHandle(tqGroupHandle *gHandle, void** ppBytes, int32_t offse
return
-
1
;
}
*
ppBytes
=
ptr
;
//do serializ
e
//do serializ
ation
*
(
int64_t
*
)
ptr
=
gHandle
->
cId
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int64_t
));
*
(
int64_t
*
)
ptr
=
gHandle
->
cgId
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int64_t
));
*
(
int32_t
*
)
ptr
=
gHandle
->
topicNum
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int32_t
));
if
(
gHandle
->
topicNum
>
0
)
{
tqSerializeListHandle
(
gHandle
->
head
,
p
pBytes
,
ptr
-
*
ppBytes
);
tqSerializeListHandle
(
gHandle
->
head
,
p
tr
);
}
return
0
;
}
int
tqSerializeListHandle
(
tqListHandle
*
listHandle
,
void
**
ppBytes
,
int32_t
offset
)
{
void
*
ptr
=
POINTER_SHIFT
(
*
ppBytes
,
offset
);
void
*
tqSerializeListHandle
(
tqListHandle
*
listHandle
,
void
*
ptr
)
{
tqListHandle
*
node
=
listHandle
;
while
(
node
->
next
)
{
ASSERT
(
node
!=
NULL
);
while
(
node
)
{
ptr
=
tqSerializeBufHandle
(
&
node
->
bufHandle
,
ptr
);
node
=
node
->
next
;
offset
=
tqSerializeBufHandle
(
node
->
bufHandle
,
ppBytes
,
offset
);
}
return
offset
;
return
ptr
;
}
int
tqSerializeBufHandle
(
tqBufferHandle
*
bufHandle
,
void
**
ppBytes
,
int32_t
offset
)
{
void
*
ptr
=
POINTER_SHIFT
(
*
ppBytes
,
offset
);
void
*
tqSerializeBufHandle
(
tqBufferHandle
*
bufHandle
,
void
*
ptr
)
{
*
(
int64_t
*
)
ptr
=
bufHandle
->
nextConsumeOffset
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int64_t
));
*
(
int64_t
*
)
ptr
=
bufHandle
->
topicId
;
...
...
@@ -256,41 +247,87 @@ int tqSerializeBufHandle(tqBufferHandle *bufHandle, void** ppBytes, int32_t offs
*
(
int32_t
*
)
ptr
=
bufHandle
->
tail
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int32_t
));
for
(
int
i
=
0
;
i
<
TQ_BUFFER_SIZE
;
i
++
)
{
int
sz
=
tqSerializeBufItem
(
&
bufHandle
->
buffer
[
i
],
ppBytes
,
ptr
-
*
ppBytes
);
ptr
=
POINTER_SHIFT
(
ptr
,
sz
);
ptr
=
tqSerializeBufItem
(
&
bufHandle
->
buffer
[
i
],
ptr
);
}
return
ptr
-
*
ppBytes
;
return
ptr
;
}
int
tqSerializeBufItem
(
tqBufferItem
*
bufItem
,
void
**
ppBytes
,
int32_t
offset
)
{
void
*
ptr
=
POINTER_SHIFT
(
*
ppBytes
,
offset
);
void
*
tqSerializeBufItem
(
tqBufferItem
*
bufItem
,
void
*
ptr
)
{
//TODO: do we need serialize this?
return
0
;
//mainly for executor
return
ptr
;
}
int
tqDeserializeGroupHandle
(
const
void
*
pBytes
,
tqGroupHandle
**
pGhandle
)
{
return
0
;
}
int
tqDeserializeListHandle
(
const
void
*
pBytes
,
tqListHandle
**
pListHandle
)
{
return
0
;
}
int
tqDeserializeBufHandle
(
const
void
*
pBytes
,
tqBufferHandle
**
pBufHandle
)
{
return
0
;
const
void
*
tqDeserializeGroupHandle
(
const
void
*
pBytes
,
tqGroupHandle
*
gHandle
)
{
const
void
*
ptr
=
pBytes
;
gHandle
->
cId
=
*
(
int64_t
*
)
ptr
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int64_t
));
gHandle
->
cgId
=
*
(
int64_t
*
)
ptr
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int64_t
));
gHandle
->
ahandle
=
NULL
;
gHandle
->
topicNum
=
*
(
int32_t
*
)
ptr
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int32_t
));
gHandle
->
head
=
NULL
;
tqListHandle
*
node
=
gHandle
->
head
;
for
(
int
i
=
0
;
i
<
gHandle
->
topicNum
;
i
++
)
{
if
(
gHandle
->
head
==
NULL
)
{
if
((
node
=
malloc
(
sizeof
(
tqListHandle
)))
==
NULL
)
{
//TODO: error
return
NULL
;
}
node
->
next
=
NULL
;
ptr
=
tqDeserializeBufHandle
(
ptr
,
&
node
->
bufHandle
);
gHandle
->
head
=
node
;
}
else
{
node
->
next
=
malloc
(
sizeof
(
tqListHandle
));
if
(
node
->
next
==
NULL
)
{
//TODO: error
return
NULL
;
}
node
->
next
->
next
=
NULL
;
ptr
=
tqDeserializeBufHandle
(
ptr
,
&
node
->
next
->
bufHandle
);
node
=
node
->
next
;
}
}
return
ptr
;
}
int
tqDeserializeBufItem
(
const
void
*
pBytes
,
tqBufferItem
**
pBufItem
)
{
return
0
;
const
void
*
tqDeserializeBufHandle
(
const
void
*
pBytes
,
tqBufferHandle
*
bufHandle
)
{
const
void
*
ptr
=
pBytes
;
bufHandle
->
nextConsumeOffset
=
*
(
int64_t
*
)
ptr
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int64_t
));
bufHandle
->
topicId
=
*
(
int64_t
*
)
ptr
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int64_t
));
bufHandle
->
head
=
*
(
int32_t
*
)
ptr
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int32_t
));
bufHandle
->
tail
=
*
(
int32_t
*
)
ptr
;
ptr
=
POINTER_SHIFT
(
ptr
,
sizeof
(
int32_t
));
for
(
int
i
=
0
;
i
<
TQ_BUFFER_SIZE
;
i
++
)
{
ptr
=
tqDeserializeBufItem
(
ptr
,
&
bufHandle
->
buffer
[
i
]);
}
return
ptr
;
}
const
void
*
tqDeserializeBufItem
(
const
void
*
pBytes
,
tqBufferItem
*
bufItem
)
{
return
pBytes
;
}
//TODO: make this a macro
int
tqGetGHandleSSize
(
const
tqGroupHandle
*
gHandle
)
{
return
0
;
return
sizeof
(
int64_t
)
*
2
+
sizeof
(
int32_t
)
+
gHandle
->
topicNum
*
tqBufHandleSSize
();
}
int
tqListHandleSSize
(
const
tqListHandle
*
listHandle
)
{
return
0
;
}
int
tqBufHandleSSize
(
const
tqBufferHandle
*
bufHandle
)
{
return
0
;
//TODO: make this a macro
int
tqBufHandleSSize
()
{
return
sizeof
(
int64_t
)
*
2
+
sizeof
(
int32_t
)
*
2
+
TQ_BUFFER_SIZE
*
tqBufItemSSize
();
}
int
tqBufItemSSize
(
const
tqBufferItem
*
bufItem
)
{
int
tqBufItemSSize
()
{
//TODO: do this need serialization?
//mainly for executor
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录