Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9048c77e
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
9048c77e
编写于
12月 07, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
e7ea5a0e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
95 deletion
+30
-95
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+30
-95
未找到文件。
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
9048c77e
...
...
@@ -40,6 +40,25 @@ static void metaFreeDB(SMetaDB *pDB);
static
int
metaCreateDBEnv
(
SMetaDB
*
pDB
,
const
char
*
path
);
static
void
metaDestroyDBEnv
(
SMetaDB
*
pDB
);
#define META_OPEN_DB(pDB, pEnv, fName) \
do { \
ret = db_create(&((pDB)), (pEnv), 0); \
if (ret != 0) { \
P_ERROR("Failed to create META DB", ret); \
metaCloseDB(pMeta); \
return -1; \
} \
\
ret = (pDB)->open((pDB), NULL, (fName), NULL, DB_BTREE, DB_CREATE, 0); \
if (ret != 0) { \
P_ERROR("Failed to open META DB", ret); \
metaCloseDB(pMeta); \
return -1; \
} \
} while (0)
#define META_CLOSE_DB(pDB)
int
metaOpenDB
(
SMeta
*
pMeta
)
{
int
ret
;
SMetaDB
*
pDB
;
...
...
@@ -56,85 +75,24 @@ int metaOpenDB(SMeta *pMeta) {
return
-
1
;
}
// ret = db_create(&(pDB->pStbDB), pDB->pEvn, 0);
// if (ret != 0) {
// P_ERROR("failed to create META super table DB", ret);
// metaCloseDB(pMeta);
// return -1;
// }
// ret = pDB->pStbDB->open(pDB->pStbDB, NULL, "meta.db", NULL, DB_BTREE, DB_CREATE, 0);
// if (ret != 0) {
// P_ERROR("failed to create META super table DB", ret);
// metaCloseDB(pMeta);
// return -1;
// }
#if 0
ret = db_create(&(pMeta->pDB->pDB), pMeta->pDB->pEvn, 0);
if (ret != 0) {
// TODO: handle error
return -1;
}
META_OPEN_DB
(
pDB
->
pStbDB
,
pDB
->
pEvn
,
"meta.db"
);
ret = db_create(&(pMeta->pDB->pSchemaDB), pMeta->pDB->pEvn, 0);
if (ret != 0) {
// TODO: handle error
return -1;
}
META_OPEN_DB
(
pDB
->
pNtbDB
,
pDB
->
pEvn
,
"meta.db"
);
ret = db_create(&(pMeta->pDB->pIdx), pMeta->pDB->pEvn, 0);
if (ret != 0) {
// TODO: handle error
return -1;
}
META_OPEN_DB
(
pDB
->
pSchemaDB
,
pDB
->
pEvn
,
"meta.db"
);
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;
{
// TODO: Loop to open each super table db
}
ret = pMeta->pDB->pSchemaDB->open(pMeta->pDB->pSchemaDB, /* 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;
}
META_OPEN_DB
(
pDB
->
pNameIdx
,
pDB
->
pEvn
,
"index.db"
);
ret = pMeta->pDB->pIdx->open(pMeta->pDB->pIdx, /* DB structure pointer */
NULL, /* Transaction pointer */
"index.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;
}
META_OPEN_DB
(
pDB
->
pUidIdx
,
pDB
->
pEvn
,
"index.db"
);
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;
{
// TODO: Loop to open index DB for each super table
// and create the association between main DB and index
}
#endif
return
0
;
}
...
...
@@ -148,30 +106,7 @@ void metaCloseDB(SMeta *pMeta) {
}
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
#if 0
tb_uid_t uid;
DBT key = {0};
DBT value = {0};
char buf[256];
void * pBuf;
int bsize;
if (pTbCfg->type == META_SUPER_TABLE) {
uid = pTbCfg->stbCfg.suid;
} else {
uid = metaGenerateUid(pMeta);
}
key.size = sizeof(uid);
key.data = &uid;
pBuf = buf;
value.size = metaEncodeTbCfg(&pBuf, pTbCfg);
value.data = buf;
pMeta->pDB->pDB->put(pMeta->pDB->pDB, NULL, &key, &value, 0);
#endif
// TODO
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录