Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fc267502
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
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看板
提交
fc267502
编写于
12月 08, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
b59a3756
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
31 deletion
+60
-31
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+60
-31
未找到文件。
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
fc267502
...
@@ -42,6 +42,7 @@ static void metaCloseBDBEnv(DB_ENV *pEnv);
...
@@ -42,6 +42,7 @@ static void metaCloseBDBEnv(DB_ENV *pEnv);
static
int
metaOpenBDBDb
(
DB
**
ppDB
,
DB_ENV
*
pEnv
,
const
char
*
pFName
);
static
int
metaOpenBDBDb
(
DB
**
ppDB
,
DB_ENV
*
pEnv
,
const
char
*
pFName
);
static
void
metaCloseBDBDb
(
DB
*
pDB
);
static
void
metaCloseBDBDb
(
DB
*
pDB
);
static
int
metaOpenBDBIdx
(
DB
**
ppIdx
,
DB_ENV
*
pEnv
,
const
char
*
pFName
,
DB
*
pDB
,
bdbIdxCbPtr
cbf
);
static
int
metaOpenBDBIdx
(
DB
**
ppIdx
,
DB_ENV
*
pEnv
,
const
char
*
pFName
,
DB
*
pDB
,
bdbIdxCbPtr
cbf
);
static
void
metaCloseBDBIdx
(
DB
*
pIdx
);
static
int
metaNameIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaNameIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaStbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaStbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaNtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaNtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
...
@@ -103,6 +104,12 @@ int metaOpenDB(SMeta *pMeta) {
...
@@ -103,6 +104,12 @@ int metaOpenDB(SMeta *pMeta) {
void
metaCloseDB
(
SMeta
*
pMeta
)
{
void
metaCloseDB
(
SMeta
*
pMeta
)
{
if
(
pMeta
->
pDB
)
{
if
(
pMeta
->
pDB
)
{
metaCloseBDBIdx
(
pMeta
->
pDB
->
pCtbIdx
);
metaCloseBDBIdx
(
pMeta
->
pDB
->
pNtbIdx
);
metaCloseBDBIdx
(
pMeta
->
pDB
->
pStbIdx
);
metaCloseBDBIdx
(
pMeta
->
pDB
->
pNameIdx
);
metaCloseBDBDb
(
pMeta
->
pDB
->
pSchemaDB
);
metaCloseBDBDb
(
pMeta
->
pDB
->
pTbDB
);
metaCloseBDBEnv
(
pMeta
->
pDB
->
pEvn
);
metaCloseBDBEnv
(
pMeta
->
pDB
->
pEvn
);
metaFreeDB
(
pMeta
->
pDB
);
metaFreeDB
(
pMeta
->
pDB
);
pMeta
->
pDB
=
NULL
;
pMeta
->
pDB
=
NULL
;
...
@@ -110,7 +117,58 @@ void metaCloseDB(SMeta *pMeta) {
...
@@ -110,7 +117,58 @@ void metaCloseDB(SMeta *pMeta) {
}
}
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
// TODO
tb_uid_t
uid
;
STSchema
*
pSchema
=
NULL
;
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
uid
=
pTbCfg
->
stbCfg
.
suid
;
}
else
{
uid
=
metaGenerateUid
(
pMeta
);
}
{
// save table info
char
buf
[
512
];
void
*
pBuf
=
buf
;
DBT
key
=
{
0
};
DBT
value
=
{
0
};
key
.
data
=
&
uid
;
key
.
size
=
sizeof
(
uid
);
// metaEncodeTbInfo(&pBuf, pTbCfg);
value
.
data
=
buf
;
value
.
size
=
POINTER_DISTANCE
(
pBuf
,
buf
);
pMeta
->
pDB
->
pTbDB
->
put
(
pMeta
->
pDB
->
pTbDB
,
NULL
,
&
key
,
&
value
,
0
);
}
// save schema
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
pSchema
=
pTbCfg
->
stbCfg
.
pSchema
;
}
else
if
(
pTbCfg
->
type
==
META_NORMAL_TABLE
)
{
pSchema
=
pTbCfg
->
ntbCfg
.
pSchema
;
}
if
(
pSchema
)
{
char
buf
[
512
];
void
*
pBuf
=
buf
;
DBT
key
=
{
0
};
DBT
value
=
{
0
};
// TODO
key
.
data
=
NULL
;
key
.
size
=
0
;
tdEncodeSchema
(
&
pBuf
,
pSchema
);
value
.
data
=
buf
;
value
.
size
=
POINTER_DISTANCE
(
pBuf
,
buf
);
pMeta
->
pDB
->
pSchemaDB
->
put
(
pMeta
->
pDB
->
pSchemaDB
,
NULL
,
&
key
,
&
value
,
0
);
}
return
0
;
return
0
;
}
}
...
@@ -169,7 +227,7 @@ static int metaOpenBDBDb(DB **ppDB, DB_ENV *pEnv, const char *pFName) {
...
@@ -169,7 +227,7 @@ static int metaOpenBDBDb(DB **ppDB, DB_ENV *pEnv, const char *pFName) {
int
ret
;
int
ret
;
DB
*
pDB
;
DB
*
pDB
;
ret
=
db_create
(
&
(
(
pDB
)),
(
pEnv
)
,
0
);
ret
=
db_create
(
&
(
pDB
),
pEnv
,
0
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
BDB_PERR
(
"Failed to create META DB"
,
ret
);
BDB_PERR
(
"Failed to create META DB"
,
ret
);
return
-
1
;
return
-
1
;
...
@@ -236,35 +294,6 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
...
@@ -236,35 +294,6 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
}
}
#if 0
#if 0
typedef struct {
tb_uid_t uid;
int32_t sver;
} SSchemaKey;
static SMetaDB *metaNewDB();
static void metaFreeDB(SMetaDB *pDB);
static int metaCreateDBEnv(SMetaDB *pDB, const char *path);
static void metaDestroyDBEnv(SMetaDB *pDB);
static int metaEncodeSchemaKey(void **buf, SSchemaKey *pSchemaKey);
static void * metaDecodeSchemaKey(void *buf, SSchemaKey *pSchemaKey);
static int metaNameIdxCb(DB *sdbp, const DBT *pKey, const DBT *pValue, DBT *pSKey);
static int metaUidIdxCb(DB *sdbp, const DBT *pKey, const DBT *pValue, DBT *pSKey);
static void metaPutSchema(SMeta *pMeta, tb_uid_t uid, STSchema *pSchema);
static int metaEncodeTbInfo(void **buf, STbCfg *pTbCfg);
static void * metaDecodeTbInfo(void *buf, STbCfg *pTbCfg);
static int metaSaveTbInfo(DB *pDB, tb_uid_t uid, STbCfg *pTbCfg);
#define META_ASSOCIATE_IDX(pDB, pIdx, cbf) \
do { \
int ret = (pDB)->associate((pDB), NULL, (pIdx), (cbf), 0); \
if (ret != 0) { \
P_ERROR("Failed to associate META DB", ret); \
metaCloseDB(pMeta); \
} \
} while (0)
int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
char buf[512];
char buf[512];
void * pBuf;
void * pBuf;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录