Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6c0c1b22
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
6c0c1b22
编写于
12月 27, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
c5b42e57
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
189 addition
and
3 deletion
+189
-3
contrib/test/tdev/src/main.c
contrib/test/tdev/src/main.c
+26
-1
include/os/osEndian.h
include/os/osEndian.h
+3
-0
include/util/tcoding.h
include/util/tcoding.h
+158
-0
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+2
-2
未找到文件。
contrib/test/tdev/src/main.c
浏览文件 @
6c0c1b22
...
...
@@ -14,6 +14,10 @@
#define tPutB(buf, val) \
({ \
((uint8_t *)buf)[7] = ((val) >> 56) & 0xff; \
((uint8_t *)buf)[6] = ((val) >> 48) & 0xff; \
((uint8_t *)buf)[5] = ((val) >> 40) & 0xff; \
((uint8_t *)buf)[4] = ((val) >> 32) & 0xff; \
((uint8_t *)buf)[3] = ((val) >> 24) & 0xff; \
((uint8_t *)buf)[2] = ((val) >> 16) & 0xff; \
((uint8_t *)buf)[1] = ((val) >> 8) & 0xff; \
...
...
@@ -27,7 +31,17 @@
POINTER_SHIFT(buf, sizeof(val)); \
})
typedef
enum
{
A
,
B
,
C
}
T
;
#define tPutD(buf, val) \
({ \
uint64_t tmp = val; \
for (size_t i = 0; i < sizeof(val); i++) { \
((uint8_t *)buf)[i] = tmp & 0xff; \
tmp >>= 8; \
} \
POINTER_SHIFT(buf, sizeof(val)); \
})
typedef
enum
{
A
,
B
,
C
,
D
}
T
;
static
void
func
(
T
t
)
{
uint64_t
val
=
198
;
...
...
@@ -59,6 +73,14 @@ static void func(T t) {
}
}
break
;
case
D
:
for
(
size_t
i
=
0
;
i
<
10
*
1024l
*
1024l
*
1024l
;
i
++
)
{
pBuf
=
tPutD
(
pBuf
,
val
);
if
(
POINTER_DISTANCE
(
buf
,
pBuf
)
==
1024
)
{
pBuf
=
buf
;
}
}
break
;
default:
break
;
...
...
@@ -83,5 +105,8 @@ int main(int argc, char const *argv[]) {
func
(
C
);
uint64_t
t4
=
now
();
printf
(
"C: %ld
\n
"
,
t4
-
t3
);
func
(
D
);
uint64_t
t5
=
now
();
printf
(
"D: %ld
\n
"
,
t5
-
t4
);
return
0
;
}
include/os/osEndian.h
浏览文件 @
6c0c1b22
...
...
@@ -20,8 +20,11 @@
extern
"C"
{
#endif
typedef
enum
{
TD_LITTLE_ENDIAN
=
0
,
TD_BIG_ENDIAN
}
td_endian_t
;
static
const
int32_t
endian_test_var
=
1
;
#define IS_LITTLE_ENDIAN() (*(uint8_t *)(&endian_test_var) != 0)
#define TD_RT_ENDIAN() (IS_LITTLE_ENDIAN() ? TD_LITTLE_ENDIAN : TD_BIG_ENDIAN)
#ifdef __cplusplus
}
...
...
include/util/tcoding.h
浏览文件 @
6c0c1b22
...
...
@@ -25,6 +25,162 @@ extern "C" {
#define ZIGZAGE(T, v) ((u##T)((v) >> (sizeof(T) * 8 - 1))) ^ (((u##T)(v)) << 1) // zigzag encode
#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) \
({ \
((uint8_t *)(b))[1] = (v)&0xff; \
((uint8_t *)(b))[0] = ((v) >> 8) & 0xff; \
2; \
})
#define tGet16b(b, v) \
({ \
(v) = ((uint8_t *)(b))[0]; \
(v) = (v) << 8; \
(v) |= ((uint8_t *)(b))[1]; \
2; \
})
#define tPut16l(b, v) \
({ \
((uint8_t *)(b))[0] = (v)&0xff; \
((uint8_t *)(b))[1] = ((v) >> 8) & 0xff; \
2; \
})
#define tGet16l(b, v) \
({ \
(v) = ((uint8_t *)(b))[1]; \
(v) <<= 8; \
(v) |= ((uint8_t *)(b))[0]; \
2; \
})
// 32
#define tPut32b(b, v) \
({ \
((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; \
4; \
})
#define tGet32b(b, v) \
({ \
(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]; \
4; \
})
#define tPut32l(b, v) \
({ \
((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; \
4; \
})
#define tGet32l(b, v) \
({ \
(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]; \
4; \
})
// 64
#define tPut64b(b, v) \
({ \
((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; \
8; \
})
#define tGet64b(b, v) \
({ \
(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]; \
8; \
})
#define tPut64l(b, v) \
({ \
((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; \
8; \
})
#define tGet64l(b, v) \
({ \
(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]; \
8; \
})
/* ------------------------ LEGACY CODES ------------------------ */
#if 1
// ---- Fixed U8
static
FORCE_INLINE
int
taosEncodeFixedU8
(
void
**
buf
,
uint8_t
value
)
{
if
(
buf
!=
NULL
)
{
...
...
@@ -368,6 +524,8 @@ static FORCE_INLINE void *taosDecodeStringTo(void *buf, char *value) {
return
POINTER_SHIFT
(
buf
,
size
);
}
#endif
#ifdef __cplusplus
}
#endif
...
...
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
6c0c1b22
...
...
@@ -403,10 +403,10 @@ static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) {
buf
=
taosDecodeFixedU8
(
buf
,
&
(
pTbCfg
->
type
));
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
buf
=
taosDecodeVariantU32
(
buf
,
pTbCfg
->
stbCfg
.
nTagCols
);
buf
=
taosDecodeVariantU32
(
buf
,
&
(
pTbCfg
->
stbCfg
.
nTagCols
)
);
pTbCfg
->
stbCfg
.
pTagSchema
=
(
SSchema
*
)
malloc
(
sizeof
(
SSchema
)
*
pTbCfg
->
stbCfg
.
nTagCols
);
for
(
uint32_t
i
=
0
;
i
<
pTbCfg
->
stbCfg
.
nTagCols
;
i
++
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pTbCfg
->
stbCfg
.
pSchema
[
i
].
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pTbCfg
->
stbCfg
.
pSchema
[
i
].
type
)
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pTbCfg
->
stbCfg
.
pSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pTbCfg
->
stbCfg
.
pSchema
[
i
].
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
pTbCfg
->
stbCfg
.
pSchema
[
i
].
name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录