Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a32fa005
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a32fa005
编写于
12月 28, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
070562ae
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
3 deletion
+41
-3
include/util/encode.h
include/util/encode.h
+41
-3
未找到文件。
include/util/encode.h
浏览文件 @
a32fa005
...
...
@@ -16,7 +16,7 @@
#ifndef _TD_UTIL_ENCODE_H_
#define _TD_UTIL_ENCODE_H_
#include "
os
.h"
#include "
tcoding
.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -162,11 +162,11 @@ static FORCE_INLINE int tEncodeU64(SEncoder* pEncoder, uint64_t val) {
return
0
;
}
static
FORCE_INLINE
int
tEncodeI
32
(
SEncoder
*
pEncoder
,
int32
_t
val
)
{
static
FORCE_INLINE
int
tEncodeI
64
(
SEncoder
*
pEncoder
,
int64
_t
val
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
sizeof
(
val
)))
return
-
1
;
if
(
TD_RT_ENDIAN
()
==
pEncoder
->
endian
)
{
tPut
(
int
32
_t
,
TD_CODER_CURRENT
(
pEncoder
),
val
);
tPut
(
int
64
_t
,
TD_CODER_CURRENT
(
pEncoder
),
val
);
}
else
{
tRPut64
(
TD_CODER_CURRENT
(
pEncoder
),
&
val
);
}
...
...
@@ -175,6 +175,44 @@ static FORCE_INLINE int tEncodeI32(SEncoder* pEncoder, int32_t val) {
return
0
;
}
static
FORCE_INLINE
int
tEncodeU16v
(
SEncoder
*
pEncoder
,
uint16_t
val
)
{
int64_t
i
=
0
;
while
(
val
>=
ENCODE_LIMIT
)
{
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
1
))
return
-
1
;
TD_CODER_CURRENT
(
pEncoder
)[
i
]
=
(
uint8_t
)(
val
|
ENCODE_LIMIT
)
}
val
>>=
7
;
i
++
;
}
if
(
pEncoder
->
data
)
{
if
(
TD_CHECK_CODER_CAPACITY_FAILED
(
pEncoder
,
1
))
return
-
1
;
TD_CODER_CURRENT
(
pEncoder
)[
i
]
=
(
uint8_t
)
val
;
}
TD_CODER_MOVE_POS
(
pEncoder
,
i
+
1
);
return
0
;
}
static
FORCE_INLINE
int
tEncodeI16v
(
SEncoder
*
pEncoder
,
int16_t
val
)
{
return
tEncodeU16v
(
pEncoder
,
ZIGZAGE
(
val
));
}
static
FORCE_INLINE
int
tEncodeU32v
(
SEncoder
*
pEncoder
,
uint32_t
val
)
{
// TODO
return
0
;
}
static
FORCE_INLINE
int
tEncodeI32v
(
SEncoder
*
pEncoder
,
int32_t
val
)
{
return
tEncodeU32v
(
pEncoder
,
ZIGZAGE
(
val
));
}
static
FORCE_INLINE
int
tEncodeU64v
(
SEncoder
*
pEncoder
,
uint64_t
val
)
{
// TODO
return
0
;
}
static
FORCE_INLINE
int
tEncodeI64v
(
SEncoder
*
pEncoder
,
int64_t
val
)
{
return
tEncodeU64v
(
pEncoder
,
ZIGZAGE
(
val
));
}
/* ------------------------ FOR DECODER ------------------------ */
static
FORCE_INLINE
void
tInitDecoder
(
SDecoder
*
pDecoder
,
td_endian_t
endian
,
const
uint8_t
*
data
,
int64_t
size
)
{
ASSERT
(
!
TD_IS_NULL
(
data
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录