Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
21237655
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
21237655
编写于
12月 30, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
24c6abcb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
1 deletion
+51
-1
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+51
-1
未找到文件。
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
21237655
...
@@ -38,6 +38,11 @@ struct SMetaDB {
...
@@ -38,6 +38,11 @@ struct SMetaDB {
DB_ENV
*
pEvn
;
DB_ENV
*
pEvn
;
};
};
typedef
struct
{
int32_t
nCols
;
SSchema
*
pSchema
;
}
SSchemaWrapper
;
typedef
int
(
*
bdbIdxCbPtr
)(
DB
*
,
const
DBT
*
,
const
DBT
*
,
DBT
*
);
typedef
int
(
*
bdbIdxCbPtr
)(
DB
*
,
const
DBT
*
,
const
DBT
*
,
DBT
*
);
static
SMetaDB
*
metaNewDB
();
static
SMetaDB
*
metaNewDB
();
...
@@ -55,6 +60,7 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *
...
@@ -55,6 +60,7 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *
static
int
metaEncodeTbInfo
(
void
**
buf
,
STbCfg
*
pTbCfg
);
static
int
metaEncodeTbInfo
(
void
**
buf
,
STbCfg
*
pTbCfg
);
static
void
*
metaDecodeTbInfo
(
void
*
buf
,
STbCfg
*
pTbCfg
);
static
void
*
metaDecodeTbInfo
(
void
*
buf
,
STbCfg
*
pTbCfg
);
static
void
metaClearTbCfg
(
STbCfg
*
pTbCfg
);
static
void
metaClearTbCfg
(
STbCfg
*
pTbCfg
);
static
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
#define BDB_PERR(info, code) fprintf(stderr, info " reason: %s", db_strerror(code))
#define BDB_PERR(info, code) fprintf(stderr, info " reason: %s", db_strerror(code))
...
@@ -432,6 +438,7 @@ static void metaClearTbCfg(STbCfg *pTbCfg) {
...
@@ -432,6 +438,7 @@ static void metaClearTbCfg(STbCfg *pTbCfg) {
/* ------------------------ FOR QUERY ------------------------ */
/* ------------------------ FOR QUERY ------------------------ */
int
metaGetTableInfo
(
SMeta
*
pMeta
,
char
*
tbname
,
STableMetaMsg
**
ppMsg
)
{
int
metaGetTableInfo
(
SMeta
*
pMeta
,
char
*
tbname
,
STableMetaMsg
**
ppMsg
)
{
#if 0
DBT key = {0};
DBT key = {0};
DBT value = {0};
DBT value = {0};
SMetaDB * pMetaDB = pMeta->pDB;
SMetaDB * pMetaDB = pMeta->pDB;
...
@@ -490,7 +497,7 @@ int metaGetTableInfo(SMeta *pMeta, char *tbname, STableMetaMsg **ppMsg) {
...
@@ -490,7 +497,7 @@ int metaGetTableInfo(SMeta *pMeta, char *tbname, STableMetaMsg **ppMsg) {
pMsg->tuid = tbCfg.stbCfg.suid;
pMsg->tuid = tbCfg.stbCfg.suid;
memcpy(pMsg->pSchema, tbCfg.stbCfg.pSchema, sizeof(SSchema) * tbCfg.stbCfg.nCols);
memcpy(pMsg->pSchema, tbCfg.stbCfg.pSchema, sizeof(SSchema) * tbCfg.stbCfg.nCols);
memcpy(POINTER_SHIFT(pMsg->pSchema, sizeof(SSchema) * tbCfg.stbCfg.nCols), tbCfg.stbCfg.pTagSchema,
memcpy(POINTER_SHIFT(pMsg->pSchema, sizeof(SSchema) * tbCfg.stbCfg.nCols), tbCfg.stbCfg.pTagSchema,
sizeof
(
SSchema
)
*
tbCfg
.
stbCfg
.
nTagCols
);
sizeof(SSchema) * tbCfg.stbCfg.nTagCols);
break;
break;
case META_CHILD_TABLE:
case META_CHILD_TABLE:
ASSERT(0);
ASSERT(0);
...
@@ -505,5 +512,48 @@ int metaGetTableInfo(SMeta *pMeta, char *tbname, STableMetaMsg **ppMsg) {
...
@@ -505,5 +512,48 @@ int metaGetTableInfo(SMeta *pMeta, char *tbname, STableMetaMsg **ppMsg) {
*ppMsg = pMsg;
*ppMsg = pMsg;
#endif
return
0
;
return
0
;
}
static
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
)
{
uint32_t
nCols
;
SSchemaWrapper
*
pSW
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
int
ret
;
void
*
pBuf
;
SSchema
*
pSchema
;
SSchemaKey
schemaKey
=
{
uid
,
sver
};
DBT
key
=
{
0
};
DBT
value
=
{
0
};
// Set key/value properties
key
.
data
=
&
schemaKey
;
key
.
size
=
sizeof
(
schemaKey
);
// Query
ret
=
pDB
->
pSchemaDB
->
get
(
pDB
->
pSchemaDB
,
NULL
,
&
key
,
&
value
,
0
);
if
(
ret
!=
0
)
{
return
NULL
;
}
// Decode the schema
pBuf
=
value
.
data
;
taosDecodeFixedI32
(
&
pBuf
,
&
nCols
);
pSW
=
(
SSchemaWrapper
*
)
malloc
(
sizeof
(
*
pSW
)
+
sizeof
(
SSchema
)
*
nCols
);
if
(
pSW
==
NULL
)
{
return
NULL
;
}
pSW
->
pSchema
=
POINTER_SHIFT
(
pSW
,
sizeof
(
*
pSW
));
for
(
int
i
=
0
;
i
<
nCols
;
i
++
)
{
pSchema
=
pSW
->
pSchema
+
i
;
taosDecodeFixedI8
(
&
pBuf
,
&
(
pSchema
->
type
));
taosDecodeFixedI32
(
&
pBuf
,
&
(
pSchema
->
colId
));
taosDecodeFixedI32
(
&
pBuf
,
&
(
pSchema
->
bytes
));
taosDecodeStringTo
(
&
pBuf
,
pSchema
->
name
);
}
return
pSW
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录