Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d9cd1a7a
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看板
提交
d9cd1a7a
编写于
12月 31, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix table meta query problem
上级
36437b65
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
54 deletion
+49
-54
include/dnode/vnode/meta/meta.h
include/dnode/vnode/meta/meta.h
+1
-1
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+48
-53
未找到文件。
include/dnode/vnode/meta/meta.h
浏览文件 @
d9cd1a7a
...
@@ -38,7 +38,7 @@ typedef struct SMetaCfg {
...
@@ -38,7 +38,7 @@ typedef struct SMetaCfg {
}
SMetaCfg
;
}
SMetaCfg
;
typedef
struct
{
typedef
struct
{
int32_t
nCols
;
uint32_t
nCols
;
SSchema
*
pSchema
;
SSchema
*
pSchema
;
}
SSchemaWrapper
;
}
SSchemaWrapper
;
...
...
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
d9cd1a7a
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
typedef
struct
{
typedef
struct
{
tb_uid_t
uid
;
tb_uid_t
uid
;
int32_t
sver
;
int32_t
sver
;
int32_t
padding
;
}
SSchemaKey
;
}
SSchemaKey
;
struct
SMetaDB
{
struct
SMetaDB
{
...
@@ -55,6 +56,8 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *
...
@@ -55,6 +56,8 @@ 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
int
metaEncodeSchema
(
void
**
buf
,
SSchemaWrapper
*
pSW
);
static
void
*
metaDecodeSchema
(
void
*
buf
,
SSchemaWrapper
*
pSW
);
#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))
...
@@ -169,18 +172,13 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
...
@@ -169,18 +172,13 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
pBuf
=
buf
;
pBuf
=
buf
;
memset
(
&
key
,
0
,
sizeof
(
key
));
memset
(
&
key
,
0
,
sizeof
(
key
));
memset
(
&
value
,
0
,
sizeof
(
key
));
memset
(
&
value
,
0
,
sizeof
(
key
));
SSchemaKey
schemaKey
=
{
uid
,
0
/*TODO*/
};
SSchemaKey
schemaKey
=
{
uid
,
0
/*TODO*/
,
0
};
key
.
data
=
&
schemaKey
;
key
.
data
=
&
schemaKey
;
key
.
size
=
sizeof
(
schemaKey
);
key
.
size
=
sizeof
(
schemaKey
);
taosEncodeFixedU32
(
&
pBuf
,
ncols
);
SSchemaWrapper
sw
=
{.
nCols
=
ncols
,
.
pSchema
=
pSchema
};
for
(
size_t
i
=
0
;
i
<
ncols
;
i
++
)
{
metaEncodeSchema
(
&
pBuf
,
&
sw
);
taosEncodeFixedI8
(
&
pBuf
,
pSchema
[
i
].
type
);
taosEncodeFixedI32
(
&
pBuf
,
pSchema
[
i
].
colId
);
taosEncodeFixedI32
(
&
pBuf
,
pSchema
[
i
].
bytes
);
taosEncodeString
(
&
pBuf
,
pSchema
[
i
].
name
);
}
value
.
data
=
buf
;
value
.
data
=
buf
;
value
.
size
=
POINTER_DISTANCE
(
pBuf
,
buf
);
value
.
size
=
POINTER_DISTANCE
(
pBuf
,
buf
);
...
@@ -197,6 +195,38 @@ int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) {
...
@@ -197,6 +195,38 @@ int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) {
}
}
/* ------------------------ STATIC METHODS ------------------------ */
/* ------------------------ STATIC METHODS ------------------------ */
static
int
metaEncodeSchema
(
void
**
buf
,
SSchemaWrapper
*
pSW
)
{
int
tlen
=
0
;
SSchema
*
pSchema
;
tlen
+=
taosEncodeFixedU32
(
buf
,
pSW
->
nCols
);
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
pSchema
=
pSW
->
pSchema
+
i
;
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
}
return
tlen
;
}
static
void
*
metaDecodeSchema
(
void
*
buf
,
SSchemaWrapper
*
pSW
)
{
SSchema
*
pSchema
;
buf
=
taosDecodeFixedU32
(
buf
,
&
pSW
->
nCols
);
pSW
->
pSchema
=
(
SSchema
*
)
malloc
(
sizeof
(
SSchema
)
*
pSW
->
nCols
);
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
pSchema
=
pSW
->
pSchema
+
i
;
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
}
return
buf
;
}
static
SMetaDB
*
metaNewDB
()
{
static
SMetaDB
*
metaNewDB
()
{
SMetaDB
*
pDB
=
NULL
;
SMetaDB
*
pDB
=
NULL
;
pDB
=
(
SMetaDB
*
)
calloc
(
1
,
sizeof
(
*
pDB
));
pDB
=
(
SMetaDB
*
)
calloc
(
1
,
sizeof
(
*
pDB
));
...
@@ -376,15 +406,8 @@ static int metaEncodeTbInfo(void **buf, STbCfg *pTbCfg) {
...
@@ -376,15 +406,8 @@ static int metaEncodeTbInfo(void **buf, STbCfg *pTbCfg) {
tsize
+=
taosEncodeFixedU8
(
buf
,
pTbCfg
->
type
);
tsize
+=
taosEncodeFixedU8
(
buf
,
pTbCfg
->
type
);
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
tsize
+=
taosEncodeVariantU32
(
buf
,
pTbCfg
->
stbCfg
.
nTagCols
);
SSchemaWrapper
sw
=
{.
nCols
=
pTbCfg
->
stbCfg
.
nTagCols
,
.
pSchema
=
pTbCfg
->
stbCfg
.
pTagSchema
};
for
(
uint32_t
i
=
0
;
i
<
pTbCfg
->
stbCfg
.
nTagCols
;
i
++
)
{
tsize
+=
metaEncodeSchema
(
buf
,
&
sw
);
tsize
+=
taosEncodeFixedI8
(
buf
,
pTbCfg
->
stbCfg
.
pTagSchema
[
i
].
type
);
tsize
+=
taosEncodeFixedI32
(
buf
,
pTbCfg
->
stbCfg
.
pTagSchema
[
i
].
colId
);
tsize
+=
taosEncodeFixedI32
(
buf
,
pTbCfg
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
tsize
+=
taosEncodeString
(
buf
,
pTbCfg
->
stbCfg
.
pTagSchema
[
i
].
name
);
}
// tsize += tdEncodeSchema(buf, pTbCfg->stbCfg.pTagSchema);
}
else
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
}
else
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
tsize
+=
taosEncodeFixedU64
(
buf
,
pTbCfg
->
ctbCfg
.
suid
);
tsize
+=
taosEncodeFixedU64
(
buf
,
pTbCfg
->
ctbCfg
.
suid
);
tsize
+=
tdEncodeKVRow
(
buf
,
pTbCfg
->
ctbCfg
.
pTag
);
tsize
+=
tdEncodeKVRow
(
buf
,
pTbCfg
->
ctbCfg
.
pTag
);
...
@@ -403,14 +426,10 @@ static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) {
...
@@ -403,14 +426,10 @@ static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) {
buf
=
taosDecodeFixedU8
(
buf
,
&
(
pTbCfg
->
type
));
buf
=
taosDecodeFixedU8
(
buf
,
&
(
pTbCfg
->
type
));
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
buf
=
taosDecodeVariantU32
(
buf
,
&
(
pTbCfg
->
stbCfg
.
nTagCols
));
SSchemaWrapper
sw
;
pTbCfg
->
stbCfg
.
pTagSchema
=
(
SSchema
*
)
malloc
(
sizeof
(
SSchema
)
*
pTbCfg
->
stbCfg
.
nTagCols
);
buf
=
metaDecodeSchema
(
buf
,
&
sw
);
for
(
uint32_t
i
=
0
;
i
<
pTbCfg
->
stbCfg
.
nTagCols
;
i
++
)
{
pTbCfg
->
stbCfg
.
nTagCols
=
sw
.
nCols
;
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pTbCfg
->
stbCfg
.
pTagSchema
[
i
].
type
));
pTbCfg
->
stbCfg
.
pTagSchema
=
sw
.
pSchema
;
buf
=
taosDecodeFixedI32
(
buf
,
&
pTbCfg
->
stbCfg
.
pTagSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pTbCfg
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
pTbCfg
->
stbCfg
.
pTagSchema
[
i
].
name
);
}
}
else
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
}
else
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pTbCfg
->
ctbCfg
.
suid
));
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pTbCfg
->
ctbCfg
.
suid
));
buf
=
tdDecodeKVRow
(
buf
,
&
(
pTbCfg
->
ctbCfg
.
pTag
));
buf
=
tdDecodeKVRow
(
buf
,
&
(
pTbCfg
->
ctbCfg
.
pTag
));
...
@@ -496,7 +515,7 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
...
@@ -496,7 +515,7 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
int
ret
;
int
ret
;
void
*
pBuf
;
void
*
pBuf
;
SSchema
*
pSchema
;
SSchema
*
pSchema
;
SSchemaKey
schemaKey
=
{
uid
,
sver
};
SSchemaKey
schemaKey
=
{
uid
,
sver
,
0
};
DBT
key
=
{
0
};
DBT
key
=
{
0
};
DBT
value
=
{
0
};
DBT
value
=
{
0
};
...
@@ -507,38 +526,14 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
...
@@ -507,38 +526,14 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
// Query
// Query
ret
=
pDB
->
pSchemaDB
->
get
(
pDB
->
pSchemaDB
,
NULL
,
&
key
,
&
value
,
0
);
ret
=
pDB
->
pSchemaDB
->
get
(
pDB
->
pSchemaDB
,
NULL
,
&
key
,
&
value
,
0
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
printf
(
"failed to query schema DB since %s================
\n
"
,
db_strerror
(
ret
));
return
NULL
;
return
NULL
;
}
}
// Decode the schema
// Decode the schema
pBuf
=
value
.
data
;
pBuf
=
value
.
data
;
taosDecodeFixedI32
(
&
pBuf
,
&
nCols
);
pSW
=
malloc
(
sizeof
(
*
pSW
));
if
(
isinline
)
{
metaDecodeSchema
(
pBuf
,
pSW
);
pSW
=
(
SSchemaWrapper
*
)
malloc
(
sizeof
(
*
pSW
)
+
sizeof
(
SSchema
)
*
nCols
);
if
(
pSW
==
NULL
)
{
return
NULL
;
}
pSW
->
pSchema
=
POINTER_SHIFT
(
pSW
,
sizeof
(
*
pSW
));
}
else
{
pSW
=
(
SSchemaWrapper
*
)
malloc
(
sizeof
(
*
pSW
));
if
(
pSW
==
NULL
)
{
return
NULL
;
}
pSW
->
pSchema
=
(
SSchema
*
)
malloc
(
sizeof
(
SSchema
)
*
nCols
);
if
(
pSW
->
pSchema
==
NULL
)
{
free
(
pSW
);
return
NULL
;
}
}
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
;
return
pSW
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录