Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
221c8254
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看板
提交
221c8254
编写于
12月 27, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
6c0c1b22
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
201 addition
and
126 deletion
+201
-126
include/common/tmsg.h
include/common/tmsg.h
+12
-1
include/util/tcoding.h
include/util/tcoding.h
+189
-125
未找到文件。
include/common/tmsg.h
浏览文件 @
221c8254
...
...
@@ -1127,6 +1127,17 @@ typedef struct SVCreateTbReq {
static
FORCE_INLINE
int
tSerializeSVCreateTbReq
(
void
**
buf
,
const
SVCreateTbReq
*
pReq
)
{
int
tlen
=
0
;
uint8_t
*
pBuf
=
(
uint8_t
*
)(
*
buf
);
if
(
TD_RT_ENDIAN
()
==
TD_LITTLE_ENDIAN
)
{
pBuf
+=
tPut
(
pBuf
,
pReq
->
ver
,
uint64_t
);
pBuf
+=
tPut
(
pBuf
,
pReq
->
ttl
,
uint32_t
);
pBuf
+=
tPut
(
pBuf
,
pReq
->
keep
,
uint32_t
);
}
else
{
pBuf
+=
tPutl
(
pBuf
,
pReq
->
ver
,
uint64_t
);
pBuf
+=
tPutl
(
pBuf
,
pReq
->
ttl
,
uint32_t
);
pBuf
+=
tPutl
(
pBuf
,
pReq
->
keep
,
uint32_t
);
}
tlen
+=
taosEncodeFixedU64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
...
...
include/util/tcoding.h
浏览文件 @
221c8254
...
...
@@ -26,159 +26,223 @@ extern "C" {
#define ZIGZAGD(T, v) ((v) >> 1) ^ -((T)((v)&1)) // zigzag decode
/* ------------------------ FIXED-LENGTH ENCODING ------------------------ */
#define tPut(T, b, v) \
({ \
*(T *)(b) = (v); \
sizeof(T); \
})
#define tGet(T, b, v) \
({ \
(v) = (*(T *)(b)); \
sizeof(T); \
})
// 16
#define tPut16b(
b, v
) \
#define tPut16b(
BUF, VAL
) \
({ \
((uint8_t *)(
b))[1] = (v
)&0xff; \
((uint8_t *)(
b))[0] = ((v
) >> 8) & 0xff; \
((uint8_t *)(
BUF))[1] = (VAL
)&0xff; \
((uint8_t *)(
BUF))[0] = ((VAL
) >> 8) & 0xff; \
2; \
})
#define tGet16b(
b, v
) \
#define tGet16b(
BUF, VAL
) \
({ \
(
v) = ((uint8_t *)(b
))[0]; \
(
v) = (v
) << 8; \
(
v) |= ((uint8_t *)(b
))[1]; \
(
VAL) = ((uint8_t *)(BUF
))[0]; \
(
VAL) = (VAL
) << 8; \
(
VAL) |= ((uint8_t *)(BUF
))[1]; \
2; \
})
#define tPut16l(
b, v
) \
#define tPut16l(
BUF, VAL
) \
({ \
((uint8_t *)(
b))[0] = (v
)&0xff; \
((uint8_t *)(
b))[1] = ((v
) >> 8) & 0xff; \
((uint8_t *)(
BUF))[0] = (VAL
)&0xff; \
((uint8_t *)(
BUF))[1] = ((VAL
) >> 8) & 0xff; \
2; \
})
#define tGet16l(
b, v
) \
#define tGet16l(
BUF, VAL
) \
({ \
(
v) = ((uint8_t *)(b
))[1]; \
(
v) <<= 8;
\
(
v) |= ((uint8_t *)(b
))[0]; \
(
VAL) = ((uint8_t *)(BUF
))[1]; \
(
VAL) <<= 8;
\
(
VAL) |= ((uint8_t *)(BUF
))[0]; \
2; \
})
// 32
#define tPut32b(
b, v
) \
#define tPut32b(
BUF, VAL
) \
({ \
((uint8_t *)(
b))[3] = (v
)&0xff; \
((uint8_t *)(
b))[2] = ((v
) >> 8) & 0xff; \
((uint8_t *)(
b))[1] = ((v
) >> 16) & 0xff; \
((uint8_t *)(
b))[0] = ((v
) >> 24) & 0xff; \
((uint8_t *)(
BUF))[3] = (VAL
)&0xff; \
((uint8_t *)(
BUF))[2] = ((VAL
) >> 8) & 0xff; \
((uint8_t *)(
BUF))[1] = ((VAL
) >> 16) & 0xff; \
((uint8_t *)(
BUF))[0] = ((VAL
) >> 24) & 0xff; \
4; \
})
#define tGet32b(
b, v
) \
#define tGet32b(
BUF, VAL
) \
({ \
(
v) = ((uint8_t *)(b
))[0]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[1]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[2]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[3]; \
(
VAL) = ((uint8_t *)(BUF
))[0]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[1]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[2]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[3]; \
4; \
})
#define tPut32l(
b, v
) \
#define tPut32l(
BUF, VAL
) \
({ \
((uint8_t *)(
b))[0] = (v
)&0xff; \
((uint8_t *)(
b))[1] = ((v
) >> 8) & 0xff; \
((uint8_t *)(
b))[2] = ((v
) >> 16) & 0xff; \
((uint8_t *)(
b))[3] = ((v
) >> 24) & 0xff; \
((uint8_t *)(
BUF))[0] = (VAL
)&0xff; \
((uint8_t *)(
BUF))[1] = ((VAL
) >> 8) & 0xff; \
((uint8_t *)(
BUF))[2] = ((VAL
) >> 16) & 0xff; \
((uint8_t *)(
BUF))[3] = ((VAL
) >> 24) & 0xff; \
4; \
})
#define tGet32l(
b, v
) \
#define tGet32l(
BUF, VAL
) \
({ \
(
v) = ((uint8_t *)(b
))[3]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[2]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[1]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[0]; \
(
VAL) = ((uint8_t *)(BUF
))[3]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[2]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[1]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[0]; \
4; \
})
// 64
#define tPut64b(
b, v
) \
#define tPut64b(
BUF, VAL
) \
({ \
((uint8_t *)(
b))[7] = (v
)&0xff; \
((uint8_t *)(
b))[6] = ((v
) >> 8) & 0xff; \
((uint8_t *)(
b))[5] = ((v
) >> 16) & 0xff; \
((uint8_t *)(
b))[4] = ((v
) >> 24) & 0xff; \
((uint8_t *)(
b))[3] = ((v
) >> 32) & 0xff; \
((uint8_t *)(
b))[2] = ((v
) >> 40) & 0xff; \
((uint8_t *)(
b))[1] = ((v
) >> 48) & 0xff; \
((uint8_t *)(
b))[0] = ((v
) >> 56) & 0xff; \
((uint8_t *)(
BUF))[7] = (VAL
)&0xff; \
((uint8_t *)(
BUF))[6] = ((VAL
) >> 8) & 0xff; \
((uint8_t *)(
BUF))[5] = ((VAL
) >> 16) & 0xff; \
((uint8_t *)(
BUF))[4] = ((VAL
) >> 24) & 0xff; \
((uint8_t *)(
BUF))[3] = ((VAL
) >> 32) & 0xff; \
((uint8_t *)(
BUF))[2] = ((VAL
) >> 40) & 0xff; \
((uint8_t *)(
BUF))[1] = ((VAL
) >> 48) & 0xff; \
((uint8_t *)(
BUF))[0] = ((VAL
) >> 56) & 0xff; \
8; \
})
#define tGet64b(
b, v
) \
#define tGet64b(
BUF, VAL
) \
({ \
(
v) = ((uint8_t *)(b
))[0]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[1]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[2]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[3]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[4]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[5]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[6]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[7]; \
(
VAL) = ((uint8_t *)(BUF
))[0]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[1]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[2]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[3]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[4]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[5]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[6]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[7]; \
8; \
})
#define tPut64l(
b, v
) \
#define tPut64l(
BUF, VAL
) \
({ \
((uint8_t *)(
b))[0] = (v
)&0xff; \
((uint8_t *)(
b))[1] = ((v
) >> 8) & 0xff; \
((uint8_t *)(
b))[2] = ((v
) >> 16) & 0xff; \
((uint8_t *)(
b))[3] = ((v
) >> 24) & 0xff; \
((uint8_t *)(
b))[4] = ((v
) >> 32) & 0xff; \
((uint8_t *)(
b))[5] = ((v
) >> 40) & 0xff; \
((uint8_t *)(
b))[6] = ((v
) >> 48) & 0xff; \
((uint8_t *)(
b))[7] = ((v
) >> 56) & 0xff; \
((uint8_t *)(
BUF))[0] = (VAL
)&0xff; \
((uint8_t *)(
BUF))[1] = ((VAL
) >> 8) & 0xff; \
((uint8_t *)(
BUF))[2] = ((VAL
) >> 16) & 0xff; \
((uint8_t *)(
BUF))[3] = ((VAL
) >> 24) & 0xff; \
((uint8_t *)(
BUF))[4] = ((VAL
) >> 32) & 0xff; \
((uint8_t *)(
BUF))[5] = ((VAL
) >> 40) & 0xff; \
((uint8_t *)(
BUF))[6] = ((VAL
) >> 48) & 0xff; \
((uint8_t *)(
BUF))[7] = ((VAL
) >> 56) & 0xff; \
8; \
})
#define tGet64l(
b, v
) \
#define tGet64l(
BUF, VAL
) \
({ \
(
v) = ((uint8_t *)(b
))[7]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[6]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[5]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[4]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[3]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[2]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[1]; \
(
v) <<= 8;
\
(
v) = ((uint8_t *)(b
))[0]; \
(
VAL) = ((uint8_t *)(BUF
))[7]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[6]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[5]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[4]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[3]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[2]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[1]; \
(
VAL) <<= 8;
\
(
VAL) = ((uint8_t *)(BUF
))[0]; \
8; \
})
#define tPut(BUF, VAL, TYPE) \
({ \
*(TYPE *)(BUF) = (VAL); \
sizeof(TYPE); \
})
#define tGet(BUF, VAL, TYPE) \
({ \
(VAL) = (*(TYPE *)(BUF)); \
sizeof(TYPE); \
})
#define tPut_uint16_t_l(BUF, VAL, TYPE) tPut16l(BUF, VAL)
#define tGet_uint16_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL)
#define tPut_int16_t_l(BUF, VAL, TYPE) tPut16l(BUF, VAL)
#define tGet_int16_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL)
#define tPut_uint32_t_l(BUF, VAL, TYPE) tPut32l(BUF, VAL)
#define tGet_uint32_t_l(BUF, VAL, TYPE) tGet32l(BUF, VAL)
#define tPut_int32_t_l(BUF, VAL, TYPE) tPut32l(BUF, VAL)
#define tGet_int32_t_l(BUF, VAL, TYPE) tGet32l(BUF, VAL)
#define tPut_uint64_t_l(BUF, VAL, TYPE) tPut64l(BUF, VAL)
#define tGet_uint64_t_l(BUF, VAL, TYPE) tGet64l(BUF, VAL)
#define tPut_int64_t_l(BUF, VAL, TYPE) tPut64l(BUF, VAL)
#define tGet_int64_t_l(BUF, VAL, TYPE) tGet64l(BUF, VAL)
#define tPut_uint16_t_b(BUF, VAL, TYPE) tPut16b(BUF, VAL)
#define tGet_uint16_t_b(BUF, VAL, TYPE) tGet16b(BUF, VAL)
#define tPut_int16_t_b(BUF, VAL, TYPE) tPut16b(BUF, VAL)
#define tGet_int16_t_b(BUF, VAL, TYPE) tGet16b(BUF, VAL)
#define tPut_uint32_t_b(BUF, VAL, TYPE) tPut32b(BUF, VAL)
#define tGet_uint32_t_b(BUF, VAL, TYPE) tGet32b(BUF, VAL)
#define tPut_int32_t_b(BUF, VAL, TYPE) tPut32b(BUF, VAL)
#define tGet_int32_t_b(BUF, VAL, TYPE) tGet32b(BUF, VAL)
#define tPut_uint64_t_b(BUF, VAL, TYPE) tPut64b(BUF, VAL)
#define tGet_uint64_t_b(BUF, VAL, TYPE) tGet64b(BUF, VAL)
#define tPut_int64_t_b(BUF, VAL, TYPE) tPut64b(BUF, VAL)
#define tGet_int64_t_b(BUF, VAL, TYPE) tGet64b(BUF, VAL)
#define tPutl(BUF, VAL, TYPE) tPut_##TYPE##_l(BUF, VAL, TYPE)
#define tGetl(BUF, VAL, TYPE) tGet_##TYPE##_l(BUF, VAL, TYPE)
#define tPutb(BUF, VAL, TYPE) tPut_##TYPE##_b(BUF, VAL, TYPE)
#define tGetb(BUF, VAL, TYPE) tGet_##TYPE##_b(BUF, VAL, TYPE)
/* ------------------------ VARIANT-LENGTH ENCODING ------------------------ */
#define vPutU(BUF, VAL) \
({ \
uint64_t tmp = (VAL); \
int i = 0; \
while ((VAL) >= ENCODE_LIMIT) { \
((uint8_t *)(BUF))[i] = (uint8_t)((tmp) | ENCODE_LIMIT); \
(tmp) >>= 7; \
i++; \
} \
((uint8_t *)(BUF))[i] = (uint8_t)(tmp); \
i + 1; \
})
#define vGetU(BUF, VAL)
#define vPutI(BUF, VAL, TYPE) \
({ \
uint64_t tmp = ZIGZAGE(TYPE, VAL); \
vPutU(BUF, tmp); \
})
#define vGetI(BUF, VAL, TYPE)
/* ------------------------ OTHER TYPE ENCODING ------------------------ */
/* ------------------------ LEGACY CODES ------------------------ */
#if 1
// ---- Fixed U8
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录