Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
40d12ec4
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
40d12ec4
编写于
12月 07, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
30922ff2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
99 addition
and
60 deletion
+99
-60
source/dnode/vnode/meta/inc/metaDB.h
source/dnode/vnode/meta/inc/metaDB.h
+1
-1
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+98
-59
未找到文件。
source/dnode/vnode/meta/inc/metaDB.h
浏览文件 @
40d12ec4
...
...
@@ -26,7 +26,7 @@ typedef struct SMetaDB SMetaDB;
int
metaOpenDB
(
SMeta
*
pMeta
);
void
metaCloseDB
(
SMeta
*
pMeta
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbCfg
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
#ifdef __cplusplus
...
...
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
40d12ec4
...
...
@@ -13,27 +13,36 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "db.h"
#include "metaDef.h"
#include "
db
.h"
#include "
thash
.h"
struct
SMetaDB
{
DB
*
pStbDB
;
DB
*
pCtbDB
;
DB
*
pNtbDB
;
DB
*
pIdx
;
// DB
DB
*
pStbDB
;
DB
*
pNtbDB
;
SHashObj
*
pCtbMap
;
DB
*
pSchemaDB
;
// IDX
SHashObj
*
pIdxMap
;
DB
*
pNameIdx
;
DB
*
pUidIdx
;
// ENV
DB_ENV
*
pEvn
;
};
static
SMetaDB
*
metaNewDB
();
static
void
metaFreeDB
(
SMetaDB
*
pDB
);
int
metaOpenDB
(
SMeta
*
pMeta
)
{
int
ret
;
int
ret
;
SMetaDB
*
pDB
;
pMeta
->
pDB
=
(
SMetaDB
*
)
calloc
(
1
,
sizeof
(
SMetaDB
));
if
(
pMeta
->
pDB
==
NULL
)
{
// TODO: handle error
return
-
1
;
}
pMeta
->
pDB
=
metaNewDB
();
#if 0
// create the env
ret = db_env_create(&(pMeta->pDB->pEvn), 0);
if (ret != 0) {
...
...
@@ -47,19 +56,13 @@ int metaOpenDB(SMeta *pMeta) {
return -1;
}
ret
=
db_create
(
&
(
pMeta
->
pDB
->
pStbDB
),
pMeta
->
pDB
->
pEvn
,
0
);
if
(
ret
!=
0
)
{
// TODO: handle error
return
-
1
;
}
ret
=
db_create
(
&
(
pMeta
->
pDB
->
pCtbDB
),
pMeta
->
pDB
->
pEvn
,
0
);
ret = db_create(&(pMeta->pDB->pDB), pMeta->pDB->pEvn, 0);
if (ret != 0) {
// TODO: handle error
return -1;
}
ret
=
db_create
(
&
(
pMeta
->
pDB
->
p
Ntb
DB
),
pMeta
->
pDB
->
pEvn
,
0
);
ret = db_create(&(pMeta->pDB->p
Schema
DB), pMeta->pDB->pEvn, 0);
if (ret != 0) {
// TODO: handle error
return -1;
...
...
@@ -71,37 +74,25 @@ int metaOpenDB(SMeta *pMeta) {
return -1;
}
ret
=
pMeta
->
pDB
->
pStbDB
->
open
(
pMeta
->
pDB
->
pStbDB
,
/* DB structure pointer */
NULL
,
/* Transaction pointer */
"meta.db"
,
/* On-disk file that holds the database */
NULL
,
/* Optional logical database name */
DB_BTREE
,
/* Database access method */
DB_CREATE
,
/* Open flags */
0
);
/* File mode */
if
(
ret
!=
0
)
{
// TODO: handle error
return
-
1
;
}
ret
=
pMeta
->
pDB
->
pCtbDB
->
open
(
pMeta
->
pDB
->
pCtbDB
,
/* DB structure pointer */
NULL
,
/* Transaction pointer */
"meta.db"
,
/* On-disk file that holds the database */
NULL
,
/* Optional logical database name */
DB_BTREE
,
/* Database access method */
DB_CREATE
,
/* Open flags */
0
);
/* File mode */
ret = pMeta->pDB->pDB->open(pMeta->pDB->pDB, /* DB structure pointer */
NULL, /* Transaction pointer */
"meta.db", /* On-disk file that holds the database */
NULL, /* Optional logical database name */
DB_BTREE, /* Database access method */
DB_CREATE, /* Open flags */
0); /* File mode */
if (ret != 0) {
// TODO: handle error
return -1;
}
ret
=
pMeta
->
pDB
->
p
NtbDB
->
open
(
pMeta
->
pDB
->
pNtb
DB
,
/* DB structure pointer */
NULL
,
/* Transaction pointer */
"meta.db"
,
/* On-disk file that holds the database */
NULL
,
/* Optional logical database name */
DB_BTREE
,
/* Database access method */
DB_CREATE
,
/* Open flags */
0
);
/* File mode */
ret = pMeta->pDB->p
SchemaDB->open(pMeta->pDB->pSchema
DB, /* DB structure pointer */
NULL,
/* Transaction pointer */
"meta.db",
/* On-disk file that holds the database */
NULL,
/* Optional logical database name */
DB_BTREE,
/* Database access method */
DB_CREATE,
/* Open flags */
0);
/* File mode */
if (ret != 0) {
// TODO: handle error
return -1;
...
...
@@ -119,30 +110,38 @@ int metaOpenDB(SMeta *pMeta) {
return -1;
}
// TODO
ret = pMeta->pDB->pDB->associate(pMeta->pDB->pDB, /* Primary database */
NULL, /* TXN id */
pMeta->pDB->pIdx, /* Secondary database */
metaIdxCallback, /* Callback used for key creation */
0); /* Flags */
if (ret != 0) {
// TODO: handle error
return -1;
}
#endif
return
0
;
}
void
metaCloseDB
(
SMeta
*
pMeta
)
{
metaFreeDB
(
pMeta
->
pDB
);
pMeta
->
pDB
=
NULL
;
#if 0
if (pMeta->pDB) {
if (pMeta->pDB->pIdx) {
pMeta->pDB->pIdx->close(pMeta->pDB->pIdx, 0);
pMeta->pDB->pIdx = NULL;
}
if
(
pMeta
->
pDB
->
pNtbDB
)
{
pMeta
->
pDB
->
pNtbDB
->
close
(
pMeta
->
pDB
->
pNtbDB
,
0
);
pMeta
->
pDB
->
pNtbDB
=
NULL
;
}
if
(
pMeta
->
pDB
->
pCtbDB
)
{
pMeta
->
pDB
->
pCtbDB
->
close
(
pMeta
->
pDB
->
pCtbDB
,
0
);
pMeta
->
pDB
->
pCtbDB
=
NULL
;
if (pMeta->pDB->pSchemaDB) {
pMeta->pDB->pSchemaDB->close(pMeta->pDB->pSchemaDB, 0);
pMeta->pDB->pSchemaDB = NULL;
}
if
(
pMeta
->
pDB
->
p
Stb
DB
)
{
pMeta
->
pDB
->
p
StbDB
->
close
(
pMeta
->
pDB
->
pStb
DB
,
0
);
pMeta
->
pDB
->
p
Stb
DB
=
NULL
;
if (pMeta->pDB->pDB) {
pMeta->pDB->p
DB->close(pMeta->pDB->p
DB, 0);
pMeta->pDB->pDB = NULL;
}
if (pMeta->pDB->pEvn) {
...
...
@@ -152,9 +151,11 @@ void metaCloseDB(SMeta *pMeta) {
free(pMeta->pDB);
}
#endif
}
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbCfg
)
{
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
#if 0
tb_uid_t uid;
DBT key = {0};
DBT value = {0};
...
...
@@ -175,11 +176,49 @@ int metaSaveTableToDB(SMeta *pMeta, const STbCfg *pTbCfg) {
value.size = metaEncodeTbCfg(&pBuf, pTbCfg);
value.data = buf;
pMeta
->
pDB
->
pStbDB
->
put
(
pMeta
->
pDB
->
pStbDB
,
NULL
,
&
key
,
&
value
,
0
);
pMeta->pDB->pDB->put(pMeta->pDB->pDB, NULL, &key, &value, 0);
#endif
return
0
;
}
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
// TODO
}
/* ------------------------ STATIC METHODS ------------------------ */
static
SMetaDB
*
metaNewDB
()
{
SMetaDB
*
pDB
;
pDB
=
(
SMetaDB
*
)
calloc
(
1
,
sizeof
(
*
pDB
));
if
(
pDB
==
NULL
)
{
return
NULL
;
}
pDB
->
pCtbMap
=
taosHashInit
(
0
,
MurmurHash3_32
,
false
,
HASH_NO_LOCK
);
if
(
pDB
->
pCtbMap
==
NULL
)
{
metaFreeDB
(
pDB
);
return
NULL
;
}
pDB
->
pIdxMap
=
taosHashInit
(
0
,
MurmurHash3_32
,
false
,
HASH_NO_LOCK
);
if
(
pDB
->
pIdxMap
==
NULL
)
{
metaFreeDB
(
pDB
);
return
NULL
;
}
return
pDB
;
}
static
void
metaFreeDB
(
SMetaDB
*
pDB
)
{
if
(
pDB
==
NULL
)
{
if
(
pDB
->
pIdxMap
)
{
taosHashCleanup
(
pDB
->
pIdxMap
);
}
if
(
pDB
->
pCtbMap
)
{
taosHashCleanup
(
pDB
->
pCtbMap
);
}
free
(
pDB
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录