Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2de2eafa
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,发现更多精彩内容 >>
提交
2de2eafa
编写于
5月 24, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(tmq): use tdb as persistent storage
上级
984b8315
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
104 addition
and
10 deletion
+104
-10
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+2
-1
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+99
-6
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+3
-3
未找到文件。
source/dnode/vnode/src/inc/tq.h
浏览文件 @
2de2eafa
...
...
@@ -96,7 +96,8 @@ struct STQ {
SHashObj
*
pStreamTasks
;
SVnode
*
pVnode
;
SWal
*
pWal
;
TDB
*
pTdb
;
TDB
*
pMetaStore
;
TTB
*
pExecStore
;
};
typedef
struct
{
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
2de2eafa
...
...
@@ -14,6 +14,7 @@
*/
#include "tq.h"
#include "tdbInt.h"
int32_t
tqInit
()
{
int8_t
old
;
...
...
@@ -46,6 +47,10 @@ void tqCleanUp() {
}
}
int
tqExecKeyCompare
(
const
void
*
pKey1
,
int32_t
kLen1
,
const
void
*
pKey2
,
int32_t
kLen2
)
{
return
strcmp
(
pKey1
,
pKey2
);
}
STQ
*
tqOpen
(
const
char
*
path
,
SVnode
*
pVnode
,
SWal
*
pWal
)
{
STQ
*
pTq
=
taosMemoryMalloc
(
sizeof
(
STQ
));
if
(
pTq
==
NULL
)
{
...
...
@@ -55,9 +60,6 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
pTq
->
path
=
strdup
(
path
);
pTq
->
pVnode
=
pVnode
;
pTq
->
pWal
=
pWal
;
if
(
tdbOpen
(
path
,
4096
,
1
,
&
pTq
->
pTdb
)
<
0
)
{
ASSERT
(
0
);
}
pTq
->
execs
=
taosHashInit
(
64
,
MurmurHash3_32
,
true
,
HASH_ENTRY_LOCK
);
...
...
@@ -65,6 +67,43 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
pTq
->
pushMgr
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_ENTRY_LOCK
);
if
(
tdbOpen
(
path
,
16
*
1024
,
1
,
&
pTq
->
pMetaStore
)
<
0
)
{
ASSERT
(
0
);
}
if
(
tdbTbOpen
(
"exec"
,
-
1
,
-
1
,
tqExecKeyCompare
,
pTq
->
pMetaStore
,
&
pTq
->
pExecStore
)
<
0
)
{
ASSERT
(
0
);
}
TXN
txn
;
if
(
tdbTxnOpen
(
&
txn
,
0
,
tdbDefaultMalloc
,
tdbDefaultFree
,
NULL
,
0
)
<
0
)
{
ASSERT
(
0
);
}
/*if (tdbBegin(pTq->pMetaStore, &txn) < 0) {*/
/*ASSERT(0);*/
/*}*/
TBC
*
pCur
;
if
(
tdbTbcOpen
(
pTq
->
pExecStore
,
&
pCur
,
&
txn
)
<
0
)
{
ASSERT
(
0
);
}
void
*
pKey
;
int
kLen
;
void
*
pVal
;
int
vLen
;
tdbTbcMoveToFirst
(
pCur
);
while
(
tdbTbcNext
(
pCur
,
&
pKey
,
&
kLen
,
&
pVal
,
&
vLen
)
==
0
)
{
// create, put into execsj
}
if
(
tdbTxnClose
(
&
txn
)
<
0
)
{
ASSERT
(
0
);
}
return
pTq
;
}
...
...
@@ -74,7 +113,7 @@ void tqClose(STQ* pTq) {
taosHashCleanup
(
pTq
->
execs
);
taosHashCleanup
(
pTq
->
pStreamTasks
);
taosHashCleanup
(
pTq
->
pushMgr
);
tdbClose
(
pTq
->
p
Tdb
);
tdbClose
(
pTq
->
p
MetaStore
);
taosMemoryFree
(
pTq
);
}
// TODO
...
...
@@ -91,7 +130,6 @@ int32_t tEncodeSTqExec(SEncoder* pEncoder, const STqExec* pExec) {
if
(
tEncodeI8
(
pEncoder
,
pExec
->
withTag
)
<
0
)
return
-
1
;
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
if
(
tEncodeCStr
(
pEncoder
,
pExec
->
qmsg
)
<
0
)
return
-
1
;
// TODO encode modified exec
}
tEndEncode
(
pEncoder
);
return
pEncoder
->
pos
;
...
...
@@ -108,7 +146,6 @@ int32_t tDecodeSTqExec(SDecoder* pDecoder, STqExec* pExec) {
if
(
tDecodeI8
(
pDecoder
,
&
pExec
->
withTag
)
<
0
)
return
-
1
;
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pExec
->
qmsg
)
<
0
)
return
-
1
;
// TODO decode modified exec
}
tEndDecode
(
pDecoder
);
return
0
;
...
...
@@ -556,6 +593,23 @@ int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen) {
int32_t
code
=
taosHashRemove
(
pTq
->
execs
,
pReq
->
subKey
,
strlen
(
pReq
->
subKey
));
ASSERT
(
code
==
0
);
TXN
txn
;
if
(
tdbTxnOpen
(
&
txn
,
0
,
tdbDefaultMalloc
,
tdbDefaultFree
,
NULL
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
)
<
0
)
{
ASSERT
(
0
);
}
if
(
tdbBegin
(
pTq
->
pMetaStore
,
&
txn
)
<
0
)
{
ASSERT
(
0
);
}
tdbTbDelete
(
pTq
->
pExecStore
,
pReq
->
subKey
,
(
int
)
strlen
(
pReq
->
subKey
),
&
txn
);
if
(
tdbCommit
(
pTq
->
pMetaStore
,
&
txn
)
<
0
)
{
ASSERT
(
0
);
}
return
0
;
}
...
...
@@ -604,6 +658,45 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
pExec
->
pDropTbUid
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
}
taosHashPut
(
pTq
->
execs
,
req
.
subKey
,
strlen
(
req
.
subKey
),
pExec
,
sizeof
(
STqExec
));
int32_t
code
;
int32_t
vlen
;
tEncodeSize
(
tEncodeSTqExec
,
pExec
,
vlen
,
code
);
ASSERT
(
code
==
0
);
void
*
buf
=
taosMemoryCalloc
(
1
,
vlen
);
if
(
buf
==
NULL
)
{
ASSERT
(
0
);
}
SEncoder
encoder
;
tEncoderInit
(
&
encoder
,
buf
,
vlen
);
if
(
tEncodeSTqExec
(
&
encoder
,
pExec
)
<
0
)
{
ASSERT
(
0
);
}
TXN
txn
;
if
(
tdbTxnOpen
(
&
txn
,
0
,
tdbDefaultMalloc
,
tdbDefaultFree
,
NULL
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
)
<
0
)
{
ASSERT
(
0
);
}
if
(
tdbBegin
(
pTq
->
pMetaStore
,
&
txn
)
<
0
)
{
ASSERT
(
0
);
}
if
(
tdbTbUpsert
(
pTq
->
pExecStore
,
req
.
subKey
,
(
int
)
strlen
(
req
.
subKey
),
buf
,
vlen
,
&
txn
)
<
0
)
{
ASSERT
(
0
);
}
if
(
tdbCommit
(
pTq
->
pMetaStore
,
&
txn
)
<
0
)
{
ASSERT
(
0
);
}
tEncoderClear
(
&
encoder
);
taosMemoryFree
(
buf
);
return
0
;
}
else
{
/*if (req.newConsumerId != -1) {*/
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
2de2eafa
...
...
@@ -83,11 +83,11 @@ bool tqNextDataBlockFilterOut(STqReadHandle* pHandle, SHashObj* filterOutUids) {
int32_t
tqRetrieveDataBlock
(
SArray
**
ppCols
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
uint64_t
*
pUid
,
int32_t
*
pNumOfRows
,
int16_t
*
pNumOfCols
)
{
/*int32_t sversion = pHandle->pBlock->sversion;*/
// TODO set to real sversion
*
pUid
=
0
;
int32_t
sversion
=
1
;
// TODO set to real sversion
/*int32_t sversion = 1;*/
int32_t
sversion
=
htonl
(
pHandle
->
pBlock
->
sversion
);
if
(
pHandle
->
sver
!=
sversion
||
pHandle
->
cachedSchemaUid
!=
pHandle
->
msgIter
.
suid
)
{
pHandle
->
pSchema
=
metaGetTbTSchema
(
pHandle
->
pVnodeMeta
,
pHandle
->
msgIter
.
uid
,
sversion
);
if
(
pHandle
->
pSchema
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录