Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
9c53131c
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9c53131c
编写于
7月 08, 2021
作者:
T
tickduan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed mst99
上级
c3497023
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
1 addition
and
168 deletion
+1
-168
deps/SZ/sz/src/ByteToolkit.c
deps/SZ/sz/src/ByteToolkit.c
+1
-1
deps/SZ/sz/src/Huffman.c
deps/SZ/sz/src/Huffman.c
+0
-167
未找到文件。
deps/SZ/sz/src/ByteToolkit.c
浏览文件 @
9c53131c
...
@@ -98,7 +98,7 @@ inline long bytesToLong_bigEndian(unsigned char* b) {
...
@@ -98,7 +98,7 @@ inline long bytesToLong_bigEndian(unsigned char* b) {
inline
void
longToBytes_bigEndian
(
unsigned
char
*
b
,
unsigned
long
num
)
inline
void
longToBytes_bigEndian
(
unsigned
char
*
b
,
unsigned
long
num
)
{
{
// arm32
// arm32
#if defined(_TD_LINUX_64) || defined(_TD_
MIPS_64) || defined(_TD_
ARM_64) || defined(_TD_DARWIN_64)
#if defined(_TD_LINUX_64) || defined(_TD_ARM_64) || defined(_TD_DARWIN_64)
b
[
0
]
=
(
unsigned
char
)(
num
>>
56
);
b
[
0
]
=
(
unsigned
char
)(
num
>>
56
);
b
[
1
]
=
(
unsigned
char
)(
num
>>
48
);
b
[
1
]
=
(
unsigned
char
)(
num
>>
48
);
b
[
2
]
=
(
unsigned
char
)(
num
>>
40
);
b
[
2
]
=
(
unsigned
char
)(
num
>>
40
);
...
...
deps/SZ/sz/src/Huffman.c
浏览文件 @
9c53131c
...
@@ -342,103 +342,6 @@ void decode(unsigned char *s, size_t targetLength, node t, int *out)
...
@@ -342,103 +342,6 @@ void decode(unsigned char *s, size_t targetLength, node t, int *out)
return
;
return
;
}
}
void
decode_MSST19
(
unsigned
char
*
s
,
size_t
targetLength
,
node
t
,
int
*
out
,
int
maxBits
)
{
size_t
count
=
0
;
node
n
=
t
;
if
(
n
->
t
)
//root->t==1 means that all state values are the same (constant)
{
for
(
count
=
0
;
count
<
targetLength
;
count
++
)
out
[
count
]
=
n
->
c
;
return
;
}
if
(
maxBits
>
16
){
maxBits
=
16
;
}
int
tableSize
=
1
<<
maxBits
;
int
*
valueTable
=
(
int
*
)
malloc
(
tableSize
*
sizeof
(
int
));
uint8_t
*
lengthTable
=
(
uint8_t
*
)
malloc
(
tableSize
*
sizeof
(
int
));
node
*
nodeTable
=
(
node
*
)
malloc
(
tableSize
*
sizeof
(
node
));
uint32_t
maskTable
[
maxBits
+
8
];
int
j
;
for
(
uint32_t
i
=
0
;
i
<
tableSize
;
i
++
){
n
=
t
;
j
=
0
;
while
(
!
n
->
t
&&
j
<
maxBits
){
uint32_t
res
=
i
>>
(
maxBits
-
j
-
1
);
if
((
res
&
0x00000001
)
==
0
){
n
=
n
->
left
;
}
else
{
n
=
n
->
right
;
}
j
++
;
}
if
(
!
n
->
t
){
nodeTable
[
i
]
=
n
;
valueTable
[
i
]
=
-
1
;
lengthTable
[
i
]
=
maxBits
;
}
else
{
valueTable
[
i
]
=
n
->
c
;
lengthTable
[
i
]
=
j
;
}
}
for
(
int
i
=
0
;
i
<
maxBits
+
8
;
i
++
){
maskTable
[
i
]
=
(
1
<<
(
maxBits
+
8
-
i
-
1
))
-
1
;
}
int
leftBits
=
0
;
uint32_t
currentValue
=
0
;
size_t
i
=
0
;
while
(
count
<
targetLength
)
{
while
(
leftBits
<
maxBits
){
currentValue
=
currentValue
<<
8
;
currentValue
+=
s
[
i
];
leftBits
+=
8
;
i
++
;
}
uint32_t
index
=
currentValue
>>
(
leftBits
-
maxBits
);
int
value
=
valueTable
[
index
];
if
(
value
!=
-
1
){
out
[
count
]
=
value
;
int
bitLength
=
lengthTable
[
index
];
leftBits
-=
bitLength
;
uint32_t
avoidHeadMask
=
maskTable
[
maxBits
+
8
-
leftBits
-
1
];
currentValue
=
(
currentValue
&
avoidHeadMask
);
count
++
;
}
else
{
int
bitLength
=
lengthTable
[
index
];
leftBits
-=
bitLength
;
n
=
nodeTable
[
index
];
while
(
!
n
->
t
){
if
(
!
leftBits
){
currentValue
=
currentValue
<<
8
;
currentValue
+=
s
[
i
];
leftBits
+=
8
;
i
++
;
}
if
(((
currentValue
>>
(
leftBits
-
1
))
&
0x01
)
==
0
)
n
=
n
->
left
;
else
n
=
n
->
right
;
leftBits
--
;
}
currentValue
&=
maskTable
[
maxBits
+
8
-
leftBits
-
1
];
out
[
count
]
=
n
->
c
;
count
++
;
}
}
free
(
valueTable
);
free
(
lengthTable
);
free
(
nodeTable
);
return
;
}
void
pad_tree_uchar
(
HuffmanTree
*
huffmanTree
,
unsigned
char
*
L
,
unsigned
char
*
R
,
unsigned
int
*
C
,
unsigned
char
*
t
,
unsigned
int
i
,
node
root
)
void
pad_tree_uchar
(
HuffmanTree
*
huffmanTree
,
unsigned
char
*
L
,
unsigned
char
*
R
,
unsigned
int
*
C
,
unsigned
char
*
t
,
unsigned
int
i
,
node
root
)
{
{
C
[
i
]
=
root
->
c
;
C
[
i
]
=
root
->
c
;
...
@@ -811,49 +714,6 @@ void encode_withTree(HuffmanTree* huffmanTree, int *s, size_t length, unsigned c
...
@@ -811,49 +714,6 @@ void encode_withTree(HuffmanTree* huffmanTree, int *s, size_t length, unsigned c
*
outSize
=
8
+
treeByteSize
+
enCodeSize
;
*
outSize
=
8
+
treeByteSize
+
enCodeSize
;
}
}
int
encode_withTree_MSST19
(
HuffmanTree
*
huffmanTree
,
int
*
s
,
size_t
length
,
unsigned
char
**
out
,
size_t
*
outSize
)
{
//struct ClockPoint clockPointInit;
//TimeDurationStart("init", &clockPointInit);
size_t
i
;
int
nodeCount
=
0
;
unsigned
char
*
treeBytes
,
buffer
[
4
];
init
(
huffmanTree
,
s
,
length
);
int
maxBits
=
0
;
for
(
i
=
0
;
i
<
huffmanTree
->
stateNum
;
i
++
)
if
(
huffmanTree
->
code
[
i
]){
nodeCount
++
;
if
(
huffmanTree
->
cout
[
i
]
>
maxBits
)
maxBits
=
huffmanTree
->
cout
[
i
];
}
nodeCount
=
nodeCount
*
2
-
1
;
//TimeDurationEnd(&clockPointInit);
//struct ClockPoint clockPointST;
//TimeDurationStart("save tree", &clockPointST);
unsigned
int
treeByteSize
=
convert_HuffTree_to_bytes_anyStates
(
huffmanTree
,
nodeCount
,
&
treeBytes
);
//printf("treeByteSize = %d\n", treeByteSize);
*
out
=
(
unsigned
char
*
)
malloc
(
length
*
sizeof
(
int
)
+
treeByteSize
);
intToBytes_bigEndian
(
buffer
,
nodeCount
);
memcpy
(
*
out
,
buffer
,
4
);
intToBytes_bigEndian
(
buffer
,
huffmanTree
->
stateNum
/
2
);
//real number of intervals
memcpy
(
*
out
+
4
,
buffer
,
4
);
memcpy
(
*
out
+
8
,
treeBytes
,
treeByteSize
);
free
(
treeBytes
);
size_t
enCodeSize
=
0
;
//TimeDurationEnd(&clockPointST);
//struct ClockPoint clockPointEncode;
//TimeDurationStart("encode", &clockPointEncode);
encode
(
huffmanTree
,
s
,
length
,
*
out
+
8
+
treeByteSize
,
&
enCodeSize
);
*
outSize
=
8
+
treeByteSize
+
enCodeSize
;
//TimeDurationEnd(&clockPointEncode);
//unsigned short state[length];
//decode(*out+4+treeByteSize, enCodeSize, qqq[0], state);
//printf("dataSeriesLength=%d",length );
return
maxBits
;
}
/**
/**
* @par *out rememmber to allocate targetLength short_type data for it beforehand.
* @par *out rememmber to allocate targetLength short_type data for it beforehand.
*
*
...
@@ -884,33 +744,6 @@ void decode_withTree(HuffmanTree* huffmanTree, unsigned char *s, size_t targetLe
...
@@ -884,33 +744,6 @@ void decode_withTree(HuffmanTree* huffmanTree, unsigned char *s, size_t targetLe
decode
(
s
+
8
+
encodeStartIndex
,
targetLength
,
root
,
out
);
decode
(
s
+
8
+
encodeStartIndex
,
targetLength
,
root
,
out
);
}
}
void
decode_withTree_MSST19
(
HuffmanTree
*
huffmanTree
,
unsigned
char
*
s
,
size_t
targetLength
,
int
*
out
,
int
maxBits
)
{
size_t
encodeStartIndex
;
size_t
nodeCount
=
bytesToInt_bigEndian
(
s
);
node
root
=
reconstruct_HuffTree_from_bytes_anyStates
(
huffmanTree
,
s
+
8
,
nodeCount
);
//sdi: Debug
/* build_code(root, 0, 0, 0);
int i;
unsigned long code_1, code_2;
for (i = 0; i < stateNum; i++)
if (code[i])
{
printf("%d: %lu,%lu ; %u\n", i, (code[i])[0],(code[i])[1], cout[i]);
//code_1 = (code[i])[0];
}*/
if
(
nodeCount
<=
256
)
encodeStartIndex
=
1
+
3
*
nodeCount
*
sizeof
(
unsigned
char
)
+
nodeCount
*
sizeof
(
unsigned
int
);
else
if
(
nodeCount
<=
65536
)
encodeStartIndex
=
1
+
2
*
nodeCount
*
sizeof
(
unsigned
short
)
+
nodeCount
*
sizeof
(
unsigned
char
)
+
nodeCount
*
sizeof
(
unsigned
int
);
else
encodeStartIndex
=
1
+
3
*
nodeCount
*
sizeof
(
unsigned
int
)
+
nodeCount
*
sizeof
(
unsigned
char
);
decode_MSST19
(
s
+
8
+
encodeStartIndex
,
targetLength
,
root
,
out
,
maxBits
);
}
void
SZ_ReleaseHuffman
(
HuffmanTree
*
huffmanTree
)
void
SZ_ReleaseHuffman
(
HuffmanTree
*
huffmanTree
)
{
{
size_t
i
;
size_t
i
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录