Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
588ff5e9
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看板
提交
588ff5e9
编写于
4月 21, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more refact
上级
b4169cdf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
22 deletion
+30
-22
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+0
-5
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+28
-11
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+2
-6
未找到文件。
source/dnode/vnode/src/inc/meta.h
浏览文件 @
588ff5e9
...
...
@@ -73,11 +73,6 @@ struct SMeta {
SMetaIdx
*
pIdx
;
};
typedef
struct
{
tb_uid_t
uid
;
int64_t
ver
;
}
STbDbKey
;
typedef
struct
__attribute__
((
__packed__
))
{
tb_uid_t
uid
;
int32_t
sver
;
...
...
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
588ff5e9
...
...
@@ -20,6 +20,7 @@ static int skmDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLe
static
int
ctbIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
tagIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
ttlIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
uidIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
)
{
SMeta
*
pMeta
=
NULL
;
...
...
@@ -51,7 +52,7 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
}
// open pTbDb
ret
=
tdbDbOpen
(
"table.db"
,
sizeof
(
STbDbKey
),
-
1
,
tbDbKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTbDb
);
ret
=
tdbDbOpen
(
"table.db"
,
sizeof
(
int64_t
),
-
1
,
tbDbKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTbDb
);
if
(
ret
<
0
)
{
metaError
(
"vgId: %d failed to open meta table db since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
...
...
@@ -64,6 +65,13 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
goto
_err
;
}
// open pUidIdx
ret
=
tdbDbOpen
(
"uid.db"
,
sizeof
(
tb_uid_t
),
sizeof
(
int64_t
),
uidIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pUidIdx
);
if
(
ret
<
0
)
{
metaError
(
"vgId: %d failed to open meta uid idx since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pNameIdx
ret
=
tdbDbOpen
(
"name.idx"
,
-
1
,
sizeof
(
tb_uid_t
),
NULL
,
pMeta
->
pEnv
,
&
pMeta
->
pNameIdx
);
if
(
ret
<
0
)
{
...
...
@@ -109,6 +117,7 @@ _err:
if
(
pMeta
->
pTagIdx
)
tdbDbClose
(
pMeta
->
pTagIdx
);
if
(
pMeta
->
pCtbIdx
)
tdbDbClose
(
pMeta
->
pCtbIdx
);
if
(
pMeta
->
pNameIdx
)
tdbDbClose
(
pMeta
->
pNameIdx
);
if
(
pMeta
->
pNameIdx
)
tdbDbClose
(
pMeta
->
pUidIdx
);
if
(
pMeta
->
pSkmDb
)
tdbDbClose
(
pMeta
->
pSkmDb
);
if
(
pMeta
->
pTbDb
)
tdbDbClose
(
pMeta
->
pTbDb
);
if
(
pMeta
->
pEnv
)
tdbEnvClose
(
pMeta
->
pEnv
);
...
...
@@ -123,6 +132,7 @@ int metaClose(SMeta *pMeta) {
if
(
pMeta
->
pTagIdx
)
tdbDbClose
(
pMeta
->
pTagIdx
);
if
(
pMeta
->
pCtbIdx
)
tdbDbClose
(
pMeta
->
pCtbIdx
);
if
(
pMeta
->
pNameIdx
)
tdbDbClose
(
pMeta
->
pNameIdx
);
if
(
pMeta
->
pNameIdx
)
tdbDbClose
(
pMeta
->
pUidIdx
);
if
(
pMeta
->
pSkmDb
)
tdbDbClose
(
pMeta
->
pSkmDb
);
if
(
pMeta
->
pTbDb
)
tdbDbClose
(
pMeta
->
pTbDb
);
if
(
pMeta
->
pEnv
)
tdbEnvClose
(
pMeta
->
pEnv
);
...
...
@@ -133,18 +143,12 @@ int metaClose(SMeta *pMeta) {
}
static
int
tbDbKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
STbDbKey
*
pTbDbKey1
=
(
STbDbKey
*
)
pKey1
;
STbDbKey
*
pTbDbKey2
=
(
STbDbKey
*
)
pKey2
;
if
(
pTbDbKey1
->
uid
>
pTbDbKey2
->
uid
)
{
return
1
;
}
else
if
(
pTbDbKey1
->
uid
<
pTbDbKey2
->
uid
)
{
return
-
1
;
}
int64_t
version1
=
*
(
int64_t
*
)
pKey1
;
int64_t
version2
=
*
(
int64_t
*
)
pKey2
;
if
(
pTbDbKey1
->
ver
>
pTbDbKey2
->
ver
)
{
if
(
version1
>
version2
)
{
return
1
;
}
else
if
(
pTbDbKey1
->
ver
<
pTbDbKey2
->
ver
)
{
}
else
if
(
version1
<
version2
)
{
return
-
1
;
}
...
...
@@ -170,6 +174,19 @@ static int skmDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLe
return
0
;
}
static
int
uidIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
tb_uid_t
uid1
=
*
(
tb_uid_t
*
)
pKey1
;
tb_uid_t
uid2
=
*
(
tb_uid_t
*
)
pKey2
;
if
(
uid1
>
uid2
)
{
return
1
;
}
else
if
(
uid1
<
uid2
)
{
return
-
1
;
}
return
0
;
}
static
int
ctbIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
SCtbIdxKey
*
pCtbIdxKey1
=
(
SCtbIdxKey
*
)
pKey1
;
SCtbIdxKey
*
pCtbIdxKey2
=
(
SCtbIdxKey
*
)
pKey2
;
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
588ff5e9
...
...
@@ -16,7 +16,6 @@
#include "vnodeInt.h"
int
metaCreateSTable
(
SMeta
*
pMeta
,
SVCreateStbReq
*
pReq
,
SVCreateStbRsp
*
pRsp
)
{
STbDbKey
tbDbKey
=
{
0
};
SSkmDbKey
skmDbKey
=
{
0
};
SMetaEntry
me
=
{
0
};
int
kLen
;
...
...
@@ -36,15 +35,12 @@ int metaCreateSTable(SMeta *pMeta, SVCreateStbReq *pReq, SVCreateStbRsp *pRsp) {
me
.
stbEntry
.
nTags
=
pReq
->
nTags
;
me
.
stbEntry
.
pSchemaTg
=
pReq
->
pSchemaTg
;
tbDbKey
.
uid
=
pReq
->
suid
;
tbDbKey
.
ver
=
0
;
// (TODO)
skmDbKey
.
uid
=
pReq
->
suid
;
skmDbKey
.
sver
=
0
;
// (TODO)
// save to table.db (TODO)
pKey
=
&
tbDbKey
;
kLen
=
sizeof
(
tbDbKey
)
;
pKey
=
NULL
;
kLen
=
0
;
pVal
=
NULL
;
vLen
=
0
;
if
(
tdbDbInsert
(
pMeta
->
pTbDb
,
pKey
,
kLen
,
pVal
,
vLen
,
NULL
)
<
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录