Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
018661e1
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
Star
22018
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看板
提交
018661e1
编写于
11月 29, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
757dea61
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
142 addition
and
15 deletion
+142
-15
include/dnode/vnode/vnode.h
include/dnode/vnode/vnode.h
+6
-2
source/dnode/vnode/impl/inc/vnodeDef.h
source/dnode/vnode/impl/inc/vnodeDef.h
+1
-0
source/dnode/vnode/impl/inc/vnodeRequest.h
source/dnode/vnode/impl/inc/vnodeRequest.h
+2
-5
source/dnode/vnode/impl/src/vnodeRequest.c
source/dnode/vnode/impl/src/vnodeRequest.c
+66
-1
source/dnode/vnode/impl/src/vnodeWrite.c
source/dnode/vnode/impl/src/vnodeWrite.c
+2
-4
source/dnode/vnode/impl/test/vnodeApiTests.cpp
source/dnode/vnode/impl/test/vnodeApiTests.cpp
+60
-3
source/dnode/vnode/meta/src/metaIdx.c
source/dnode/vnode/meta/src/metaIdx.c
+5
-0
未找到文件。
include/dnode/vnode/vnode.h
浏览文件 @
018661e1
...
@@ -65,14 +65,14 @@ typedef struct SVnodeCfg {
...
@@ -65,14 +65,14 @@ typedef struct SVnodeCfg {
/* ------------------------ SVnode ------------------------ */
/* ------------------------ SVnode ------------------------ */
/**
/**
* @brief Initialize the vnode module
* @brief Initialize the vnode module
*
*
* @return int 0 for success and -1 for failure
* @return int 0 for success and -1 for failure
*/
*/
int
vnodeInit
();
int
vnodeInit
();
/**
/**
* @brief clear a vnode
* @brief clear a vnode
*
*
*/
*/
void
vnodeClear
();
void
vnodeClear
();
...
@@ -156,6 +156,10 @@ typedef struct {
...
@@ -156,6 +156,10 @@ typedef struct {
/// Create table request
/// Create table request
typedef
STbCfg
SVCreateTableReq
;
typedef
STbCfg
SVCreateTableReq
;
int
vnodeBuildCreateTableReq
(
void
**
buf
,
const
SVCreateTableReq
*
pReq
);
void
*
vnodeParseCreateTableReq
(
void
*
buf
,
SVCreateTableReq
*
pReq
);
/// Drop table request
/// Drop table request
typedef
struct
{
typedef
struct
{
tb_uid_t
uid
;
tb_uid_t
uid
;
...
...
source/dnode/vnode/impl/inc/vnodeDef.h
浏览文件 @
018661e1
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "sync.h"
#include "sync.h"
#include "tlockfree.h"
#include "tlockfree.h"
#include "wal.h"
#include "wal.h"
#include "tcoding.h"
#include "vnode.h"
#include "vnode.h"
#include "vnodeBufferPool.h"
#include "vnodeBufferPool.h"
...
...
source/dnode/vnode/impl/inc/vnodeRequest.h
浏览文件 @
018661e1
...
@@ -22,12 +22,9 @@
...
@@ -22,12 +22,9 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
// SVCreateTableReq
int
vnodeBuildCreateTableReq
(
const
SVCreateTableReq
*
pReq
,
char
*
msg
,
int
len
);
int
vnodeParseCreateTableReq
(
const
char
*
msg
,
int
len
,
SVCreateTableReq
*
pReq
);
// SVDropTableReq
// SVDropTableReq
int
vnodeBuildDropTableReq
(
const
SVDropTableReq
*
pReq
,
char
*
msg
,
int
len
);
int
vnodeBuildDropTableReq
(
void
**
buf
,
const
SVDropTableReq
*
pReq
);
int
vnodeParseDropTableReq
(
const
char
*
msg
,
int
len
,
SVDropTableReq
*
pReq
);
void
*
vnodeParseDropTableReq
(
void
*
buf
,
SVDropTableReq
*
pReq
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/vnode/impl/src/vnodeRequest.c
浏览文件 @
018661e1
...
@@ -11,4 +11,69 @@
...
@@ -11,4 +11,69 @@
*
*
* You should have received a copy of the GNU Affero General Public License
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
\ No newline at end of file
#include "vnodeDef.h"
int
vnodeBuildCreateTableReq
(
void
**
buf
,
const
SVCreateTableReq
*
pReq
)
{
int
tsize
=
0
;
tsize
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tsize
+=
taosEncodeFixedU32
(
buf
,
pReq
->
ttl
);
tsize
+=
taosEncodeFixedU32
(
buf
,
pReq
->
keep
);
tsize
+=
taosEncodeFixedU8
(
buf
,
pReq
->
type
);
switch
(
pReq
->
type
)
{
case
META_SUPER_TABLE
:
tsize
+=
taosEncodeFixedU64
(
buf
,
pReq
->
stbCfg
.
suid
);
tsize
+=
tdEncodeSchema
(
buf
,
pReq
->
stbCfg
.
pSchema
);
tsize
+=
tdEncodeSchema
(
buf
,
pReq
->
stbCfg
.
pTagSchema
);
break
;
case
META_CHILD_TABLE
:
tsize
+=
taosEncodeFixedU64
(
buf
,
pReq
->
ctbCfg
.
suid
);
tsize
+=
tdEncodeKVRow
(
buf
,
pReq
->
ctbCfg
.
pTag
);
break
;
case
META_NORMAL_TABLE
:
tsize
+=
tdEncodeSchema
(
buf
,
pReq
->
ntbCfg
.
pSchema
);
break
;
default:
break
;
}
return
tsize
;
}
void
*
vnodeParseCreateTableReq
(
void
*
buf
,
SVCreateTableReq
*
pReq
)
{
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
name
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
ttl
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
keep
));
buf
=
taosDecodeFixedU8
(
buf
,
&
(
pReq
->
type
));
switch
(
pReq
->
type
)
{
case
META_SUPER_TABLE
:
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pReq
->
stbCfg
.
suid
));
buf
=
tdDecodeSchema
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
));
buf
=
tdDecodeSchema
(
buf
,
&
(
pReq
->
stbCfg
.
pTagSchema
));
break
;
case
META_CHILD_TABLE
:
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pReq
->
ctbCfg
.
suid
));
buf
=
tdDecodeKVRow
(
buf
,
pReq
->
ctbCfg
.
pTag
);
break
;
case
META_NORMAL_TABLE
:
buf
=
tdDecodeSchema
(
buf
,
&
(
pReq
->
ntbCfg
.
pSchema
));
break
;
default:
break
;
}
return
buf
;
}
int
vnodeBuildDropTableReq
(
void
**
buf
,
const
SVDropTableReq
*
pReq
)
{
// TODO
return
0
;
}
void
*
vnodeParseDropTableReq
(
void
*
buf
,
SVDropTableReq
*
pReq
)
{
// TODO
}
\ No newline at end of file
source/dnode/vnode/impl/src/vnodeWrite.c
浏览文件 @
018661e1
...
@@ -56,9 +56,7 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
...
@@ -56,9 +56,7 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
switch
(
pMsg
->
msgType
)
{
switch
(
pMsg
->
msgType
)
{
case
TSDB_MSG_TYPE_CREATE_TABLE
:
case
TSDB_MSG_TYPE_CREATE_TABLE
:
if
(
vnodeParseCreateTableReq
(
pVnodeReq
->
req
,
pMsg
->
contLen
-
sizeof
(
pVnodeReq
->
ver
),
&
(
ctReq
))
<
0
)
{
vnodeParseCreateTableReq
(
pVnodeReq
->
req
,
&
(
ctReq
));
// TODO: handle error
}
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
ctReq
)
<
0
)
{
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
ctReq
)
<
0
)
{
// TODO: handle error
// TODO: handle error
...
@@ -67,7 +65,7 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
...
@@ -67,7 +65,7 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
// TODO: maybe need to clear the requst struct
// TODO: maybe need to clear the requst struct
break
;
break
;
case
TSDB_MSG_TYPE_DROP_TABLE
:
case
TSDB_MSG_TYPE_DROP_TABLE
:
if
(
vnodeParseDropTableReq
(
pVnodeReq
->
req
,
pMsg
->
contLen
-
sizeof
(
pVnodeReq
->
ver
),
&
(
dtReq
))
<
0
)
{
if
(
vnodeParseDropTableReq
(
pVnodeReq
->
req
,
&
(
dtReq
))
<
0
)
{
// TODO: handle error
// TODO: handle error
}
}
...
...
source/dnode/vnode/impl/test/vnodeApiTests.cpp
浏览文件 @
018661e1
...
@@ -10,9 +10,66 @@ TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
...
@@ -10,9 +10,66 @@ TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
SVnode
*
pVnode
=
vnodeOpen
(
"vnode1"
,
NULL
);
SVnode
*
pVnode
=
vnodeOpen
(
"vnode1"
,
NULL
);
ASSERT_NE
(
pVnode
,
nullptr
);
ASSERT_NE
(
pVnode
,
nullptr
);
// Create table
tb_uid_t
suid
=
1638166374163
;
// SArray *pArray = taosArrayInit()
{
// vnodeProcessWMsgs(pVnode, );
// Create a super table
STSchema
*
pSchema
=
NULL
;
STSchema
*
pTagSchema
=
NULL
;
char
tbname
[
128
]
=
"st"
;
SArray
*
pMsgs
=
(
SArray
*
)
taosArrayInit
(
1
,
sizeof
(
SRpcMsg
*
));
STbCfg
stbCfg
=
META_INIT_STB_CFG
(
tbname
,
UINT32_MAX
,
UINT32_MAX
,
suid
,
pSchema
,
pTagSchema
);
int
zs
=
vnodeBuildCreateTableReq
(
NULL
,
&
stbCfg
);
SRpcMsg
*
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
)
+
zs
);
pMsg
->
contLen
=
zs
;
pMsg
->
pCont
=
POINTER_SHIFT
(
pMsg
,
sizeof
(
SRpcMsg
));
void
**
pBuf
=
&
(
pMsg
->
pCont
);
vnodeBuildCreateTableReq
(
pBuf
,
&
stbCfg
);
META_CLEAR_TB_CFG
(
&
stbCfg
);
taosArrayPush
(
pMsgs
,
&
(
pMsg
));
vnodeProcessWMsgs
(
pVnode
,
pMsgs
);
free
(
pMsg
);
taosArrayClear
(
pMsgs
);
}
{
// Create some child tables
int
ntables
=
1000000
;
int
batch
=
10
;
for
(
int
i
=
0
;
i
<
ntables
/
batch
;
i
++
)
{
SArray
*
pMsgs
=
(
SArray
*
)
taosArrayInit
(
batch
,
sizeof
(
SRpcMsg
*
));
for
(
int
j
=
0
;
j
<
batch
;
j
++
)
{
SRow
*
pTag
=
NULL
;
char
tbname
[
128
];
sprintf
(
tbname
,
"tb%d"
,
i
*
batch
+
j
);
STbCfg
ctbCfg
=
META_INIT_CTB_CFG
(
tbname
,
UINT32_MAX
,
UINT32_MAX
,
suid
,
pTag
);
int
tz
=
vnodeBuildCreateTableReq
(
NULL
,
&
ctbCfg
);
SRpcMsg
*
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
)
+
tz
);
pMsg
->
contLen
=
tz
;
pMsg
->
pCont
=
POINTER_SHIFT
(
pMsg
,
sizeof
(
*
pMsg
));
void
**
pBuf
=
&
(
pMsg
->
pCont
);
vnodeBuildCreateTableReq
(
pBuf
,
&
ctbCfg
);
META_CLEAR_TB_CFG
(
&
ctbCfg
);
}
vnodeProcessWMsgs
(
pVnode
,
pMsgs
);
for
(
int
j
=
0
;
j
<
batch
;
j
++
)
{
SRpcMsg
*
pMsg
=
*
(
SRpcMsg
**
)
taosArrayPop
(
pMsgs
);
free
(
pMsg
);
}
taosArrayClear
(
pMsgs
);
}
}
// Close the vnode
// Close the vnode
vnodeClose
(
pVnode
);
vnodeClose
(
pVnode
);
...
...
source/dnode/vnode/meta/src/metaIdx.c
浏览文件 @
018661e1
...
@@ -50,4 +50,9 @@ void metaCloseIdx(SMeta *pMeta) { /* TODO */
...
@@ -50,4 +50,9 @@ void metaCloseIdx(SMeta *pMeta) { /* TODO */
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
)
{
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
)
{
// TODO
// TODO
return
0
;
return
0
;
}
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
// TODO
return
0
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录