Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
fb0456ca
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fb0456ca
编写于
10月 19, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1747] reduce tableMeta size
上级
3abaaabe
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
63 addition
and
29 deletion
+63
-29
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+4
-4
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+13
-2
src/client/src/tscServer.c
src/client/src/tscServer.c
+12
-6
src/inc/taosmsg.h
src/inc/taosmsg.h
+22
-5
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+12
-12
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
fb0456ca
...
...
@@ -90,10 +90,10 @@ typedef struct STableComInfo {
}
STableComInfo
;
typedef
struct
SCMCorVgroupInfo
{
int32_t
version
;
int8_t
inUse
;
int8_t
numOfEps
;
SEpAddr
epAddr
[
TSDB_MAX_REPLICA
];
int32_t
version
;
int8_t
inUse
;
int8_t
numOfEps
;
SEpAddr
1
epAddr
[
TSDB_MAX_REPLICA
];
}
SCMCorVgroupInfo
;
typedef
struct
STableMeta
{
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
fb0456ca
...
...
@@ -145,10 +145,11 @@ static void tscInitCorVgroupInfo(SCMCorVgroupInfo *corVgroupInfo, SCMVgroupInfo
corVgroupInfo
->
inUse
=
0
;
corVgroupInfo
->
numOfEps
=
vgroupInfo
->
numOfEps
;
for
(
int32_t
i
=
0
;
i
<
corVgroupInfo
->
numOfEps
;
i
++
)
{
strncpy
(
corVgroupInfo
->
epAddr
[
i
].
fqdn
,
vgroupInfo
->
epAddr
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
corVgroupInfo
->
epAddr
[
i
].
fqdn
=
strdup
(
vgroupInfo
->
epAddr
[
i
].
fqdn
);
corVgroupInfo
->
epAddr
[
i
].
port
=
vgroupInfo
->
epAddr
[
i
].
port
;
}
}
STableMeta
*
tscCreateTableMetaFromMsg
(
STableMetaMsg
*
pTableMetaMsg
,
size_t
*
size
)
{
assert
(
pTableMetaMsg
!=
NULL
);
...
...
@@ -164,7 +165,17 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
pTableMeta
->
id
.
tid
=
pTableMetaMsg
->
sid
;
pTableMeta
->
id
.
uid
=
pTableMetaMsg
->
uid
;
pTableMeta
->
vgroupInfo
=
pTableMetaMsg
->
vgroup
;
SCMVgroupInfo
*
pVgroupInfo
=
&
pTableMeta
->
vgroupInfo
;
pVgroupInfo
->
numOfEps
=
pTableMetaMsg
->
vgroup
.
numOfEps
;
pVgroupInfo
->
vgId
=
pTableMetaMsg
->
vgroup
.
vgId
;
for
(
int32_t
i
=
0
;
i
<
pVgroupInfo
->
numOfEps
;
++
i
)
{
SEpAddrMsg
*
pEpMsg
=
&
pTableMetaMsg
->
vgroup
.
epAddr
[
i
];
pVgroupInfo
->
epAddr
[
i
].
fqdn
=
strndup
(
pEpMsg
->
fqdn
,
tListLen
(
pEpMsg
->
fqdn
));
pVgroupInfo
->
epAddr
[
i
].
port
=
pEpMsg
->
port
;
}
tscInitCorVgroupInfo
(
&
pTableMeta
->
corVgroupInfo
,
&
pTableMeta
->
vgroupInfo
);
...
...
src/client/src/tscServer.c
浏览文件 @
fb0456ca
...
...
@@ -1839,22 +1839,28 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) {
SSqlCmd
*
pCmd
=
&
parent
->
cmd
;
for
(
int32_t
i
=
0
;
i
<
pStableVgroup
->
numOfTables
;
++
i
)
{
STableMetaInfo
*
pInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
i
);
SVgroupsInfo
*
pVgroupInfo
=
(
SVgroupsInfo
*
)
pMsg
;
pVgroupInfo
->
numOfVgroups
=
htonl
(
pVgroupInfo
->
numOfVgroups
);
size_t
size
=
sizeof
(
SCMVgroupInfo
)
*
pVgroupInfo
->
numOfVgroups
+
sizeof
(
SVgroupsInfo
);
SVgroupsMsg
*
pVgroupMsg
=
(
SVgroupsMsg
*
)
pMsg
;
pVgroupMsg
->
numOfVgroups
=
htonl
(
pVgroupMsg
->
numOfVgroups
);
size_t
size
=
sizeof
(
SCMVgroupInfo
)
*
pVgroupMsg
->
numOfVgroups
+
sizeof
(
SVgroupsInfo
);
pInfo
->
vgroupList
=
calloc
(
1
,
size
);
assert
(
pInfo
->
vgroupList
!=
NULL
);
memcpy
(
pInfo
->
vgroupList
,
pVgroupInfo
,
size
)
;
pInfo
->
vgroupList
->
numOfVgroups
=
pVgroupMsg
->
numOfVgroups
;
for
(
int32_t
j
=
0
;
j
<
pInfo
->
vgroupList
->
numOfVgroups
;
++
j
)
{
//just init, no need to lock
SCMVgroupInfo
*
pVgroups
=
&
pInfo
->
vgroupList
->
vgroups
[
j
];
pVgroups
->
vgId
=
htonl
(
pVgroups
->
vgId
);
SCMVgroupMsg
*
vgroupMsg
=
&
pVgroupMsg
->
vgroups
[
j
];
pVgroups
->
vgId
=
htonl
(
vgroupMsg
->
vgId
);
pVgroups
->
numOfEps
=
vgroupMsg
->
numOfEps
;
assert
(
pVgroups
->
numOfEps
>=
1
);
for
(
int32_t
k
=
0
;
k
<
pVgroups
->
numOfEps
;
++
k
)
{
pVgroups
->
epAddr
[
k
].
port
=
htons
(
pVgroups
->
epAddr
[
k
].
port
);
pVgroups
->
epAddr
[
k
].
port
=
htons
(
vgroupMsg
->
epAddr
[
k
].
port
);
pVgroups
->
epAddr
[
k
].
fqdn
=
strndup
(
vgroupMsg
->
epAddr
[
k
].
fqdn
,
tListLen
(
vgroupMsg
->
epAddr
[
k
].
fqdn
));
}
}
...
...
src/inc/taosmsg.h
浏览文件 @
fb0456ca
...
...
@@ -182,10 +182,16 @@ extern char *taosMsg[];
#pragma pack(push, 1)
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
typedef
struct
{
char
fqdn
[
TSDB_FQDN_LEN
];
uint16_t
port
;
}
SEpAddr
;
}
SEpAddrMsg
;
typedef
struct
{
char
*
fqdn
;
uint16_t
port
;
}
SEpAddr1
;
typedef
struct
{
int32_t
numOfVnodes
;
...
...
@@ -662,16 +668,27 @@ typedef struct SCMSTableVgroupMsg {
}
SCMSTableVgroupMsg
,
SCMSTableVgroupRspMsg
;
typedef
struct
{
int32_t
vgId
;
int8_t
numOfEps
;
SEpAddr
epAddr
[
TSDB_MAX_REPLICA
];
int32_t
vgId
;
int8_t
numOfEps
;
SEpAddr
1
epAddr
[
TSDB_MAX_REPLICA
];
}
SCMVgroupInfo
;
typedef
struct
{
int32_t
vgId
;
int8_t
numOfEps
;
SEpAddrMsg
epAddr
[
TSDB_MAX_REPLICA
];
}
SCMVgroupMsg
;
typedef
struct
{
int32_t
numOfVgroups
;
SCMVgroupInfo
vgroups
[];
}
SVgroupsInfo
;
typedef
struct
{
int32_t
numOfVgroups
;
SCMVgroupMsg
vgroups
[];
}
SVgroupsMsg
;
typedef
struct
STableMetaMsg
{
int32_t
contLen
;
char
tableId
[
TSDB_TABLE_FNAME_LEN
];
// table id
...
...
@@ -684,7 +701,7 @@ typedef struct STableMetaMsg {
int16_t
tversion
;
int32_t
sid
;
uint64_t
uid
;
SCMVgroup
Info
vgroup
;
SCMVgroup
Msg
vgroup
;
SSchema
schema
[];
}
STableMetaMsg
;
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
fb0456ca
...
...
@@ -1472,12 +1472,12 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
int32_t
numOfTable
=
htonl
(
pInfo
->
numOfTables
);
// reserve space
int32_t
contLen
=
sizeof
(
SCMSTableVgroupRspMsg
)
+
32
*
sizeof
(
SCMVgroupInfo
)
+
sizeof
(
SVgroups
Info
);
int32_t
contLen
=
sizeof
(
SCMSTableVgroupRspMsg
)
+
32
*
sizeof
(
SCMVgroupInfo
)
+
sizeof
(
SVgroups
Msg
);
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SCMSTableVgroupMsg
)
+
(
TSDB_TABLE_FNAME_LEN
)
*
i
;
SSuperTableObj
*
pTable
=
mnodeGetSuperTable
(
stableName
);
if
(
pTable
!=
NULL
&&
pTable
->
vgHash
!=
NULL
)
{
contLen
+=
(
taosHashGetSize
(
pTable
->
vgHash
)
*
sizeof
(
SCMVgroupInfo
)
+
sizeof
(
SVgroups
Info
));
contLen
+=
(
taosHashGetSize
(
pTable
->
vgHash
)
*
sizeof
(
SCMVgroupInfo
)
+
sizeof
(
SVgroups
Msg
));
}
mnodeDecTableRef
(
pTable
);
}
...
...
@@ -1506,12 +1506,12 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
// even this super table has no corresponding table, still return
pRsp
->
numOfTables
++
;
SVgroups
Info
*
pVgroupInfo
=
(
SVgroupsInfo
*
)
msg
;
pVgroup
Info
->
numOfVgroups
=
0
;
SVgroups
Msg
*
pVgroupMsg
=
(
SVgroupsMsg
*
)
msg
;
pVgroup
Msg
->
numOfVgroups
=
0
;
msg
+=
sizeof
(
SVgroups
Info
);
msg
+=
sizeof
(
SVgroups
Msg
);
}
else
{
SVgroups
Info
*
pVgroupInfo
=
(
SVgroupsInfo
*
)
msg
;
SVgroups
Msg
*
pVgroupMsg
=
(
SVgroupsMsg
*
)
msg
;
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pTable
->
vgHash
);
int32_t
vgSize
=
0
;
...
...
@@ -1520,15 +1520,15 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
*
pVgId
);
if
(
pVgroup
==
NULL
)
continue
;
pVgroup
Info
->
vgroups
[
vgSize
].
vgId
=
htonl
(
pVgroup
->
vgId
);
pVgroup
Msg
->
vgroups
[
vgSize
].
vgId
=
htonl
(
pVgroup
->
vgId
);
for
(
int32_t
vn
=
0
;
vn
<
pVgroup
->
numOfVnodes
;
++
vn
)
{
SDnodeObj
*
pDnode
=
pVgroup
->
vnodeGid
[
vn
].
pDnode
;
if
(
pDnode
==
NULL
)
break
;
tstrncpy
(
pVgroup
Info
->
vgroups
[
vgSize
].
epAddr
[
vn
].
fqdn
,
pDnode
->
dnodeFqdn
,
TSDB_FQDN_LEN
);
pVgroup
Info
->
vgroups
[
vgSize
].
epAddr
[
vn
].
port
=
htons
(
pDnode
->
dnodePort
);
tstrncpy
(
pVgroup
Msg
->
vgroups
[
vgSize
].
epAddr
[
vn
].
fqdn
,
pDnode
->
dnodeFqdn
,
TSDB_FQDN_LEN
);
pVgroup
Msg
->
vgroups
[
vgSize
].
epAddr
[
vn
].
port
=
htons
(
pDnode
->
dnodePort
);
pVgroup
Info
->
vgroups
[
vgSize
].
numOfEps
++
;
pVgroup
Msg
->
vgroups
[
vgSize
].
numOfEps
++
;
}
vgSize
++
;
...
...
@@ -1538,10 +1538,10 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
taosHashDestroyIter
(
pIter
);
mnodeDecTableRef
(
pTable
);
pVgroup
Info
->
numOfVgroups
=
htonl
(
vgSize
);
pVgroup
Msg
->
numOfVgroups
=
htonl
(
vgSize
);
// one table is done, try the next table
msg
+=
sizeof
(
SVgroups
Info
)
+
vgSize
*
sizeof
(
SCMVgroupInfo
);
msg
+=
sizeof
(
SVgroups
Msg
)
+
vgSize
*
sizeof
(
SCMVgroupMsg
);
pRsp
->
numOfTables
++
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录