Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e477c355
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看板
提交
e477c355
编写于
10月 08, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-10529]add new files.
上级
2f5eb2ab
变更
16
显示空白变更内容
内联
并排
Showing
16 changed file
with
1122 addition
and
76 deletion
+1122
-76
include/common/common.h
include/common/common.h
+2
-0
include/common/tcompression.h
include/common/tcompression.h
+370
-0
source/common/src/ttypes.c
source/common/src/ttypes.c
+684
-0
source/libs/parser/inc/tvariant.h
source/libs/parser/inc/tvariant.h
+1
-1
source/libs/planner/CMakeLists.txt
source/libs/planner/CMakeLists.txt
+1
-1
source/libs/scheduler/inc/schedulerInt.h
source/libs/scheduler/inc/schedulerInt.h
+0
-8
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/common/src/ttypes.c
src/common/src/ttypes.c
+2
-2
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+21
-21
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+19
-20
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+5
-5
src/query/src/qResultbuf.c
src/query/src/qResultbuf.c
+2
-2
src/query/src/qTsbuf.c
src/query/src/qTsbuf.c
+2
-2
src/query/src/qUtil.c
src/query/src/qUtil.c
+2
-2
src/tsdb/inc/tsdbint.h
src/tsdb/inc/tsdbint.h
+8
-8
src/util/src/tcompression.c
src/util/src/tcompression.c
+2
-3
未找到文件。
include/common/common.h
浏览文件 @
e477c355
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#ifndef TDENGINE_COMMON_H
#ifndef TDENGINE_COMMON_H
#define TDENGINE_COMMON_H
#define TDENGINE_COMMON_H
#include "taosdef.h"
typedef
struct
STimeWindow
{
typedef
struct
STimeWindow
{
TSKEY
skey
;
TSKEY
skey
;
TSKEY
ekey
;
TSKEY
ekey
;
...
...
include/common/tcompression.h
0 → 100644
浏览文件 @
e477c355
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_TCOMPRESSION_H
#define TDENGINE_TCOMPRESSION_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "taosdef.h"
#define COMP_OVERFLOW_BYTES 2
#define BITS_PER_BYTE 8
// Masks
#define INT64MASK(_x) ((((uint64_t)1) << _x) - 1)
#define INT32MASK(_x) (((uint32_t)1 << _x) - 1)
#define INT8MASK(_x) (((uint8_t)1 << _x) - 1)
// Compression algorithm
#define NO_COMPRESSION 0
#define ONE_STAGE_COMP 1
#define TWO_STAGE_COMP 2
//
// compressed data first byte foramt
// ------ 7 bit ---- | ---- 1 bit ----
// algorithm mode
//
// compression data mode save first byte lower 1 bit
#define MODE_NOCOMPRESS 0 // original data
#define MODE_COMPRESS 1 // compatible old compress
// compression algorithm save first byte higher 7 bit
#define ALGO_SZ_LOSSY 1 // SZ compress
#define HEAD_MODE(x) x%2
#define HEAD_ALGO(x) x/2
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
);
// lossy
extern
int
tsCompressFloatLossyImp
(
const
char
*
input
,
const
int
nelements
,
char
*
const
output
);
extern
int
tsDecompressFloatLossyImp
(
const
char
*
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
);
extern
int
tsCompressDoubleLossyImp
(
const
char
*
input
,
const
int
nelements
,
char
*
const
output
);
extern
int
tsDecompressDoubleLossyImp
(
const
char
*
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
);
#ifdef TD_TSZ
extern
bool
lossyFloat
;
extern
bool
lossyDouble
;
// init call
int
tsCompressInit
();
// exit call
void
tsCompressExit
();
#endif
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
);
return
-
1
;
}
}
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
)
{
if
(
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
)
<
0
)
return
-
1
;
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_TINYINT
);
}
else
{
assert
(
0
);
return
-
1
;
}
}
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
);
return
-
1
;
}
}
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
)
{
if
(
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
)
<
0
)
return
-
1
;
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_SMALLINT
);
}
else
{
assert
(
0
);
return
-
1
;
}
}
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
);
return
-
1
;
}
}
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
)
{
if
(
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
)
<
0
)
return
-
1
;
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_INT
);
}
else
{
assert
(
0
);
return
-
1
;
}
}
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
);
return
-
1
;
}
}
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
)
{
if
(
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
)
<
0
)
return
-
1
;
return
tsDecompressINTImp
(
buffer
,
nelements
,
output
,
TSDB_DATA_TYPE_BIGINT
);
}
else
{
assert
(
0
);
return
-
1
;
}
}
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
);
return
-
1
;
}
}
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
)
{
if
(
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
)
<
0
)
return
-
1
;
return
tsDecompressBoolImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
return
-
1
;
}
}
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
)
{
#ifdef TD_TSZ
// lossy mode
if
(
lossyFloat
)
{
return
tsCompressFloatLossyImp
(
input
,
nelements
,
output
);
// lossless mode
}
else
{
#endif
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
);
return
-
1
;
}
#ifdef TD_TSZ
}
#endif
}
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
)
{
#ifdef TD_TSZ
if
(
HEAD_ALGO
(
input
[
0
])
==
ALGO_SZ_LOSSY
){
// decompress lossy
return
tsDecompressFloatLossyImp
(
input
,
compressedSize
,
nelements
,
output
);
}
else
{
#endif
// decompress lossless
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressFloatImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
if
(
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
)
<
0
)
return
-
1
;
return
tsDecompressFloatImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
return
-
1
;
}
#ifdef TD_TSZ
}
#endif
}
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
)
{
#ifdef TD_TSZ
if
(
lossyDouble
){
// lossy mode
return
tsCompressDoubleLossyImp
(
input
,
nelements
,
output
);
}
else
{
#endif
// lossless mode
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
);
return
-
1
;
}
#ifdef TD_TSZ
}
#endif
}
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
)
{
#ifdef TD_TSZ
if
(
HEAD_ALGO
(
input
[
0
])
==
ALGO_SZ_LOSSY
){
// decompress lossy
return
tsDecompressDoubleLossyImp
(
input
,
compressedSize
,
nelements
,
output
);
}
else
{
#endif
// decompress lossless
if
(
algorithm
==
ONE_STAGE_COMP
)
{
return
tsDecompressDoubleImp
(
input
,
nelements
,
output
);
}
else
if
(
algorithm
==
TWO_STAGE_COMP
)
{
if
(
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
)
<
0
)
return
-
1
;
return
tsDecompressDoubleImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
return
-
1
;
}
#ifdef TD_TSZ
}
#endif
}
#ifdef TD_TSZ
//
// lossy float double
//
static
FORCE_INLINE
int
tsCompressFloatLossy
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
)
{
return
tsCompressFloatLossyImp
(
input
,
nelements
,
output
);
}
static
FORCE_INLINE
int
tsDecompressFloatLossy
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
){
return
tsDecompressFloatLossyImp
(
input
,
compressedSize
,
nelements
,
output
);
}
static
FORCE_INLINE
int
tsCompressDoubleLossy
(
const
char
*
const
input
,
int
inputSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
){
return
tsCompressDoubleLossyImp
(
input
,
nelements
,
output
);
}
static
FORCE_INLINE
int
tsDecompressDoubleLossy
(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
){
return
tsDecompressDoubleLossyImp
(
input
,
compressedSize
,
nelements
,
output
);
}
#endif
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
);
return
-
1
;
}
}
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
)
{
if
(
tsDecompressStringImp
(
input
,
compressedSize
,
buffer
,
bufferSize
)
<
0
)
return
-
1
;
return
tsDecompressTimestampImp
(
buffer
,
nelements
,
output
);
}
else
{
assert
(
0
);
return
-
1
;
}
}
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_TCOMPRESSION_H
\ No newline at end of file
source/common/src/ttypes.c
0 → 100644
浏览文件 @
e477c355
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "taos.h"
#include "os.h"
#include "ttypes.h"
#include "tcompression.h"
const
int32_t
TYPE_BYTES
[
15
]
=
{
-
1
,
// TSDB_DATA_TYPE_NULL
CHAR_BYTES
,
// TSDB_DATA_TYPE_BOOL
CHAR_BYTES
,
// TSDB_DATA_TYPE_TINYINT
SHORT_BYTES
,
// TSDB_DATA_TYPE_SMALLINT
INT_BYTES
,
// TSDB_DATA_TYPE_INT
sizeof
(
int64_t
),
// TSDB_DATA_TYPE_BIGINT
FLOAT_BYTES
,
// TSDB_DATA_TYPE_FLOAT
DOUBLE_BYTES
,
// TSDB_DATA_TYPE_DOUBLE
sizeof
(
VarDataOffsetT
),
// TSDB_DATA_TYPE_BINARY
sizeof
(
TSKEY
),
// TSDB_DATA_TYPE_TIMESTAMP
sizeof
(
VarDataOffsetT
),
// TSDB_DATA_TYPE_NCHAR
CHAR_BYTES
,
// TSDB_DATA_TYPE_UTINYINT
SHORT_BYTES
,
// TSDB_DATA_TYPE_USMALLINT
INT_BYTES
,
// TSDB_DATA_TYPE_UINT
sizeof
(
uint64_t
),
// TSDB_DATA_TYPE_UBIGINT
};
#define DO_STATICS(__sum, __min, __max, __minIndex, __maxIndex, _list, _index) \
do { \
(__sum) += (_list)[(_index)]; \
if ((__min) > (_list)[(_index)]) { \
(__min) = (_list)[(_index)]; \
(__minIndex) = (_index); \
} \
\
if ((__max) < (_list)[(_index)]) { \
(__max) = (_list)[(_index)]; \
(__maxIndex) = (_index); \
} \
} while (0)
static
void
getStatics_bool
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int8_t
*
data
=
(
int8_t
*
)
pData
;
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
data
[
i
]
==
TSDB_DATA_BOOL_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
DO_STATICS
(
*
sum
,
*
min
,
*
max
,
*
minIndex
,
*
maxIndex
,
data
,
i
);
}
}
static
void
getStatics_i8
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int8_t
*
data
=
(
int8_t
*
)
pData
;
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(((
uint8_t
)
data
[
i
])
==
TSDB_DATA_TINYINT_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
DO_STATICS
(
*
sum
,
*
min
,
*
max
,
*
minIndex
,
*
maxIndex
,
data
,
i
);
}
}
static
void
getStatics_u8
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
uint8_t
*
data
=
(
uint8_t
*
)
pData
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_max
=
0
;
uint64_t
_sum
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(((
uint8_t
)
data
[
i
])
==
TSDB_DATA_UTINYINT_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
DO_STATICS
(
_sum
,
_min
,
_max
,
*
minIndex
,
*
maxIndex
,
data
,
i
);
}
*
min
=
_min
;
*
max
=
_max
;
*
sum
=
_sum
;
}
static
void
getStatics_i16
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int16_t
*
data
=
(
int16_t
*
)
pData
;
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(((
uint16_t
)
data
[
i
])
==
TSDB_DATA_SMALLINT_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
DO_STATICS
(
*
sum
,
*
min
,
*
max
,
*
minIndex
,
*
maxIndex
,
data
,
i
);
}
}
static
void
getStatics_u16
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
uint16_t
*
data
=
(
uint16_t
*
)
pData
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_max
=
0
;
uint64_t
_sum
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(((
uint16_t
)
data
[
i
])
==
TSDB_DATA_USMALLINT_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
DO_STATICS
(
_sum
,
_min
,
_max
,
*
minIndex
,
*
maxIndex
,
data
,
i
);
}
*
min
=
_min
;
*
max
=
_max
;
*
sum
=
_sum
;
}
static
void
getStatics_i32
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int32_t
*
data
=
(
int32_t
*
)
pData
;
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(((
uint32_t
)
data
[
i
])
==
TSDB_DATA_INT_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
DO_STATICS
(
*
sum
,
*
min
,
*
max
,
*
minIndex
,
*
maxIndex
,
data
,
i
);
}
}
static
void
getStatics_u32
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
uint32_t
*
data
=
(
uint32_t
*
)
pData
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_max
=
0
;
uint64_t
_sum
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(((
uint32_t
)
data
[
i
])
==
TSDB_DATA_UINT_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
DO_STATICS
(
_sum
,
_min
,
_max
,
*
minIndex
,
*
maxIndex
,
data
,
i
);
}
*
min
=
_min
;
*
max
=
_max
;
*
sum
=
_sum
;
}
static
void
getStatics_i64
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int64_t
*
data
=
(
int64_t
*
)
pData
;
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(((
uint64_t
)
data
[
i
])
==
TSDB_DATA_BIGINT_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
DO_STATICS
(
*
sum
,
*
min
,
*
max
,
*
minIndex
,
*
maxIndex
,
data
,
i
);
}
}
static
void
getStatics_u64
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
uint64_t
*
data
=
(
uint64_t
*
)
pData
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_max
=
0
;
uint64_t
_sum
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(((
uint64_t
)
data
[
i
])
==
TSDB_DATA_UBIGINT_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
DO_STATICS
(
_sum
,
_min
,
_max
,
*
minIndex
,
*
maxIndex
,
data
,
i
);
}
*
min
=
_min
;
*
max
=
_max
;
*
sum
=
_sum
;
}
static
void
getStatics_f
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
float
*
data
=
(
float
*
)
pData
;
float
fmin
=
FLT_MAX
;
float
fmax
=
-
FLT_MAX
;
double
dsum
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
((
*
(
uint32_t
*
)
&
(
data
[
i
]))
==
TSDB_DATA_FLOAT_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
float
fv
=
GET_FLOAT_VAL
((
const
char
*
)
&
(
data
[
i
]));
dsum
+=
fv
;
if
(
fmin
>
fv
)
{
fmin
=
fv
;
*
minIndex
=
i
;
}
if
(
fmax
<
fv
)
{
fmax
=
fv
;
*
maxIndex
=
i
;
}
}
SET_DOUBLE_VAL
(
sum
,
dsum
);
SET_DOUBLE_VAL
(
max
,
fmax
);
SET_DOUBLE_VAL
(
min
,
fmin
);
}
static
void
getStatics_d
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
double
*
data
=
(
double
*
)
pData
;
double
dmin
=
DBL_MAX
;
double
dmax
=
-
DBL_MAX
;
double
dsum
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
((
*
(
uint64_t
*
)
&
(
data
[
i
]))
==
TSDB_DATA_DOUBLE_NULL
)
{
(
*
numOfNull
)
+=
1
;
continue
;
}
double
dv
=
0
;
dv
=
GET_DOUBLE_VAL
((
const
char
*
)
&
(
data
[
i
]));
dsum
+=
dv
;
if
(
dmin
>
dv
)
{
dmin
=
dv
;
*
minIndex
=
i
;
}
if
(
dmax
<
dv
)
{
dmax
=
dv
;
*
maxIndex
=
i
;
}
}
SET_DOUBLE_PTR
(
sum
,
&
dsum
);
SET_DOUBLE_PTR
(
max
,
&
dmax
);
SET_DOUBLE_PTR
(
min
,
&
dmin
);
}
static
void
getStatics_bin
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
const
char
*
data
=
pData
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
(
data
,
TSDB_DATA_TYPE_BINARY
))
{
(
*
numOfNull
)
+=
1
;
}
data
+=
varDataTLen
(
data
);
}
*
sum
=
0
;
*
max
=
0
;
*
min
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
}
static
void
getStatics_nchr
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
const
char
*
data
=
pData
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
(
data
,
TSDB_DATA_TYPE_NCHAR
))
{
(
*
numOfNull
)
+=
1
;
}
data
+=
varDataTLen
(
data
);
}
*
sum
=
0
;
*
max
=
0
;
*
min
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
}
tDataTypeDescriptor
tDataTypes
[
15
]
=
{
{
TSDB_DATA_TYPE_NULL
,
6
,
1
,
"NOTYPE"
,
0
,
0
,
NULL
,
NULL
,
NULL
},
{
TSDB_DATA_TYPE_BOOL
,
4
,
CHAR_BYTES
,
"BOOL"
,
false
,
true
,
tsCompressBool
,
tsDecompressBool
,
getStatics_bool
},
{
TSDB_DATA_TYPE_TINYINT
,
7
,
CHAR_BYTES
,
"TINYINT"
,
INT8_MIN
,
INT8_MAX
,
tsCompressTinyint
,
tsDecompressTinyint
,
getStatics_i8
},
{
TSDB_DATA_TYPE_SMALLINT
,
8
,
SHORT_BYTES
,
"SMALLINT"
,
INT16_MIN
,
INT16_MAX
,
tsCompressSmallint
,
tsDecompressSmallint
,
getStatics_i16
},
{
TSDB_DATA_TYPE_INT
,
3
,
INT_BYTES
,
"INT"
,
INT32_MIN
,
INT32_MAX
,
tsCompressInt
,
tsDecompressInt
,
getStatics_i32
},
{
TSDB_DATA_TYPE_BIGINT
,
6
,
LONG_BYTES
,
"BIGINT"
,
INT64_MIN
,
INT64_MAX
,
tsCompressBigint
,
tsDecompressBigint
,
getStatics_i64
},
{
TSDB_DATA_TYPE_FLOAT
,
5
,
FLOAT_BYTES
,
"FLOAT"
,
0
,
0
,
tsCompressFloat
,
tsDecompressFloat
,
getStatics_f
},
{
TSDB_DATA_TYPE_DOUBLE
,
6
,
DOUBLE_BYTES
,
"DOUBLE"
,
0
,
0
,
tsCompressDouble
,
tsDecompressDouble
,
getStatics_d
},
{
TSDB_DATA_TYPE_BINARY
,
6
,
0
,
"BINARY"
,
0
,
0
,
tsCompressString
,
tsDecompressString
,
getStatics_bin
},
{
TSDB_DATA_TYPE_TIMESTAMP
,
9
,
LONG_BYTES
,
"TIMESTAMP"
,
INT64_MIN
,
INT64_MAX
,
tsCompressTimestamp
,
tsDecompressTimestamp
,
getStatics_i64
},
{
TSDB_DATA_TYPE_NCHAR
,
5
,
8
,
"NCHAR"
,
0
,
0
,
tsCompressString
,
tsDecompressString
,
getStatics_nchr
},
{
TSDB_DATA_TYPE_UTINYINT
,
16
,
CHAR_BYTES
,
"TINYINT UNSIGNED"
,
0
,
UINT8_MAX
,
tsCompressTinyint
,
tsDecompressTinyint
,
getStatics_u8
},
{
TSDB_DATA_TYPE_USMALLINT
,
17
,
SHORT_BYTES
,
"SMALLINT UNSIGNED"
,
0
,
UINT16_MAX
,
tsCompressSmallint
,
tsDecompressSmallint
,
getStatics_u16
},
{
TSDB_DATA_TYPE_UINT
,
12
,
INT_BYTES
,
"INT UNSIGNED"
,
0
,
UINT32_MAX
,
tsCompressInt
,
tsDecompressInt
,
getStatics_u32
},
{
TSDB_DATA_TYPE_UBIGINT
,
15
,
LONG_BYTES
,
"BIGINT UNSIGNED"
,
0
,
UINT64_MAX
,
tsCompressBigint
,
tsDecompressBigint
,
getStatics_u64
},
};
char
tTokenTypeSwitcher
[
13
]
=
{
TSDB_DATA_TYPE_NULL
,
// no type
TSDB_DATA_TYPE_BINARY
,
// TK_ID
TSDB_DATA_TYPE_BOOL
,
// TK_BOOL
TSDB_DATA_TYPE_BIGINT
,
// TK_TINYINT
TSDB_DATA_TYPE_BIGINT
,
// TK_SMALLINT
TSDB_DATA_TYPE_BIGINT
,
// TK_INTEGER
TSDB_DATA_TYPE_BIGINT
,
// TK_BIGINT
TSDB_DATA_TYPE_DOUBLE
,
// TK_FLOAT
TSDB_DATA_TYPE_DOUBLE
,
// TK_DOUBLE
TSDB_DATA_TYPE_BINARY
,
// TK_STRING
TSDB_DATA_TYPE_BIGINT
,
// TK_TIMESTAMP
TSDB_DATA_TYPE_BINARY
,
// TK_BINARY
TSDB_DATA_TYPE_NCHAR
,
// TK_NCHAR
};
float
floatMin
=
-
FLT_MAX
,
floatMax
=
FLT_MAX
;
double
doubleMin
=
-
DBL_MAX
,
doubleMax
=
DBL_MAX
;
FORCE_INLINE
void
*
getDataMin
(
int32_t
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_FLOAT
:
return
&
floatMin
;
case
TSDB_DATA_TYPE_DOUBLE
:
return
&
doubleMin
;
default:
return
&
tDataTypes
[
type
].
minValue
;
}
}
FORCE_INLINE
void
*
getDataMax
(
int32_t
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_FLOAT
:
return
&
floatMax
;
case
TSDB_DATA_TYPE_DOUBLE
:
return
&
doubleMax
;
default:
return
&
tDataTypes
[
type
].
maxValue
;
}
}
bool
isValidDataType
(
int32_t
type
)
{
return
type
>=
TSDB_DATA_TYPE_NULL
&&
type
<=
TSDB_DATA_TYPE_UBIGINT
;
}
void
setVardataNull
(
void
*
val
,
int32_t
type
)
{
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
varDataSetLen
(
val
,
sizeof
(
int8_t
));
*
(
uint8_t
*
)
varDataVal
(
val
)
=
TSDB_DATA_BINARY_NULL
;
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
varDataSetLen
(
val
,
sizeof
(
int32_t
));
*
(
uint32_t
*
)
varDataVal
(
val
)
=
TSDB_DATA_NCHAR_NULL
;
}
else
{
assert
(
0
);
}
}
void
setNull
(
void
*
val
,
int32_t
type
,
int32_t
bytes
)
{
setNullN
(
val
,
type
,
bytes
,
1
);
}
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
void
setNullN
(
void
*
val
,
int32_t
type
,
int32_t
bytes
,
int32_t
numOfElems
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint8_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_BOOL_NULL
;
}
break
;
case
TSDB_DATA_TYPE_TINYINT
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint8_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_TINYINT_NULL
;
}
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint16_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_SMALLINT_NULL
;
}
break
;
case
TSDB_DATA_TYPE_INT
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint32_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_INT_NULL
;
}
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint64_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_BIGINT_NULL
;
}
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint8_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_UTINYINT_NULL
;
}
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint16_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_USMALLINT_NULL
;
}
break
;
case
TSDB_DATA_TYPE_UINT
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint32_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_UINT_NULL
;
}
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint64_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_UBIGINT_NULL
;
}
break
;
case
TSDB_DATA_TYPE_FLOAT
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint32_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_FLOAT_NULL
;
}
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint64_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
type
].
bytes
))
=
TSDB_DATA_DOUBLE_NULL
;
}
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_BINARY
:
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
setVardataNull
(
POINTER_SHIFT
(
val
,
i
*
bytes
),
type
);
}
break
;
default:
{
for
(
int32_t
i
=
0
;
i
<
numOfElems
;
++
i
)
{
*
(
uint32_t
*
)(
POINTER_SHIFT
(
val
,
i
*
tDataTypes
[
TSDB_DATA_TYPE_INT
].
bytes
))
=
TSDB_DATA_INT_NULL
;
}
break
;
}
}
}
static
uint8_t
nullBool
=
TSDB_DATA_BOOL_NULL
;
static
uint8_t
nullTinyInt
=
TSDB_DATA_TINYINT_NULL
;
static
uint16_t
nullSmallInt
=
TSDB_DATA_SMALLINT_NULL
;
static
uint32_t
nullInt
=
TSDB_DATA_INT_NULL
;
static
uint64_t
nullBigInt
=
TSDB_DATA_BIGINT_NULL
;
static
uint32_t
nullFloat
=
TSDB_DATA_FLOAT_NULL
;
static
uint64_t
nullDouble
=
TSDB_DATA_DOUBLE_NULL
;
static
uint8_t
nullTinyIntu
=
TSDB_DATA_UTINYINT_NULL
;
static
uint16_t
nullSmallIntu
=
TSDB_DATA_USMALLINT_NULL
;
static
uint32_t
nullIntu
=
TSDB_DATA_UINT_NULL
;
static
uint64_t
nullBigIntu
=
TSDB_DATA_UBIGINT_NULL
;
static
SBinaryNullT
nullBinary
=
{
1
,
TSDB_DATA_BINARY_NULL
};
static
SNCharNullT
nullNchar
=
{
4
,
TSDB_DATA_NCHAR_NULL
};
static
const
void
*
nullValues
[]
=
{
&
nullBool
,
&
nullTinyInt
,
&
nullSmallInt
,
&
nullInt
,
&
nullBigInt
,
&
nullFloat
,
&
nullDouble
,
&
nullBinary
,
&
nullBigInt
,
&
nullNchar
,
&
nullTinyIntu
,
&
nullSmallIntu
,
&
nullIntu
,
&
nullBigIntu
,
};
const
void
*
getNullValue
(
int32_t
type
)
{
assert
(
type
>=
TSDB_DATA_TYPE_BOOL
&&
type
<=
TSDB_DATA_TYPE_UBIGINT
);
return
nullValues
[
type
-
1
];
}
void
assignVal
(
char
*
val
,
const
char
*
src
,
int32_t
len
,
int32_t
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
*
((
int8_t
*
)
val
)
=
GET_INT8_VAL
(
src
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
*
((
int16_t
*
)
val
)
=
GET_INT16_VAL
(
src
);
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
*
((
int32_t
*
)
val
)
=
GET_INT32_VAL
(
src
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
SET_FLOAT_VAL
(
val
,
GET_FLOAT_VAL
(
src
));
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
SET_DOUBLE_VAL
(
val
,
GET_DOUBLE_VAL
(
src
));
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
*
((
int64_t
*
)
val
)
=
GET_INT64_VAL
(
src
);
break
;
case
TSDB_DATA_TYPE_BINARY
:
varDataCopy
(
val
,
src
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
varDataCopy
(
val
,
src
);
break
;
default:
{
memcpy
(
val
,
src
,
len
);
break
;
}
}
}
void
operateVal
(
void
*
dst
,
void
*
s1
,
void
*
s2
,
int32_t
optr
,
int32_t
type
)
{
if
(
optr
==
TSDB_BINARY_OP_ADD
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_TINYINT
:
*
((
int8_t
*
)
dst
)
=
GET_INT8_VAL
(
s1
)
+
GET_INT8_VAL
(
s2
);
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
*
((
uint8_t
*
)
dst
)
=
GET_UINT8_VAL
(
s1
)
+
GET_UINT8_VAL
(
s2
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
*
((
int16_t
*
)
dst
)
=
GET_INT16_VAL
(
s1
)
+
GET_INT16_VAL
(
s2
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
*
((
uint16_t
*
)
dst
)
=
GET_UINT16_VAL
(
s1
)
+
GET_UINT16_VAL
(
s2
);
break
;
case
TSDB_DATA_TYPE_INT
:
*
((
int32_t
*
)
dst
)
=
GET_INT32_VAL
(
s1
)
+
GET_INT32_VAL
(
s2
);
break
;
case
TSDB_DATA_TYPE_UINT
:
*
((
uint32_t
*
)
dst
)
=
GET_UINT32_VAL
(
s1
)
+
GET_UINT32_VAL
(
s2
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
*
((
int64_t
*
)
dst
)
=
GET_INT64_VAL
(
s1
)
+
GET_INT64_VAL
(
s2
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
*
((
uint64_t
*
)
dst
)
=
GET_UINT64_VAL
(
s1
)
+
GET_UINT64_VAL
(
s2
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
*
((
int64_t
*
)
dst
)
=
GET_INT64_VAL
(
s1
)
+
GET_INT64_VAL
(
s2
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
SET_FLOAT_VAL
(
dst
,
GET_FLOAT_VAL
(
s1
)
+
GET_FLOAT_VAL
(
s2
));
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
SET_DOUBLE_VAL
(
dst
,
GET_DOUBLE_VAL
(
s1
)
+
GET_DOUBLE_VAL
(
s2
));
break
;
default:
{
assert
(
0
);
break
;
}
}
}
else
{
assert
(
0
);
}
}
#define SWAP(a, b, c) \
do { \
typeof(a) __tmp = (a); \
(a) = (b); \
(b) = __tmp; \
} while (0)
void
tsDataSwap
(
void
*
pLeft
,
void
*
pRight
,
int32_t
type
,
int32_t
size
,
void
*
buf
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
{
SWAP
(
*
(
int32_t
*
)(
pLeft
),
*
(
int32_t
*
)(
pRight
),
int32_t
);
break
;
}
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
SWAP
(
*
(
int64_t
*
)(
pLeft
),
*
(
int64_t
*
)(
pRight
),
int64_t
);
break
;
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
SWAP
(
*
(
double
*
)(
pLeft
),
*
(
double
*
)(
pRight
),
double
);
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
{
SWAP
(
*
(
int16_t
*
)(
pLeft
),
*
(
int16_t
*
)(
pRight
),
int16_t
);
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:
{
SWAP
(
*
(
float
*
)(
pLeft
),
*
(
float
*
)(
pRight
),
float
);
break
;
}
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
{
SWAP
(
*
(
int8_t
*
)(
pLeft
),
*
(
int8_t
*
)(
pRight
),
int8_t
);
break
;
}
default:
{
memcpy
(
buf
,
pLeft
,
size
);
memcpy
(
pLeft
,
pRight
,
size
);
memcpy
(
pRight
,
buf
,
size
);
break
;
}
}
}
source/libs/parser/inc/tvariant.h
浏览文件 @
e477c355
...
@@ -39,7 +39,7 @@ typedef struct SVariant {
...
@@ -39,7 +39,7 @@ typedef struct SVariant {
bool
taosVariantIsValid
(
SVariant
*
pVar
);
bool
taosVariantIsValid
(
SVariant
*
pVar
);
void
taosVariantCreate
(
SVariant
*
pVar
,
S
Str
Token
*
token
);
void
taosVariantCreate
(
SVariant
*
pVar
,
SToken
*
token
);
void
taosVariantCreateFromBinary
(
SVariant
*
pVar
,
const
char
*
pz
,
size_t
len
,
uint32_t
type
);
void
taosVariantCreateFromBinary
(
SVariant
*
pVar
,
const
char
*
pz
,
size_t
len
,
uint32_t
type
);
...
...
source/libs/planner/CMakeLists.txt
浏览文件 @
e477c355
...
@@ -8,5 +8,5 @@ target_include_directories(
...
@@ -8,5 +8,5 @@ target_include_directories(
target_link_libraries
(
target_link_libraries
(
planner
planner
PRIVATE os util common catalog parser
PRIVATE os util common catalog parser
transport
)
)
\ No newline at end of file
source/libs/scheduler/inc/schedulerInt.h
浏览文件 @
e477c355
...
@@ -25,14 +25,6 @@ extern "C" {
...
@@ -25,14 +25,6 @@ extern "C" {
#include "planner.h"
#include "planner.h"
#include "scheduler.h"
#include "scheduler.h"
typedef
struct
SSubquery
{
int64_t
taskId
;
// the task id created by qnode
int32_t
type
;
int32_t
level
;
struct
SQueryPhyNode
*
pNode
;
SArray
*
pUpstream
;
}
SSubquery
;
typedef
struct
SQuery
{
typedef
struct
SQuery
{
SArray
**
pSubquery
;
SArray
**
pSubquery
;
int32_t
numOfLevels
;
int32_t
numOfLevels
;
...
...
src/client/src/tscServer.c
浏览文件 @
e477c355
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <t
s
compression.h>
#include <tcompression.h>
#include "os.h"
#include "os.h"
#include "qPlan.h"
#include "qPlan.h"
#include "qTableMeta.h"
#include "qTableMeta.h"
...
...
src/common/src/ttypes.c
浏览文件 @
e477c355
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
*/
*/
#include "os.h"
#include "os.h"
#include "t
type
.h"
#include "t
compression
.h"
#include "ttokendef.h"
#include "ttokendef.h"
#include "t
scompression
.h"
#include "t
type
.h"
const
int32_t
TYPE_BYTES
[
15
]
=
{
const
int32_t
TYPE_BYTES
[
15
]
=
{
-
1
,
// TSDB_DATA_TYPE_NULL
-
1
,
// TSDB_DATA_TYPE_NULL
...
...
src/dnode/src/dnodeMain.c
浏览文件 @
e477c355
...
@@ -14,36 +14,36 @@
...
@@ -14,36 +14,36 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "taos.h"
#include "tnote.h"
#include "ttimer.h"
#include "tconfig.h"
#include "tfile.h"
#include "twal.h"
#include "tfs.h"
#include "tsync.h"
#include "dnodeStep.h"
#include "dnodePeer.h"
#include "dnodeModule.h"
#include "dnodeEps.h"
#include "dnodeMInfos.h"
#include "dnodeCfg.h"
#include "dnodeCfg.h"
#include "dnodeCheck.h"
#include "dnodeCheck.h"
#include "dnodeVRead.h"
#include "dnodeEps.h"
#include "dnodeVWrite.h"
#include "dnodeMInfos.h"
#include "dnodeVMgmt.h"
#include "dnodeMPeer.h"
#include "dnodeVnodes.h"
#include "dnodeMRead.h"
#include "dnodeMRead.h"
#include "dnodeMWrite.h"
#include "dnodeMWrite.h"
#include "dnodeMPeer.h"
#include "dnodeModule.h"
#include "dnodePeer.h"
#include "dnodeShell.h"
#include "dnodeShell.h"
#include "dnodeStep.h"
#include "dnodeTelemetry.h"
#include "dnodeTelemetry.h"
#include "module.h"
#include "dnodeVMgmt.h"
#include "dnodeVRead.h"
#include "dnodeVWrite.h"
#include "dnodeVnodes.h"
#include "mnode.h"
#include "mnode.h"
#include "module.h"
#include "os.h"
#include "qScript.h"
#include "qScript.h"
#include "taos.h"
#include "tcache.h"
#include "tcache.h"
#include "tscompression.h"
#include "tcompression.h"
#include "tconfig.h"
#include "tfile.h"
#include "tfs.h"
#include "tnote.h"
#include "tsync.h"
#include "ttimer.h"
#include "twal.h"
#if !defined(_MODULE) || !defined(_TD_LINUX)
#if !defined(_MODULE) || !defined(_TD_LINUX)
int32_t
moduleStart
()
{
return
0
;
}
int32_t
moduleStart
()
{
return
0
;
}
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
e477c355
...
@@ -14,35 +14,34 @@
...
@@ -14,35 +14,34 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeTable.h"
#include "taosmsg.h"
#include "dnode.h"
#include "tutil.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "tscompression.h"
#include "tname.h"
#include "tidpool.h"
#include "tglobal.h"
#include "tcompare.h"
#include "tdataformat.h"
#include "tgrant.h"
#include "tqueue.h"
#include "hash.h"
#include "hash.h"
#include "mnode.h"
#include "mnode.h"
#include "dnode.h"
#include "mnodeDef.h"
#include "mnodeInt.h"
#include "mnodeAcct.h"
#include "mnodeAcct.h"
#include "mnodeDb.h"
#include "mnodeDb.h"
#include "mnodeDef.h"
#include "mnodeDnode.h"
#include "mnodeDnode.h"
#include "mnodeFunc.h"
#include "mnodeInt.h"
#include "mnodePeer.h"
#include "mnodeRead.h"
#include "mnodeSdb.h"
#include "mnodeSdb.h"
#include "mnodeShow.h"
#include "mnodeShow.h"
#include "mnodeTable.h"
#include "mnodeVgroup.h"
#include "mnodeVgroup.h"
#include "mnodeWrite.h"
#include "mnodeWrite.h"
#include "mnodeRead.h"
#include "os.h"
#include "mnodePeer.h"
#include "taoserror.h"
#include "mnodeFunc.h"
#include "taosmsg.h"
#include "tcompare.h"
#include "tcompression.h"
#include "tdataformat.h"
#include "tglobal.h"
#include "tgrant.h"
#include "tidpool.h"
#include "tname.h"
#include "tqueue.h"
#include "tutil.h"
#define ALTER_CTABLE_RETRY_TIMES 3
#define ALTER_CTABLE_RETRY_TIMES 3
#define CREATE_CTABLE_RETRY_TIMES 10
#define CREATE_CTABLE_RETRY_TIMES 10
...
...
src/query/src/qExecutor.c
浏览文件 @
e477c355
...
@@ -19,17 +19,17 @@
...
@@ -19,17 +19,17 @@
#include "exception.h"
#include "exception.h"
#include "hash.h"
#include "hash.h"
#include "texpr.h"
#include "qExecutor.h"
#include "qExecutor.h"
#include "qResultbuf.h"
#include "qResultbuf.h"
#include "qScript.h"
#include "qUtil.h"
#include "qUtil.h"
#include "queryLog.h"
#include "queryLog.h"
#include "tlosertree.h"
#include "ttype.h"
#include "tcompare.h"
#include "tcompare.h"
#include "tscompression.h"
#include "tcompression.h"
#include "qScript.h"
#include "texpr.h"
#include "tlosertree.h"
#include "tscLog.h"
#include "tscLog.h"
#include "ttype.h"
#define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN)
#define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN)
#define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN)
#define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN)
...
...
src/query/src/qResultbuf.c
浏览文件 @
e477c355
#include "qResultbuf.h"
#include "qResultbuf.h"
#include "stddef.h"
#include "tscompression.h"
#include "hash.h"
#include "hash.h"
#include "qExtbuffer.h"
#include "qExtbuffer.h"
#include "queryLog.h"
#include "queryLog.h"
#include "stddef.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tcompression.h"
#define GET_DATA_PAYLOAD(_p) ((char *)(_p)->pData + POINTER_BYTES)
#define GET_DATA_PAYLOAD(_p) ((char *)(_p)->pData + POINTER_BYTES)
#define NO_IN_MEM_AVAILABLE_PAGES(_b) (listNEles((_b)->lruList) >= (_b)->inMemPages)
#define NO_IN_MEM_AVAILABLE_PAGES(_b) (listNEles((_b)->lruList) >= (_b)->inMemPages)
...
...
src/query/src/qTsbuf.c
浏览文件 @
e477c355
#include "qTsbuf.h"
#include "qTsbuf.h"
#include "queryLog.h"
#include "taoserror.h"
#include "taoserror.h"
#include "t
s
compression.h"
#include "tcompression.h"
#include "tutil.h"
#include "tutil.h"
#include "queryLog.h"
static
int32_t
getDataStartOffset
();
static
int32_t
getDataStartOffset
();
static
void
TSBufUpdateGroupInfo
(
STSBuf
*
pTSBuf
,
int32_t
index
,
STSGroupBlockInfo
*
pBlockInfo
);
static
void
TSBufUpdateGroupInfo
(
STSBuf
*
pTSBuf
,
int32_t
index
,
STSGroupBlockInfo
*
pBlockInfo
);
...
...
src/query/src/qUtil.c
浏览文件 @
e477c355
...
@@ -19,10 +19,10 @@
...
@@ -19,10 +19,10 @@
#include "qExecutor.h"
#include "qExecutor.h"
#include "qUtil.h"
#include "qUtil.h"
#include "queryLog.h"
#include "tbuffer.h"
#include "tbuffer.h"
#include "tcompression.h"
#include "tlosertree.h"
#include "tlosertree.h"
#include "queryLog.h"
#include "tscompression.h"
typedef
struct
SCompSupporter
{
typedef
struct
SCompSupporter
{
STableQueryInfo
**
pTableQueryInfo
;
STableQueryInfo
**
pTableQueryInfo
;
...
...
src/tsdb/inc/tsdbint.h
浏览文件 @
e477c355
...
@@ -26,20 +26,20 @@
...
@@ -26,20 +26,20 @@
// #include <semaphore.h>
// #include <semaphore.h>
// #include <dirent.h>
// #include <dirent.h>
#include "hash.h"
#include "os.h"
#include "os.h"
#include "tlog.h"
#include "taosdef.h"
#include "taosdef.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tarray.h"
#include "tchecksum.h"
#include "tchecksum.h"
#include "tskiplist.h"
#include "tdataformat.h"
#include "tcoding.h"
#include "tcoding.h"
#include "tscompression.h"
#include "tcompression.h"
#include "tlockfree.h"
#include "tdataformat.h"
#include "tlist.h"
#include "hash.h"
#include "tarray.h"
#include "tfs.h"
#include "tfs.h"
#include "tlist.h"
#include "tlockfree.h"
#include "tlog.h"
#include "tskiplist.h"
#include "tsocket.h"
#include "tsocket.h"
#include "tsdb.h"
#include "tsdb.h"
...
...
src/util/src/tcompression.c
浏览文件 @
e477c355
...
@@ -53,10 +53,9 @@
...
@@ -53,10 +53,9 @@
#include "td_sz.h"
#include "td_sz.h"
#endif
#endif
#include "taosdef.h"
#include "taosdef.h"
#include "tscompression.h"
#include "tcompression.h"
#include "tulog.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tulog.h"
static
const
int
TEST_NUMBER
=
1
;
static
const
int
TEST_NUMBER
=
1
;
#define is_bigendian() ((*(char *)&TEST_NUMBER) == 0)
#define is_bigendian() ((*(char *)&TEST_NUMBER) == 0)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录