Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
747ce081
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看板
提交
747ce081
编写于
9月 19, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
fe13dce4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
49 addition
and
41 deletion
+49
-41
source/util/src/tcompression.c
source/util/src/tcompression.c
+49
-41
未找到文件。
source/util/src/tcompression.c
浏览文件 @
747ce081
...
@@ -1046,9 +1046,12 @@ struct SCompressor {
...
@@ -1046,9 +1046,12 @@ struct SCompressor {
};
};
// Integer ----
// Integer ----
struct
{
struct
{
int64_t
i_prev
;
int64_t
i_prev
;
int32_t
i_selector
;
int32_t
i_selector
;
int32_t
i_nele
;
int32_t
i_start
;
int32_t
i_end
;
uint64_t
i_aZigzag
[
241
];
int8_t
i_aBitN
[
241
];
};
};
// Float ----
// Float ----
struct
{
struct
{
...
@@ -1190,9 +1193,9 @@ static int32_t tCompTimestamp(SCompressor *pCmprsor, int64_t ts) {
...
@@ -1190,9 +1193,9 @@ static int32_t tCompTimestamp(SCompressor *pCmprsor, int64_t ts) {
// Integer =====================================================
// Integer =====================================================
#define SIMPLE8B_MAX ((uint64_t)1152921504606846974LL)
#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
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
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
,
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
,
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
,
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
};
...
@@ -1227,60 +1230,64 @@ static int32_t tCompInt(SCompressor *pCmprsor, const void *pData, int32_t nData)
...
@@ -1227,60 +1230,64 @@ static int32_t tCompInt(SCompressor *pCmprsor, const void *pData, int32_t nData)
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UINT
:
val
=
*
(
uint32_t
*
)
pData
;
val
=
*
(
uint32_t
*
)
pData
;
break
;
break
;
//
case TSDB_DATA_TYPE_UBIGINT:
case
TSDB_DATA_TYPE_UBIGINT
:
//
val = *(int64_t *)pData;
val
=
*
(
int64_t
*
)
pData
;
//
break;
break
;
default:
default:
ASSERT
(
0
);
ASSERT
(
0
);
break
;
break
;
}
}
if
(
!
I64_SAFE_ADD
(
val
,
pCmprsor
->
i_prev
))
{
if
(
!
I64_SAFE_ADD
(
val
,
-
pCmprsor
->
i_prev
))
{
// TODO
// TODO
goto
_copy_cmpr
;
goto
_copy_cmpr
;
}
}
int64_t
diff
=
val
-
pCmprsor
->
i_prev
;
int64_t
diff
=
val
-
pCmprsor
->
i_prev
;
uint64_t
vZigzag
=
ZIGZAG_ENCODE
(
int64_t
,
diff
);
uint64_t
vZigzag
=
ZIGZAG_ENCODE
(
int64_t
,
diff
);
if
(
vZigzag
>=
SIMPLE8B_MAX
)
{
if
(
vZigzag
>=
SIMPLE8B_MAX
)
{
// TODO
// TODO
goto
_copy_cmpr
;
goto
_copy_cmpr
;
}
}
int64_t
nBit
;
int8_t
nBit
=
(
vZigzag
)
?
(
64
-
BUILDIN_CLZL
(
vZigzag
))
:
0
;
if
(
vZigzag
)
{
pCmprsor
->
i_prev
=
val
;
nBit
=
64
-
BUILDIN_CLZL
(
vZigzag
);
}
else
{
nBit
=
0
;
}
if
(
pCmprsor
->
i_nele
+
1
<=
selector_to_elems
[
pCmprsor
->
i_selector
]
&&
while
(
1
)
{
pCmprsor
->
i_nele
+
1
<=
selector_to_elems
[
bit_to_selector
[
nBit
]])
{
int32_t
nEle
=
pCmprsor
->
i_end
-
pCmprsor
->
i_start
;
if
(
pCmprsor
->
i_selector
<
bit_to_selector
[
nBit
])
{
pCmprsor
->
i_selector
=
bit_to_selector
[
nBit
];
}
pCmprsor
->
i_nele
++
;
pCmprsor
->
i_prev
=
val
;
}
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
(
nEle
+
1
<=
SELECTOR_TO_ELEMS
[
pCmprsor
->
i_selector
]
&&
nEle
+
1
<=
SELECTOR_TO_ELEMS
[
BIT_TO_SELECTOR
[
nBit
]])
{
if
(
code
)
return
code
;
if
(
pCmprsor
->
i_selector
<
BIT_TO_SELECTOR
[
nBit
])
{
pCmprsor
->
i_selector
=
BIT_TO_SELECTOR
[
nBit
];
}
pCmprsor
->
i_end
=
(
pCmprsor
->
i_end
+
1
)
%
241
;
pCmprsor
->
i_aZigzag
[
pCmprsor
->
i_end
]
=
vZigzag
;
pCmprsor
->
i_aBitN
[
pCmprsor
->
i_end
]
=
nBit
;
break
;
}
else
{
while
(
nEle
<
SELECTOR_TO_ELEMS
[
pCmprsor
->
i_selector
])
{
pCmprsor
->
i_selector
++
;
}
nEle
=
SELECTOR_TO_ELEMS
[
pCmprsor
->
i_selector
];
uint64_t
*
bp
=
(
uint64_t
*
)(
pCmprsor
->
aBuf
[
0
]
+
pCmprsor
->
nBuf
[
0
]);
code
=
tRealloc
(
&
pCmprsor
->
aBuf
[
0
],
pCmprsor
->
nBuf
[
0
]
+
sizeof
(
uint64_t
));
pCmprsor
->
nBuf
[
0
]
+=
sizeof
(
uint64_t
);
if
(
code
)
return
code
;
bp
[
0
]
=
pCmprsor
->
i_selector
;
for
(
int32_t
iVal
=
0
;
iVal
<
pCmprsor
->
i_nele
;
iVal
++
)
{
/* code */
}
// reset and continue
// uint64_t *bp = (uint64_t *)(pCmprsor->aBuf[0] + pCmprsor->nBuf[0]);
pCmprsor
->
i_nele
=
0
;
// pCmprsor->nBuf[0] += sizeof(uint64_t);
pCmprsor
->
i_selector
=
0
;
// bp[0] = pCmprsor->i_selector;
// for (int32_t iVal = 0; iVal < pCmprsor->i_nele; iVal++) {
// /* code */
// }
// reset and continue
pCmprsor
->
i_selector
=
0
;
for
(
int32_t
iVal
=
pCmprsor
->
i_start
;
iVal
<
pCmprsor
->
i_end
;
iVal
++
)
{
if
(
pCmprsor
->
i_selector
<
BIT_TO_SELECTOR
[
pCmprsor
->
i_aBitN
[
iVal
]])
{
pCmprsor
->
i_selector
=
BIT_TO_SELECTOR
[
pCmprsor
->
i_aBitN
[
iVal
]];
}
}
}
}
}
}
else
{
}
else
{
_copy_cmpr:
_copy_cmpr:
...
@@ -1546,7 +1553,8 @@ int32_t tCompressorReset(SCompressor *pCmprsor, int8_t type, int8_t cmprAlg, int
...
@@ -1546,7 +1553,8 @@ int32_t tCompressorReset(SCompressor *pCmprsor, int8_t type, int8_t cmprAlg, int
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
pCmprsor
->
i_prev
=
0
;
pCmprsor
->
i_prev
=
0
;
pCmprsor
->
i_selector
=
0
;
pCmprsor
->
i_selector
=
0
;
pCmprsor
->
i_nele
=
0
;
pCmprsor
->
i_start
=
0
;
pCmprsor
->
i_end
=
0
;
pCmprsor
->
aBuf
[
0
][
0
]
=
0
;
// 0 means compressed, 1 otherwise (for backward compatibility)
pCmprsor
->
aBuf
[
0
][
0
]
=
0
;
// 0 means compressed, 1 otherwise (for backward compatibility)
pCmprsor
->
nBuf
[
0
]
=
1
;
pCmprsor
->
nBuf
[
0
]
=
1
;
break
;
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录