Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fcedc343
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
fcedc343
编写于
4月 21, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact META 7
上级
588ff5e9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
93 addition
and
34 deletion
+93
-34
include/common/tmsg.h
include/common/tmsg.h
+4
-0
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+2
-1
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+83
-29
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+4
-4
未找到文件。
include/common/tmsg.h
浏览文件 @
fcedc343
...
...
@@ -1506,6 +1506,10 @@ typedef struct SVCreateStbReq {
int
tEncodeSVCreateStbReq
(
SCoder
*
pCoder
,
const
SVCreateStbReq
*
pReq
);
int
tDecodeSVCreateStbReq
(
SCoder
*
pCoder
,
SVCreateStbReq
*
pReq
);
typedef
struct
SVDropStbReq
{
// data
}
SVDropStbReq
;
typedef
struct
SVCreateStbRsp
{
int
code
;
}
SVCreateStbRsp
;
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
fcedc343
...
...
@@ -52,7 +52,8 @@ int metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions);
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
// metaTable ==================
int
metaCreateSTable
(
SMeta
*
pMeta
,
SVCreateStbReq
*
pReq
,
SVCreateStbRsp
*
pRsp
);
int
metaCreateSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
);
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
);
// metaCommit ==================
int
metaBegin
(
SMeta
*
pMeta
);
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
fcedc343
...
...
@@ -15,15 +15,25 @@
#include "vnodeInt.h"
int
metaCreateSTable
(
SMeta
*
pMeta
,
SVCreateStbReq
*
pReq
,
SVCreateStbRsp
*
pRsp
)
{
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
int64_t
version
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateUidIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int64_t
version
);
static
int
metaUpdateNameIdx
(
SMeta
*
pMeta
,
const
char
*
name
,
tb_uid_t
uid
);
int
metaCreateSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
SSkmDbKey
skmDbKey
=
{
0
};
SMetaEntry
me
=
{
0
};
int
kLen
;
int
vLen
;
const
void
*
pKey
;
const
void
*
pVal
;
int
kLen
=
0
;
int
vLen
=
0
;
const
void
*
pKey
=
NULL
;
const
void
*
pVal
=
NULL
;
void
*
pBuf
=
NULL
;
int32_t
szBuf
=
0
;
void
*
p
=
NULL
;
SCoder
coder
=
{
0
};
// check name and uid unique
{
// TODO: validate request (uid and name unique)
}
// set structs
me
.
type
=
TSDB_SUPER_TABLE
;
...
...
@@ -38,33 +48,27 @@ int metaCreateSTable(SMeta *pMeta, SVCreateStbReq *pReq, SVCreateStbRsp *pRsp) {
skmDbKey
.
uid
=
pReq
->
suid
;
skmDbKey
.
sver
=
0
;
// (TODO)
// save to table.db (TODO)
pKey
=
NULL
;
kLen
=
0
;
pVal
=
NULL
;
vLen
=
0
;
if
(
tdbDbInsert
(
pMeta
->
pTbDb
,
pKey
,
kLen
,
pVal
,
vLen
,
NULL
)
<
0
)
{
return
-
1
;
}
// save to table.db
if
(
metaSaveToTbDb
(
pMeta
,
version
,
&
me
)
<
0
)
goto
_err
;
// save to schema.db
pKey
=
&
skmDbKey
;
kLen
=
sizeof
(
skmDbKey
);
pVal
=
NULL
;
vLen
=
0
;
if
(
tdbDbInsert
(
pMeta
->
pSkmDb
,
pKey
,
kLen
,
pVal
,
vLen
,
NULL
)
<
0
)
{
return
-
1
;
}
// update uid idx
if
(
metaUpdateUidIdx
(
pMeta
,
me
.
uid
,
version
)
<
0
)
goto
_err
;
// update name.idx
pKey
=
pReq
->
name
;
kLen
=
strlen
(
pReq
->
name
)
+
1
;
pVal
=
&
pReq
->
suid
;
vLen
=
sizeof
(
tb_uid_t
);
if
(
tdbDbInsert
(
pMeta
->
pNameIdx
,
pKey
,
kLen
,
pVal
,
vLen
,
NULL
)
<
0
)
{
return
-
1
;
}
if
(
metaUpdateNameIdx
(
pMeta
,
me
.
name
,
me
.
uid
)
<
0
)
goto
_err
;
metaDebug
(
"vgId: %d super table is created, name:%s uid: %"
PRId64
,
TD_VID
(
pMeta
->
pVnode
),
pReq
->
name
,
pReq
->
suid
);
return
0
;
_err:
metaError
(
"vgId: %d failed to create super table: %s uid: %"
PRId64
" since %s"
,
TD_VID
(
pMeta
->
pVnode
),
pReq
->
name
,
pReq
->
suid
,
tstrerror
(
terrno
));
return
-
1
;
}
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
)
{
// TODO
return
0
;
}
...
...
@@ -99,3 +103,53 @@ int metaDropTable(SMeta *pMeta, tb_uid_t uid) {
return
0
;
}
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
int64_t
version
,
const
SMetaEntry
*
pME
)
{
void
*
pKey
=
NULL
;
void
*
pVal
=
NULL
;
int
kLen
=
0
;
int
vLen
=
0
;
SCoder
coder
=
{
0
};
// set key and value
pKey
=
&
version
;
kLen
=
sizeof
(
version
);
if
(
tEncodeSize
(
metaEncodeEntry
,
pME
,
vLen
)
<
0
)
{
goto
_err
;
}
pVal
=
taosMemoryMalloc
(
vLen
);
if
(
pVal
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
tCoderInit
(
&
coder
,
TD_LITTLE_ENDIAN
,
pVal
,
vLen
,
TD_ENCODER
);
if
(
metaEncodeEntry
(
&
coder
,
pME
)
<
0
)
{
goto
_err
;
}
tCoderClear
(
&
coder
);
// write to table.db
if
(
tdbDbInsert
(
pMeta
->
pTbDb
,
pKey
,
kLen
,
pVal
,
vLen
,
NULL
)
<
0
)
{
goto
_err
;
}
taosMemoryFree
(
pVal
);
return
0
;
_err:
taosMemoryFree
(
pVal
);
return
-
1
;
}
static
int
metaUpdateUidIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int64_t
version
)
{
return
tdbDbInsert
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
version
,
sizeof
(
version
),
NULL
);
}
static
int
metaUpdateNameIdx
(
SMeta
*
pMeta
,
const
char
*
name
,
tb_uid_t
uid
)
{
return
tdbDbInsert
(
pMeta
->
pNameIdx
,
name
,
strlen
(
name
)
+
1
,
&
uid
,
sizeof
(
uid
),
NULL
);
}
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
fcedc343
...
...
@@ -15,7 +15,7 @@
#include "vnodeInt.h"
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
,
int
len
,
SRpcMsg
*
pRsp
);
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int
len
,
SRpcMsg
*
pRsp
);
static
int
vnodeProcessAlterStbReq
(
SVnode
*
pVnode
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int
vnodeProcessDropStbReq
(
SVnode
*
pVnode
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int
vnodeProcessCreateTbReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
void
*
pReq
,
SRpcMsg
*
pRsp
);
...
...
@@ -68,7 +68,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
switch
(
pMsg
->
msgType
)
{
/* META */
case
TDMT_VND_CREATE_STB
:
if
(
vnodeProcessCreateStbReq
(
pVnode
,
pReq
,
len
,
pRsp
)
<
0
)
goto
_err
;
if
(
vnodeProcessCreateStbReq
(
pVnode
,
version
,
pReq
,
len
,
pRsp
)
<
0
)
goto
_err
;
break
;
case
TDMT_VND_ALTER_STB
:
if
(
vnodeProcessAlterStbReq
(
pVnode
,
pReq
,
len
,
pRsp
)
<
0
)
goto
_err
;
...
...
@@ -214,7 +214,7 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
return
0
;
}
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
,
int
len
,
SRpcMsg
*
pRsp
)
{
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int
len
,
SRpcMsg
*
pRsp
)
{
SVCreateStbReq
req
=
{
0
};
SCoder
coder
;
...
...
@@ -231,7 +231,7 @@ static int vnodeProcessCreateStbReq(SVnode *pVnode, void *pReq, int len, SRpcMsg
goto
_err
;
}
if
(
metaCreateSTable
(
pVnode
->
pMeta
,
pReq
,
NULL
)
<
0
)
{
if
(
metaCreateSTable
(
pVnode
->
pMeta
,
version
,
pReq
)
<
0
)
{
pRsp
->
code
=
terrno
;
goto
_err
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录