Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
20854de4
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
20854de4
编写于
5月 07, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compile error
上级
141ef5af
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
62 deletion
+63
-62
include/common/tmsg.h
include/common/tmsg.h
+1
-1
include/util/tencode.h
include/util/tencode.h
+2
-2
source/util/test/CMakeLists.txt
source/util/test/CMakeLists.txt
+3
-3
source/util/test/encodeTest.cpp
source/util/test/encodeTest.cpp
+57
-56
未找到文件。
include/common/tmsg.h
浏览文件 @
20854de4
...
@@ -1824,7 +1824,7 @@ int32_t tDeserializeSClientHbBatchRsp(void* buf, int32_t bufLen, SClientHbBatchR
...
@@ -1824,7 +1824,7 @@ int32_t tDeserializeSClientHbBatchRsp(void* buf, int32_t bufLen, SClientHbBatchR
static
FORCE_INLINE
int32_t
tEncodeSKv
(
SEncoder
*
pEncoder
,
const
SKv
*
pKv
)
{
static
FORCE_INLINE
int32_t
tEncodeSKv
(
SEncoder
*
pEncoder
,
const
SKv
*
pKv
)
{
if
(
tEncodeI32
(
pEncoder
,
pKv
->
key
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pKv
->
key
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pKv
->
valueLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pKv
->
valueLen
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
pEncoder
,
(
const
char
*
)
pKv
->
value
,
pKv
->
valueLen
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
pEncoder
,
(
uint8_t
*
)
pKv
->
value
,
pKv
->
valueLen
)
<
0
)
return
-
1
;
return
0
;
return
0
;
}
}
...
...
include/util/tencode.h
浏览文件 @
20854de4
...
@@ -275,7 +275,7 @@ static FORCE_INLINE int32_t tEncodeBinary(SEncoder* pCoder, const uint8_t* val,
...
@@ -275,7 +275,7 @@ static FORCE_INLINE int32_t tEncodeBinary(SEncoder* pCoder, const uint8_t* val,
}
}
static
FORCE_INLINE
int32_t
tEncodeCStrWithLen
(
SEncoder
*
pCoder
,
const
char
*
val
,
uint32_t
len
)
{
static
FORCE_INLINE
int32_t
tEncodeCStrWithLen
(
SEncoder
*
pCoder
,
const
char
*
val
,
uint32_t
len
)
{
return
tEncodeBinary
(
pCoder
,
(
void
*
)
val
,
len
+
1
);
return
tEncodeBinary
(
pCoder
,
(
uint8_t
*
)
val
,
len
+
1
);
}
}
static
FORCE_INLINE
int32_t
tEncodeCStr
(
SEncoder
*
pCoder
,
const
char
*
val
)
{
static
FORCE_INLINE
int32_t
tEncodeCStr
(
SEncoder
*
pCoder
,
const
char
*
val
)
{
...
@@ -383,7 +383,7 @@ static FORCE_INLINE int32_t tDecodeBinary(SDecoder* pCoder, const uint8_t** val,
...
@@ -383,7 +383,7 @@ static FORCE_INLINE int32_t tDecodeBinary(SDecoder* pCoder, const uint8_t** val,
if
(
TD_CODER_CHECK_CAPACITY_FAILED
(
pCoder
,
*
len
))
return
-
1
;
if
(
TD_CODER_CHECK_CAPACITY_FAILED
(
pCoder
,
*
len
))
return
-
1
;
if
(
val
)
{
if
(
val
)
{
*
val
=
(
void
*
)
TD_CODER_CURRENT
(
pCoder
);
*
val
=
(
uint8_t
*
)
TD_CODER_CURRENT
(
pCoder
);
}
}
TD_CODER_MOVE_POS
(
pCoder
,
*
len
);
TD_CODER_MOVE_POS
(
pCoder
,
*
len
);
...
...
source/util/test/CMakeLists.txt
浏览文件 @
20854de4
...
@@ -41,9 +41,9 @@ target_sources(freelistTest
...
@@ -41,9 +41,9 @@ target_sources(freelistTest
)
)
target_link_libraries
(
freelistTest os util gtest gtest_main
)
target_link_libraries
(
freelistTest os util gtest gtest_main
)
# encodeTest
#
#
encodeTest
add_executable
(
encodeTest
"encodeTest.cpp"
)
#
add_executable(encodeTest "encodeTest.cpp")
target_link_libraries
(
encodeTest os util gtest gtest_main
)
#
target_link_libraries(encodeTest os util gtest gtest_main)
# queueTest
# queueTest
add_executable
(
procTest
"procTest.cpp"
)
add_executable
(
procTest
"procTest.cpp"
)
...
...
source/util/test/encodeTest.cpp
浏览文件 @
20854de4
...
@@ -12,48 +12,49 @@
...
@@ -12,48 +12,49 @@
#define BUF_SIZE 64
#define BUF_SIZE 64
td_endian_t
endian_arr
[
2
]
=
{
TD_LITTLE_ENDIAN
,
TD_BIG_ENDIAN
};
td_endian_t
endian_arr
[
2
]
=
{
TD_LITTLE_ENDIAN
,
TD_BIG_ENDIAN
};
static
int32_t
encode
(
S
C
oder
*
pCoder
,
int8_t
val
)
{
return
tEncodeI8
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
Enc
oder
*
pCoder
,
int8_t
val
)
{
return
tEncodeI8
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
C
oder
*
pCoder
,
uint8_t
val
)
{
return
tEncodeU8
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
Enc
oder
*
pCoder
,
uint8_t
val
)
{
return
tEncodeU8
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
C
oder
*
pCoder
,
int16_t
val
)
{
return
tEncodeI16
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
Enc
oder
*
pCoder
,
int16_t
val
)
{
return
tEncodeI16
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
C
oder
*
pCoder
,
uint16_t
val
)
{
return
tEncodeU16
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
Enc
oder
*
pCoder
,
uint16_t
val
)
{
return
tEncodeU16
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
C
oder
*
pCoder
,
int32_t
val
)
{
return
tEncodeI32
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
Enc
oder
*
pCoder
,
int32_t
val
)
{
return
tEncodeI32
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
C
oder
*
pCoder
,
uint32_t
val
)
{
return
tEncodeU32
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
Enc
oder
*
pCoder
,
uint32_t
val
)
{
return
tEncodeU32
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
C
oder
*
pCoder
,
int64_t
val
)
{
return
tEncodeI64
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
Enc
oder
*
pCoder
,
int64_t
val
)
{
return
tEncodeI64
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
C
oder
*
pCoder
,
uint64_t
val
)
{
return
tEncodeU64
(
pCoder
,
val
);
}
static
int32_t
encode
(
S
Enc
oder
*
pCoder
,
uint64_t
val
)
{
return
tEncodeU64
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
C
oder
*
pCoder
,
int8_t
*
val
)
{
return
tDecodeI8
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
Dec
oder
*
pCoder
,
int8_t
*
val
)
{
return
tDecodeI8
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
C
oder
*
pCoder
,
uint8_t
*
val
)
{
return
tDecodeU8
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
Dec
oder
*
pCoder
,
uint8_t
*
val
)
{
return
tDecodeU8
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
C
oder
*
pCoder
,
int16_t
*
val
)
{
return
tDecodeI16
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
Dec
oder
*
pCoder
,
int16_t
*
val
)
{
return
tDecodeI16
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
C
oder
*
pCoder
,
uint16_t
*
val
)
{
return
tDecodeU16
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
Dec
oder
*
pCoder
,
uint16_t
*
val
)
{
return
tDecodeU16
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
C
oder
*
pCoder
,
int32_t
*
val
)
{
return
tDecodeI32
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
Dec
oder
*
pCoder
,
int32_t
*
val
)
{
return
tDecodeI32
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
C
oder
*
pCoder
,
uint32_t
*
val
)
{
return
tDecodeU32
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
Dec
oder
*
pCoder
,
uint32_t
*
val
)
{
return
tDecodeU32
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
C
oder
*
pCoder
,
int64_t
*
val
)
{
return
tDecodeI64
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
Dec
oder
*
pCoder
,
int64_t
*
val
)
{
return
tDecodeI64
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
C
oder
*
pCoder
,
uint64_t
*
val
)
{
return
tDecodeU64
(
pCoder
,
val
);
}
static
int32_t
decode
(
S
Dec
oder
*
pCoder
,
uint64_t
*
val
)
{
return
tDecodeU64
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
C
oder
*
pCoder
,
int8_t
val
)
{
return
tEncodeI8
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
Enc
oder
*
pCoder
,
int8_t
val
)
{
return
tEncodeI8
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
C
oder
*
pCoder
,
uint8_t
val
)
{
return
tEncodeU8
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
Enc
oder
*
pCoder
,
uint8_t
val
)
{
return
tEncodeU8
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
C
oder
*
pCoder
,
int16_t
val
)
{
return
tEncodeI16v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
Enc
oder
*
pCoder
,
int16_t
val
)
{
return
tEncodeI16v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
C
oder
*
pCoder
,
uint16_t
val
)
{
return
tEncodeU16v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
Enc
oder
*
pCoder
,
uint16_t
val
)
{
return
tEncodeU16v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
C
oder
*
pCoder
,
int32_t
val
)
{
return
tEncodeI32v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
Enc
oder
*
pCoder
,
int32_t
val
)
{
return
tEncodeI32v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
C
oder
*
pCoder
,
uint32_t
val
)
{
return
tEncodeU32v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
Enc
oder
*
pCoder
,
uint32_t
val
)
{
return
tEncodeU32v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
C
oder
*
pCoder
,
int64_t
val
)
{
return
tEncodeI64v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
Enc
oder
*
pCoder
,
int64_t
val
)
{
return
tEncodeI64v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
C
oder
*
pCoder
,
uint64_t
val
)
{
return
tEncodeU64v
(
pCoder
,
val
);
}
static
int32_t
encodev
(
S
Enc
oder
*
pCoder
,
uint64_t
val
)
{
return
tEncodeU64v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
C
oder
*
pCoder
,
int8_t
*
val
)
{
return
tDecodeI8
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
Dec
oder
*
pCoder
,
int8_t
*
val
)
{
return
tDecodeI8
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
C
oder
*
pCoder
,
uint8_t
*
val
)
{
return
tDecodeU8
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
Dec
oder
*
pCoder
,
uint8_t
*
val
)
{
return
tDecodeU8
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
C
oder
*
pCoder
,
int16_t
*
val
)
{
return
tDecodeI16v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
Dec
oder
*
pCoder
,
int16_t
*
val
)
{
return
tDecodeI16v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
C
oder
*
pCoder
,
uint16_t
*
val
)
{
return
tDecodeU16v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
Dec
oder
*
pCoder
,
uint16_t
*
val
)
{
return
tDecodeU16v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
C
oder
*
pCoder
,
int32_t
*
val
)
{
return
tDecodeI32v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
Dec
oder
*
pCoder
,
int32_t
*
val
)
{
return
tDecodeI32v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
C
oder
*
pCoder
,
uint32_t
*
val
)
{
return
tDecodeU32v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
Dec
oder
*
pCoder
,
uint32_t
*
val
)
{
return
tDecodeU32v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
C
oder
*
pCoder
,
int64_t
*
val
)
{
return
tDecodeI64v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
Dec
oder
*
pCoder
,
int64_t
*
val
)
{
return
tDecodeI64v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
C
oder
*
pCoder
,
uint64_t
*
val
)
{
return
tDecodeU64v
(
pCoder
,
val
);
}
static
int32_t
decodev
(
S
Dec
oder
*
pCoder
,
uint64_t
*
val
)
{
return
tDecodeU64v
(
pCoder
,
val
);
}
template
<
typename
T
>
template
<
typename
T
>
static
void
simple_encode_decode_func
(
bool
var_len
)
{
static
void
simple_encode_decode_func
(
bool
var_len
)
{
uint8_t
buf
[
BUF_SIZE
];
uint8_t
buf
[
BUF_SIZE
];
SCoder
coder
;
SEncoder
encoder
=
{
0
};
T
min_val
,
max_val
;
SDecoder
decoder
=
{
0
};
T
step
=
1
;
T
min_val
,
max_val
;
T
step
=
1
;
if
(
typeid
(
T
)
==
typeid
(
int8_t
))
{
if
(
typeid
(
T
)
==
typeid
(
int8_t
))
{
min_val
=
INT8_MIN
;
min_val
=
INT8_MIN
;
...
@@ -95,51 +96,51 @@ static void simple_encode_decode_func(bool var_len) {
...
@@ -95,51 +96,51 @@ static void simple_encode_decode_func(bool var_len) {
// Encode NULL
// Encode NULL
for
(
td_endian_t
endian
:
endian_arr
)
{
for
(
td_endian_t
endian
:
endian_arr
)
{
t
CoderInit
(
&
coder
,
endian
,
NULL
,
0
,
TD_ENCODER
);
t
EncoderInit
(
&
en
coder
,
endian
,
NULL
,
0
,
TD_ENCODER
);
if
(
var_len
)
{
if
(
var_len
)
{
GTEST_ASSERT_EQ
(
encodev
(
&
coder
,
i
),
0
);
GTEST_ASSERT_EQ
(
encodev
(
&
en
coder
,
i
),
0
);
}
else
{
}
else
{
GTEST_ASSERT_EQ
(
encode
(
&
coder
,
i
),
0
);
GTEST_ASSERT_EQ
(
encode
(
&
en
coder
,
i
),
0
);
GTEST_ASSERT_EQ
(
coder
.
pos
,
sizeof
(
T
));
GTEST_ASSERT_EQ
(
en
coder
.
pos
,
sizeof
(
T
));
}
}
tCoderClear
(
&
coder
);
tCoderClear
(
&
en
coder
);
}
}
// Encode and decode
// Encode and decode
for
(
td_endian_t
e_endian
:
endian_arr
)
{
for
(
td_endian_t
e_endian
:
endian_arr
)
{
for
(
td_endian_t
d_endian
:
endian_arr
)
{
for
(
td_endian_t
d_endian
:
endian_arr
)
{
// Encode
// Encode
tCoderInit
(
&
coder
,
e_endian
,
buf
,
BUF_SIZE
,
TD_ENCODER
);
tCoderInit
(
&
en
coder
,
e_endian
,
buf
,
BUF_SIZE
,
TD_ENCODER
);
if
(
var_len
)
{
if
(
var_len
)
{
GTEST_ASSERT_EQ
(
encodev
(
&
coder
,
i
),
0
);
GTEST_ASSERT_EQ
(
encodev
(
&
en
coder
,
i
),
0
);
}
else
{
}
else
{
GTEST_ASSERT_EQ
(
encode
(
&
coder
,
i
),
0
);
GTEST_ASSERT_EQ
(
encode
(
&
en
coder
,
i
),
0
);
GTEST_ASSERT_EQ
(
coder
.
pos
,
sizeof
(
T
));
GTEST_ASSERT_EQ
(
en
coder
.
pos
,
sizeof
(
T
));
}
}
int32_t
epos
=
coder
.
pos
;
int32_t
epos
=
en
coder
.
pos
;
tCoderClear
(
&
coder
);
tCoderClear
(
&
en
coder
);
// Decode
// Decode
tCoderInit
(
&
coder
,
d_endian
,
buf
,
BUF_SIZE
,
TD_DECODER
);
tCoderInit
(
&
en
coder
,
d_endian
,
buf
,
BUF_SIZE
,
TD_DECODER
);
if
(
var_len
)
{
if
(
var_len
)
{
GTEST_ASSERT_EQ
(
decodev
(
&
coder
,
&
dval
),
0
);
GTEST_ASSERT_EQ
(
decodev
(
&
en
coder
,
&
dval
),
0
);
}
else
{
}
else
{
GTEST_ASSERT_EQ
(
decode
(
&
coder
,
&
dval
),
0
);
GTEST_ASSERT_EQ
(
decode
(
&
en
coder
,
&
dval
),
0
);
GTEST_ASSERT_EQ
(
coder
.
pos
,
sizeof
(
T
));
GTEST_ASSERT_EQ
(
en
coder
.
pos
,
sizeof
(
T
));
}
}
GTEST_ASSERT_EQ
(
coder
.
pos
,
epos
);
GTEST_ASSERT_EQ
(
en
coder
.
pos
,
epos
);
if
(
typeid
(
T
)
==
typeid
(
int8_t
)
||
typeid
(
T
)
==
typeid
(
uint8_t
)
||
e_endian
==
d_endian
)
{
if
(
typeid
(
T
)
==
typeid
(
int8_t
)
||
typeid
(
T
)
==
typeid
(
uint8_t
)
||
e_endian
==
d_endian
)
{
GTEST_ASSERT_EQ
(
i
,
dval
);
GTEST_ASSERT_EQ
(
i
,
dval
);
}
}
tCoderClear
(
&
coder
);
tCoderClear
(
&
en
coder
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录