Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
84da4d65
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
84da4d65
编写于
7月 15, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-5250]<enhance>: compress the tableMeta info msg.
上级
b68bb2a8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
15 deletion
+53
-15
src/client/src/tscServer.c
src/client/src/tscServer.c
+19
-3
src/inc/taosmsg.h
src/inc/taosmsg.h
+6
-4
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+28
-8
未找到文件。
src/client/src/tscServer.c
浏览文件 @
84da4d65
...
...
@@ -13,7 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <tscompression.h>
#include "os.h"
#include "qPlan.h"
#include "qTableMeta.h"
#include "tcmdtype.h"
#include "tlockfree.h"
#include "trpc.h"
...
...
@@ -21,10 +24,8 @@
#include "tscLog.h"
#include "tscProfile.h"
#include "tscUtil.h"
#include "qTableMeta.h"
#include "tsclient.h"
#include "ttimer.h"
#include "qPlan.h"
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
=
{
0
};
...
...
@@ -2048,16 +2049,27 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
}
SSqlCmd
*
pParentCmd
=
&
pParentSql
->
cmd
;
SHashObj
*
pSet
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
char
*
pMsg
=
pMultiMeta
->
meta
;
char
*
buf
=
NULL
;
if
(
pMultiMeta
->
compressed
)
{
buf
=
malloc
(
pMultiMeta
->
rawLen
-
sizeof
(
SMultiTableMeta
));
int32_t
len
=
tsDecompressString
(
pMultiMeta
->
meta
,
pMultiMeta
->
contLen
-
sizeof
(
SMultiTableMeta
),
1
,
buf
,
pMultiMeta
->
rawLen
-
sizeof
(
SMultiTableMeta
),
ONE_STAGE_COMP
,
NULL
,
0
);
assert
(
len
==
pMultiMeta
->
rawLen
-
sizeof
(
SMultiTableMeta
));
pMsg
=
buf
;
}
for
(
int32_t
i
=
0
;
i
<
pMultiMeta
->
numOfTables
;
i
++
)
{
STableMetaMsg
*
pMetaMsg
=
(
STableMetaMsg
*
)
pMsg
;
int32_t
code
=
tableMetaMsgConvert
(
pMetaMsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
taosHashCleanup
(
pSet
);
taosReleaseRef
(
tscObjRef
,
pParentSql
->
self
);
tfree
(
buf
);
return
code
;
}
...
...
@@ -2066,6 +2078,8 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
tscError
(
"0x%"
PRIx64
" invalid table meta from mnode, name:%s"
,
pSql
->
self
,
pMetaMsg
->
tableFname
);
taosHashCleanup
(
pSet
);
taosReleaseRef
(
tscObjRef
,
pParentSql
->
self
);
tfree
(
buf
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
...
...
@@ -2115,6 +2129,8 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
taosHashCleanup
(
pSet
);
taosReleaseRef
(
tscObjRef
,
pParentSql
->
self
);
tfree
(
buf
);
return
TSDB_CODE_SUCCESS
;
}
...
...
src/inc/taosmsg.h
浏览文件 @
84da4d65
...
...
@@ -760,10 +760,12 @@ typedef struct STableMetaMsg {
}
STableMetaMsg
;
typedef
struct
SMultiTableMeta
{
int32_t
numOfTables
;
int32_t
numOfVgroup
;
int32_t
contLen
;
char
meta
[];
int32_t
numOfTables
;
int32_t
numOfVgroup
;
uint32_t
contLen
:
31
;
uint8_t
compressed
:
1
;
// denote if compressed or not
uint32_t
rawLen
;
// size before compress
char
meta
[];
}
SMultiTableMeta
;
typedef
struct
{
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
84da4d65
...
...
@@ -2892,7 +2892,7 @@ static SMultiTableMeta* ensureMsgBufferSpace(SMultiTableMeta *pMultiMeta, SArray
(
*
totalMallocLen
)
*=
2
;
}
pMultiMeta
=
r
pcReallocCont
(
pMultiMeta
,
*
totalMallocLen
);
pMultiMeta
=
r
ealloc
(
pMultiMeta
,
*
totalMallocLen
);
if
(
pMultiMeta
==
NULL
)
{
return
NULL
;
}
...
...
@@ -2923,8 +2923,8 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) {
}
// first malloc 80KB, subsequent reallocation will expand the size as twice of the original size
int32_t
totalMallocLen
=
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
);
pMultiMeta
=
rpcMallocCont
(
totalMallocLen
);
int32_t
totalMallocLen
=
sizeof
(
S
MultiTableMeta
)
+
sizeof
(
S
TableMetaMsg
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
);
pMultiMeta
=
calloc
(
1
,
totalMallocLen
);
if
(
pMultiMeta
==
NULL
)
{
code
=
TSDB_CODE_MND_OUT_OF_MEMORY
;
goto
_end
;
...
...
@@ -2957,7 +2957,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) {
int
remain
=
totalMallocLen
-
pMultiMeta
->
contLen
;
if
(
remain
<=
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
))
{
totalMallocLen
*=
2
;
pMultiMeta
=
r
pcReallocCont
(
pMultiMeta
,
totalMallocLen
);
pMultiMeta
=
r
ealloc
(
pMultiMeta
,
totalMallocLen
);
if
(
pMultiMeta
==
NULL
)
{
mnodeDecTableRef
(
pMsg
->
pTable
);
code
=
TSDB_CODE_MND_OUT_OF_MEMORY
;
...
...
@@ -3027,16 +3027,36 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) {
pMsg
->
rpcRsp
.
len
=
pMultiMeta
->
contLen
;
code
=
TSDB_CODE_SUCCESS
;
char
*
tmp
=
rpcMallocCont
(
pMultiMeta
->
contLen
+
2
);
int32_t
len
=
tsCompressString
(
pMultiMeta
->
meta
,
(
int32_t
)
pMultiMeta
->
contLen
-
sizeof
(
SMultiTableMeta
),
1
,
tmp
+
sizeof
(
SMultiTableMeta
),
(
int32_t
)
pMultiMeta
->
contLen
-
sizeof
(
SMultiTableMeta
)
+
2
,
ONE_STAGE_COMP
,
NULL
,
0
);
pMultiMeta
->
rawLen
=
pMultiMeta
->
contLen
;
if
(
len
==
-
1
||
len
+
sizeof
(
SMultiTableMeta
)
>=
pMultiMeta
->
contLen
+
2
)
{
// compress failed, do not compress this binary data
pMultiMeta
->
compressed
=
0
;
memcpy
(
tmp
,
pMultiMeta
,
sizeof
(
SMultiTableMeta
)
+
pMultiMeta
->
contLen
);
}
else
{
pMultiMeta
->
compressed
=
1
;
pMultiMeta
->
contLen
=
sizeof
(
SMultiTableMeta
)
+
len
;
// copy the header and the compressed payload
memcpy
(
tmp
,
pMultiMeta
,
sizeof
(
SMultiTableMeta
));
}
pMsg
->
rpcRsp
.
rsp
=
tmp
;
pMsg
->
rpcRsp
.
len
=
pMultiMeta
->
contLen
;
SMultiTableMeta
*
p
=
(
SMultiTableMeta
*
)
tmp
;
mDebug
(
"multiTable info build completed, original:%d, compressed:%d, comp:%d"
,
p
->
rawLen
,
p
->
contLen
,
p
->
compressed
);
_end:
tfree
(
str
);
tfree
(
nameList
);
taosArrayDestroy
(
pList
);
pMsg
->
pTable
=
NULL
;
pMsg
->
pVgroup
=
NULL
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
rpcFreeCont
(
pMultiMeta
);
}
tfree
(
pMultiMeta
);
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录