Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e86c501d
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e86c501d
编写于
4月 30, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize compression
上级
6741d710
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
215 addition
and
254 deletion
+215
-254
src/util/inc/tscompression.h
src/util/inc/tscompression.h
+215
-37
src/util/src/tcompression.c
src/util/src/tcompression.c
+0
-217
未找到文件。
src/util/inc/tscompression.h
浏览文件 @
e86c501d
...
...
@@ -21,6 +21,7 @@ extern "C" {
#endif
#include "taosdef.h"
#include "tutil.h"
#define COMP_OVERFLOW_BYTES 2
#define BITS_PER_BYTE 8
...
...
@@ -33,43 +34,220 @@ extern "C" {
#define ONE_STAGE_COMP 1
#define TWO_STAGE_COMP 2
int
tsCompressTinyint
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
tsCompressSmallint
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorith
,
char
*
const
buffer
,
int
bufferSize
);
int
tsCompressInt
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorith
,
char
*
const
buffer
,
int
bufferSize
);
int
tsCompressBigint
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorith
,
char
*
const
buffer
,
int
bufferSize
);
int
tsCompressBool
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
tsCompressString
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorith
,
char
*
const
buffer
,
int
bufferSize
);
int
tsCompressFloat
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorith
,
char
*
const
buffer
,
int
bufferSize
);
int
tsCompressDouble
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorith
,
char
*
const
buffer
,
int
bufferSize
);
int
tsCompressTimestamp
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorith
,
char
*
const
buffer
,
int
bufferSize
);
int
tsDecompressTinyint
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
tsDecompressSmallint
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
tsDecompressInt
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
tsDecompressBigint
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
tsDecompressBool
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
tsDecompressString
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
tsDecompressFloat
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
tsDecompressDouble
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorith
,
char
*
const
buffer
,
int
bufferSize
);
int
tsDecompressTimestamp
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
extern
int
tsCompressINTImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
,
const
char
type
);
extern
int
tsDecompressINTImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
,
const
char
type
);
extern
int
tsCompressBoolImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
extern
int
tsDecompressBoolImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
extern
int
tsCompressStringImp
(
const
char
*
const
input
,
int
inputSize
,
char
*
const
output
,
int
outputSize
);
extern
int
tsDecompressStringImp
(
const
char
*
const
input
,
int
compressedSize
,
char
*
const
output
,
int
outputSize
);
extern
int
tsCompressTimestampImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
extern
int
tsDecompressTimestampImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
extern
int
tsCompressDoubleImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
extern
int
tsDecompressDoubleImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
extern
int
tsCompressFloatImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
extern
int
tsDecompressFloatImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
static
FORCE_INLINE
int
tsCompressTinyint
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_TINYINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressINTImp
(
input
,
nelements
,
buffer
,
TSDB_DATA_TYPE_TINYINT
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsDecompressTinyint
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_TINYINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_TINYINT
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsCompressSmallint
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_SMALLINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressINTImp
(
input
,
nelements
,
buffer
,
TSDB_DATA_TYPE_SMALLINT
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsDecompressSmallint
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_SMALLINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_SMALLINT
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsCompressInt
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_INT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressINTImp
(
input
,
nelements
,
buffer
,
TSDB_DATA_TYPE_INT
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsDecompressInt
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_INT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_INT
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsCompressBigint
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_BIGINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressINTImp
(
input
,
nelements
,
buffer
,
TSDB_DATA_TYPE_BIGINT
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsDecompressBigint
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_BIGINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_BIGINT
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsCompressBool
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressBoolImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressBoolImp
(
input
,
nelements
,
buffer
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsDecompressBool
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressBoolImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressBoolImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsCompressString
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
return
tsCompressStringImp
(
input
,
inputSize
,
output
,
outputSize
);
}
static
FORCE_INLINE
int
tsDecompressString
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
return
tsDecompressStringImp
(
input
,
compressedSize
,
output
,
outputSize
);
}
static
FORCE_INLINE
int
tsCompressFloat
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressFloatImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressFloatImp
(
input
,
nelements
,
buffer
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsDecompressFloat
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressFloatImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressFloatImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsCompressDouble
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressDoubleImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressDoubleImp
(
input
,
nelements
,
buffer
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsDecompressDouble
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressDoubleImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressDoubleImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsCompressTimestamp
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressTimestampImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressTimestampImp
(
input
,
nelements
,
buffer
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
static
FORCE_INLINE
int
tsDecompressTimestamp
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressTimestampImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressTimestampImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
}
}
#ifdef __cplusplus
}
...
...
src/util/src/tcompression.c
浏览文件 @
e86c501d
...
...
@@ -56,223 +56,6 @@ const int TEST_NUMBER = 1;
#define is_bigendian() ((*(char *)&TEST_NUMBER) == 0)
#define SIMPLE8B_MAX_INT64 ((uint64_t)2305843009213693951L)
// Function declarations
int
tsCompressINTImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
,
const
char
type
);
int
tsDecompressINTImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
,
const
char
type
);
int
tsCompressBoolImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
int
tsDecompressBoolImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
int
tsCompressStringImp
(
const
char
*
const
input
,
int
inputSize
,
char
*
const
output
,
int
outputSize
);
int
tsDecompressStringImp
(
const
char
*
const
input
,
int
compressedSize
,
char
*
const
output
,
int
outputSize
);
int
tsCompressTimestampImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
int
tsDecompressTimestampImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
int
tsCompressDoubleImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
int
tsDecompressDoubleImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
int
tsCompressFloatImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
int
tsDecompressFloatImp
(
const
char
*
const
input
,
const
int
nelements
,
char
*
const
output
);
/* ----------------------------------------------Compression function used by
* others ---------------------------------------------- */
int
tsCompressTinyint
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_TINYINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressINTImp
(
input
,
nelements
,
buffer
,
TSDB_DATA_TYPE_TINYINT
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
int
tsDecompressTinyint
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_TINYINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_TINYINT
);
}
else
{
assert
(
0
);
}
}
int
tsCompressSmallint
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_SMALLINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressINTImp
(
input
,
nelements
,
buffer
,
TSDB_DATA_TYPE_SMALLINT
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
int
tsDecompressSmallint
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_SMALLINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_SMALLINT
);
}
else
{
assert
(
0
);
}
}
int
tsCompressInt
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_INT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressINTImp
(
input
,
nelements
,
buffer
,
TSDB_DATA_TYPE_INT
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
int
tsDecompressInt
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_INT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_INT
);
}
else
{
assert
(
0
);
}
}
int
tsCompressBigint
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_BIGINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressINTImp
(
input
,
nelements
,
buffer
,
TSDB_DATA_TYPE_BIGINT
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
int
tsDecompressBigint
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressINTImp
(
input
,
nelements
,
output
,
TSDB_DATA_TYPE_BIGINT
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_BIGINT
);
}
else
{
assert
(
0
);
}
}
int
tsCompressBool
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressBoolImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressBoolImp
(
input
,
nelements
,
buffer
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
int
tsDecompressBool
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressBoolImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressBoolImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
}
}
int
tsCompressString
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
return
tsCompressStringImp
(
input
,
inputSize
,
output
,
outputSize
);
}
int
tsDecompressString
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
return
tsDecompressStringImp
(
input
,
compressedSize
,
output
,
outputSize
);
}
int
tsCompressFloat
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressFloatImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressFloatImp
(
input
,
nelements
,
buffer
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
int
tsDecompressFloat
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressFloatImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressFloatImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
}
}
int
tsCompressDouble
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressDoubleImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressDoubleImp
(
input
,
nelements
,
buffer
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
int
tsDecompressDouble
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressDoubleImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressDoubleImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
}
}
int
tsCompressTimestamp
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsCompressTimestampImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
int
len
=
tsCompressTimestampImp
(
input
,
nelements
,
buffer
);
return
tsCompressStringImp
(
buffer
,
len
,
output
,
outputSize
);
}
else
{
assert
(
0
);
}
}
int
tsDecompressTimestamp
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressTimestampImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
);
return
tsDecompressTimestampImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
}
}
bool
safeInt64Add
(
int64_t
a
,
int64_t
b
)
{
if
((
a
>
0
&&
b
>
INT64_MAX
-
a
)
||
(
a
<
0
&&
b
<
INT64_MIN
-
a
))
return
false
;
return
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录