Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0ff451dc
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
“2a974f92ca876d5fcb3743bfc84fd10c620e5bb6”上不存在“docs/zh/21-tdinternal/01-arch.md”
提交
0ff451dc
编写于
9月 16, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
5ffaaeba
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
23 deletion
+60
-23
source/dnode/vnode/src/tsdb/tsdbCompress.c
source/dnode/vnode/src/tsdb/tsdbCompress.c
+60
-23
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCompress.c
浏览文件 @
0ff451dc
...
...
@@ -36,6 +36,9 @@ typedef struct {
struct
{
int8_t
i_copy
;
int32_t
i_n
;
int64_t
i_prev
;
int32_t
i_selector
;
int32_t
i_nele
;
};
// Float ----
struct
{
...
...
@@ -188,38 +191,72 @@ _copy_exit:
// Integer =====================================================
#define SIMPLE8B_MAX ((uint64_t)1152921504606846974LL)
static
const
char
bit_per_integer
[]
=
{
0
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
10
,
12
,
15
,
20
,
30
,
60
};
static
const
int32_t
selector_to_elems
[]
=
{
240
,
120
,
60
,
30
,
20
,
15
,
12
,
10
,
8
,
7
,
6
,
5
,
4
,
3
,
2
,
1
};
static
const
char
bit_to_selector
[]
=
{
0
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
10
,
11
,
11
,
12
,
12
,
12
,
13
,
13
,
13
,
13
,
13
,
14
,
14
,
14
,
14
,
14
,
14
,
14
,
14
,
14
,
14
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
,
15
};
static
int32_t
tCompI64
(
SCompressor
*
pCmprsor
,
int64_t
val
)
{
int32_t
code
=
0
;
#if 0
// raw copy
if (pCmprsor->rawCopy) {
memcpy(pCmprsor->pBuf + pCmprsor->nBuf, &val, sizeof(val));
pCmprsor->nBuf += sizeof(val);
pCmprsor->nVal++;
goto _exit;
if
(
pCmprsor
->
i_copy
==
1
)
goto
_copy_cmpr
;
if
(
!
I64_SAFE_ADD
(
val
,
pCmprsor
->
i_prev
))
{
// TODO
goto
_copy_cmpr
;
}
if (!I64_SAFE_ADD(val, pCmprsor->prevVal)) {
pCmprsor->rawCopy = 1;
// TODO: decompress and copy
pCmprsor->nVal++;
goto _exit;
int64_t
diff
=
val
-
pCmprsor
->
i_prev
;
uint64_t
vZigzag
=
ZIGZAGE
(
int64_t
,
diff
);
if
(
vZigzag
>=
SIMPLE8B_MAX
)
{
// TODO
goto
_copy_cmpr
;
}
int64_t diff = val - pCmprsor->prevVal;
uint8_t zigzag = ZIGZAGE(int64_t, diff);
int64_t
nBit
;
if
(
vZigzag
)
{
nBit
=
64
-
BUILDIN_CLZL
(
vZigzag
);
}
else
{
nBit
=
0
;
}
if (zigzag >= SIMPLE8B_MAX) {
pCmprsor->rawCopy = 1;
// TODO: decompress and copy
pCmprsor->nVal++;
goto _exit;
if
(
pCmprsor
->
i_nele
+
1
<=
selector_to_elems
[
pCmprsor
->
i_selector
]
&&
pCmprsor
->
i_nele
+
1
<=
selector_to_elems
[
bit_to_selector
[
nBit
]])
{
if
(
pCmprsor
->
i_selector
<
bit_to_selector
[
nBit
])
{
pCmprsor
->
i_selector
=
bit_to_selector
[
nBit
];
}
pCmprsor
->
i_nele
++
;
}
else
{
while
(
pCmprsor
->
i_nele
<
selector_to_elems
[
pCmprsor
->
i_selector
])
{
pCmprsor
->
i_selector
++
;
}
pCmprsor
->
i_nele
=
selector_to_elems
[
pCmprsor
->
i_selector
];
code
=
tRealloc
(
&
pCmprsor
->
aBuf
[
0
],
pCmprsor
->
nBuf
[
0
]
+
sizeof
(
uint64_t
));
if
(
code
)
return
code
;
uint64_t
*
bp
=
pCmprsor
->
aBuf
[
0
]
+
pCmprsor
->
nBuf
[
0
];
pCmprsor
->
nBuf
[
0
]
+=
sizeof
(
uint64_t
);
bp
[
0
]
=
pCmprsor
->
i_selector
;
for
(
int32_t
iVal
=
0
;
iVal
<
pCmprsor
->
i_nele
;
iVal
++
)
{
/* code */
}
// reset and continue
}
_exit:
#endif
return
code
;
_copy_cmpr:
code
=
tRealloc
(
&
pCmprsor
->
aBuf
[
0
],
pCmprsor
->
nBuf
[
0
]
+
tDataTypes
[
pCmprsor
->
type
].
bytes
);
if
(
code
)
return
code
;
memcpy
(
pCmprsor
->
aBuf
[
0
]
+
pCmprsor
->
nBuf
[
0
],
NULL
/* todo */
,
tDataTypes
[
pCmprsor
->
type
].
bytes
);
pCmprsor
->
nBuf
[
0
]
+=
tDataTypes
[
pCmprsor
->
type
].
bytes
;
return
code
;
}
...
...
@@ -294,8 +331,8 @@ static int32_t tCompDouble(SCompressor *pCmprsor, double d) {
int32_t
clz
,
ctz
;
if
(
diff
)
{
clz
=
BUILDIN_CLZ
(
diff
);
ctz
=
BUILDIN_CTZ
(
diff
);
clz
=
BUILDIN_CLZ
L
(
diff
);
ctz
=
BUILDIN_CTZ
L
(
diff
);
}
else
{
clz
=
sizeof
(
uint64_t
);
ctz
=
sizeof
(
uint64_t
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录