Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
21c8d981
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看板
提交
21c8d981
编写于
11月 23, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
49c78ed5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
214 addition
and
0 deletion
+214
-0
include/common/tmsg.h
include/common/tmsg.h
+22
-0
include/util/tencode.h
include/util/tencode.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+191
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
21c8d981
...
...
@@ -3226,6 +3226,28 @@ int32_t tDeserializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq);
int32_t
tSerializeSMqHbReq
(
void
*
buf
,
int32_t
bufLen
,
SMqHbReq
*
pReq
);
int32_t
tDeserializeSMqHbReq
(
void
*
buf
,
int32_t
bufLen
,
SMqHbReq
*
pReq
);
typedef
struct
{
int64_t
suid
;
int64_t
uid
;
int32_t
sver
;
union
{
SArray
*
aRowP
;
SArray
*
aCol
;
};
}
SSubmitTbData
;
#define SUBMIT_REQ_AUTO_CREATE_TABLE 0x1
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
typedef
struct
{
int32_t
flag
;
SArray
*
aCreateTbReq
;
SArray
*
aSubmitTbData
;
}
SSubmitReq2
;
int32_t
tEncodeSSubmitReq2
(
SEncoder
*
pCoder
,
const
SSubmitReq2
*
pReq
);
int32_t
tDecodeSSubmitReq2
(
SDecoder
*
pCoder
,
SSubmitReq2
**
ppReq
);
void
tDestroySSubmitReq2
(
SSubmitReq2
*
pReq
);
#pragma pack(pop)
#ifdef __cplusplus
...
...
include/util/tencode.h
浏览文件 @
21c8d981
...
...
@@ -116,6 +116,7 @@ static int32_t tEncodeI64v(SEncoder* pCoder, int64_t val);
static
int32_t
tEncodeFloat
(
SEncoder
*
pCoder
,
float
val
);
static
int32_t
tEncodeDouble
(
SEncoder
*
pCoder
,
double
val
);
static
int32_t
tEncodeBinary
(
SEncoder
*
pCoder
,
const
uint8_t
*
val
,
uint32_t
len
);
static
int32_t
tEncodeBinaryEx
(
SEncoder
*
pCoder
,
const
uint8_t
*
val
,
uint32_t
len
);
static
int32_t
tEncodeCStrWithLen
(
SEncoder
*
pCoder
,
const
char
*
val
,
uint32_t
len
);
static
int32_t
tEncodeCStr
(
SEncoder
*
pCoder
,
const
char
*
val
);
...
...
source/common/src/tmsg.c
浏览文件 @
21c8d981
...
...
@@ -6652,3 +6652,194 @@ int32_t tDecodeSBatchDeleteReq(SDecoder *pDecoder, SBatchDeleteReq *pReq) {
}
return
0
;
}
static
int32_t
tEncodeSSubmitTbData
(
SEncoder
*
pCoder
,
const
SSubmitTbData
*
pSubmitTbData
,
int8_t
colFmt
)
{
if
(
tStartEncode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pSubmitTbData
->
suid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pSubmitTbData
->
uid
)
<
0
)
return
-
1
;
if
(
tEncodeI32v
(
pCoder
,
pSubmitTbData
->
sver
)
<
0
)
return
-
1
;
if
(
colFmt
)
{
// todo
ASSERT
(
0
);
}
else
{
if
(
tEncodeI64v
(
pCoder
,
taosArrayGetSize
(
pSubmitTbData
->
aRowP
))
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pSubmitTbData
->
aRowP
);
i
++
)
{
SRow
*
pRow
=
taosArrayGetP
(
pSubmitTbData
->
aRowP
,
i
);
if
(
tEncodeBinary
(
pCoder
,
(
uint8_t
*
)
pRow
,
pRow
->
len
)
<
0
)
return
-
1
;
// todo
}
}
tEndEncode
(
pCoder
);
return
0
;
}
static
int32_t
tDecodeSSubmitTbData
(
SDecoder
*
pCoder
,
SSubmitTbData
*
pSubmitTbData
,
int8_t
colFmt
)
{
int32_t
code
=
0
;
if
(
tStartDecode
(
pCoder
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
if
(
tDecodeI64
(
pCoder
,
&
pSubmitTbData
->
suid
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
if
(
tDecodeI64
(
pCoder
,
&
pSubmitTbData
->
uid
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
if
(
tDecodeI32v
(
pCoder
,
&
pSubmitTbData
->
sver
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
if
(
colFmt
)
{
// todo
ASSERT
(
0
);
}
else
{
int64_t
nRows
=
0
;
if
(
tDecodeI64v
(
pCoder
,
&
nRows
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
pSubmitTbData
->
aRowP
=
taosArrayInit
(
nRows
,
sizeof
(
SRow
*
));
if
(
pSubmitTbData
->
aRowP
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
for
(
int32_t
i
=
0
;
i
<
nRows
;
i
++
)
{
SRow
**
ppRow
=
taosArrayReserve
(
pSubmitTbData
->
aRowP
,
1
);
if
(
tDecodeBinary
(
pCoder
,
(
uint8_t
**
)
ppRow
,
NULL
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
}
}
tEndDecode
(
pCoder
);
_exit:
if
(
code
)
{
// todo: do clear
}
return
0
;
}
int32_t
tEncodeSSubmitReq2
(
SEncoder
*
pCoder
,
const
SSubmitReq2
*
pReq
)
{
if
(
tStartEncode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32v
(
pCoder
,
pReq
->
flag
)
<
0
)
return
-
1
;
if
(
pReq
->
flag
&
SUBMIT_REQ_AUTO_CREATE_TABLE
)
{
if
(
tEncodeI64v
(
pCoder
,
taosArrayGetSize
(
pReq
->
aCreateTbReq
))
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pReq
->
aCreateTbReq
);
++
i
)
{
SVCreateTbReq
*
pCreateTbReq
=
(
SVCreateTbReq
*
)
taosArrayGet
(
pReq
->
aCreateTbReq
,
i
);
if
(
tEncodeSVCreateTbReq
(
pCoder
,
pCreateTbReq
)
<
0
)
return
-
1
;
}
}
if
(
tEncodeI64v
(
pCoder
,
taosArrayGetSize
(
pReq
->
aSubmitTbData
))
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pReq
->
aSubmitTbData
);
++
i
)
{
SSubmitTbData
*
pSubmitTbData
=
(
SSubmitTbData
*
)
taosArrayGet
(
pReq
->
aSubmitTbData
,
i
);
if
(
tEncodeSSubmitTbData
(
pCoder
,
pSubmitTbData
,
pReq
->
flag
&
SUBMIT_REQ_COLUMN_DATA_FORMAT
)
<
0
)
return
-
1
;
}
tEndEncode
(
pCoder
);
return
0
;
}
int32_t
tDecodeSSubmitReq2
(
SDecoder
*
pCoder
,
SSubmitReq2
**
ppReq
)
{
int32_t
code
=
0
;
// alloc
SSubmitReq2
*
pReq
=
(
SSubmitReq2
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSubmitReq2
));
if
(
pReq
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
// decode
if
(
tStartDecode
(
pCoder
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
if
(
tDecodeI32v
(
pCoder
,
&
pReq
->
flag
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
if
(
pReq
->
flag
&
SUBMIT_REQ_AUTO_CREATE_TABLE
)
{
int64_t
nCreateTbReq
=
0
;
if
(
tDecodeI64v
(
pCoder
,
&
nCreateTbReq
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
pReq
->
aCreateTbReq
=
taosArrayInit
(
nCreateTbReq
,
sizeof
(
SVCreateTbReq
));
if
(
pReq
->
aCreateTbReq
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
for
(
int64_t
i
=
0
;
i
<
nCreateTbReq
;
++
i
)
{
SVCreateTbReq
*
pCreateTbReq
=
taosArrayReserve
(
pReq
->
aCreateTbReq
,
1
);
if
(
tDecodeSVCreateTbReq
(
pCoder
,
pCreateTbReq
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
}
}
int64_t
nSubmitTbData
=
0
;
if
(
tDecodeI64v
(
pCoder
,
&
nSubmitTbData
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
pReq
->
aSubmitTbData
=
taosArrayInit
(
nSubmitTbData
,
sizeof
(
SSubmitTbData
));
if
(
pReq
->
aSubmitTbData
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
for
(
int64_t
i
=
0
;
i
<
nSubmitTbData
;
++
i
)
{
SSubmitTbData
*
pSubmitTbData
=
taosArrayReserve
(
pReq
->
aSubmitTbData
,
1
);
if
(
tDecodeSSubmitTbData
(
pCoder
,
pSubmitTbData
,
pReq
->
flag
&
SUBMIT_REQ_COLUMN_DATA_FORMAT
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
}
tEndDecode
(
pCoder
);
_exit:
if
(
code
)
{
*
ppReq
=
NULL
;
if
(
pReq
)
{
// todo: do other clear
taosMemoryFree
(
pReq
);
}
}
else
{
*
ppReq
=
pReq
;
}
return
0
;
}
void
tDestroySSubmitReq2
(
SSubmitReq2
*
pReq
)
{
if
(
NULL
==
pReq
)
return
;
if
(
pReq
->
flag
&
SUBMIT_REQ_AUTO_CREATE_TABLE
)
{
taosArrayDestroyEx
(
pReq
->
aCreateTbReq
,
NULL
/* todo */
);
}
taosArrayDestroyEx
(
pReq
->
aSubmitTbData
,
NULL
/* todo */
);
taosMemoryFree
(
pReq
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录