Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
codyshao
TDengine
提交
5ae9ed74
T
TDengine
项目概览
codyshao
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5ae9ed74
编写于
5月 14, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-321
上级
f5a677e5
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
287 addition
and
304 deletion
+287
-304
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+0
-293
src/common/src/ttypes.c
src/common/src/ttypes.c
+273
-11
src/inc/taosdef.h
src/inc/taosdef.h
+2
-0
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+7
-0
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+5
-0
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
5ae9ed74
...
...
@@ -3620,299 +3620,6 @@ void spread_function_finalizer(SQLFunctionCtx *pCtx) {
doFinalizer
(
pCtx
);
}
static
void
getStatics_i8
(
int64_t
*
primaryKey
,
int32_t
type
,
int8_t
*
data
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int32_t
*
numOfNull
)
{
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
// int64_t lastKey = 0;
// int8_t lastVal = TSDB_DATA_TINYINT_NULL;
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
((
char
*
)
&
data
[
i
],
type
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
*
sum
+=
data
[
i
];
if
(
*
min
>
data
[
i
])
{
*
min
=
data
[
i
];
*
minIndex
=
i
;
}
if
(
*
max
<
data
[
i
])
{
*
max
=
data
[
i
];
*
maxIndex
=
i
;
}
// if (type != TSDB_DATA_TYPE_BOOL) { // ignore the bool data type pre-calculation
// if (isNull((char *)&lastVal, type)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
// }
}
}
static
void
getStatics_i16
(
int64_t
*
primaryKey
,
int16_t
*
data
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int32_t
*
numOfNull
)
{
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
// int64_t lastKey = 0;
// int16_t lastVal = TSDB_DATA_SMALLINT_NULL;
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
((
const
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_SMALLINT
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
*
sum
+=
data
[
i
];
if
(
*
min
>
data
[
i
])
{
*
min
=
data
[
i
];
*
minIndex
=
i
;
}
if
(
*
max
<
data
[
i
])
{
*
max
=
data
[
i
];
*
maxIndex
=
i
;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_SMALLINT)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
}
}
static
void
getStatics_i32
(
int64_t
*
primaryKey
,
int32_t
*
data
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int32_t
*
numOfNull
)
{
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
// int64_t lastKey = 0;
// int32_t lastVal = TSDB_DATA_INT_NULL;
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
((
const
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_INT
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
*
sum
+=
data
[
i
];
if
(
*
min
>
data
[
i
])
{
*
min
=
data
[
i
];
*
minIndex
=
i
;
}
if
(
*
max
<
data
[
i
])
{
*
max
=
data
[
i
];
*
maxIndex
=
i
;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_INT)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
}
}
static
void
getStatics_i64
(
int64_t
*
primaryKey
,
int64_t
*
data
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int32_t
*
numOfNull
)
{
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
((
const
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_BIGINT
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
*
sum
+=
data
[
i
];
if
(
*
min
>
data
[
i
])
{
*
min
=
data
[
i
];
*
minIndex
=
i
;
}
if
(
*
max
<
data
[
i
])
{
*
max
=
data
[
i
];
*
maxIndex
=
i
;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_BIGINT)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
}
}
static
void
getStatics_f
(
int64_t
*
primaryKey
,
float
*
data
,
int32_t
numOfRow
,
double
*
min
,
double
*
max
,
double
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int32_t
*
numOfNull
)
{
float
fmin
=
DBL_MAX
;
float
fmax
=
-
DBL_MAX
;
double
dsum
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
((
const
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_FLOAT
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
float
fv
=
0
;
fv
=
GET_FLOAT_VAL
(
&
(
data
[
i
]));
dsum
+=
fv
;
if
(
fmin
>
fv
)
{
fmin
=
fv
;
*
minIndex
=
i
;
}
if
(
fmax
<
fv
)
{
fmax
=
fv
;
*
maxIndex
=
i
;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_FLOAT)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
}
double
csum
=
0
;
csum
=
GET_DOUBLE_VAL
(
sum
);
csum
+=
dsum
;
#ifdef _TD_ARM_32_
SET_DOUBLE_VAL_ALIGN
(
sum
,
&
csum
);
SET_DOUBLE_VAL_ALIGN
(
max
,
&
fmax
);
SET_DOUBLE_VAL_ALIGN
(
min
,
&
fmin
);
#else
*
sum
=
csum
;
*
max
=
fmax
;
*
min
=
fmin
;
#endif
}
static
void
getStatics_d
(
int64_t
*
primaryKey
,
double
*
data
,
int32_t
numOfRow
,
double
*
min
,
double
*
max
,
double
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int32_t
*
numOfNull
)
{
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
(
isNull
((
const
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_DOUBLE
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
double
dv
=
0
;
dv
=
GET_DOUBLE_VAL
(
&
(
data
[
i
]));
dsum
+=
dv
;
if
(
dmin
>
dv
)
{
dmin
=
dv
;
*
minIndex
=
i
;
}
if
(
dmax
<
dv
)
{
dmax
=
dv
;
*
maxIndex
=
i
;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_DOUBLE)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
}
double
csum
=
0
;
csum
=
GET_DOUBLE_VAL
(
sum
);
csum
+=
dsum
;
#ifdef _TD_ARM_32_
SET_DOUBLE_VAL_ALIGN
(
sum
,
&
csum
);
SET_DOUBLE_VAL_ALIGN
(
max
,
&
dmax
);
SET_DOUBLE_VAL_ALIGN
(
min
,
&
dmin
);
#else
*
sum
=
csum
;
*
max
=
dmax
;
*
min
=
dmin
;
#endif
}
void
getStatistics
(
char
*
priData
,
char
*
data
,
int32_t
size
,
int32_t
numOfRow
,
int32_t
type
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int32_t
*
numOfNull
)
{
int64_t
*
primaryKey
=
(
int64_t
*
)
priData
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
(
data
+
i
*
size
,
type
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
}
}
else
{
if
(
type
==
TSDB_DATA_TYPE_TINYINT
||
type
==
TSDB_DATA_TYPE_BOOL
)
{
getStatics_i8
(
primaryKey
,
type
,
(
int8_t
*
)
data
,
numOfRow
,
min
,
max
,
sum
,
minIndex
,
maxIndex
,
numOfNull
);
}
else
if
(
type
==
TSDB_DATA_TYPE_SMALLINT
)
{
getStatics_i16
(
primaryKey
,
(
int16_t
*
)
data
,
numOfRow
,
min
,
max
,
sum
,
minIndex
,
maxIndex
,
numOfNull
);
}
else
if
(
type
==
TSDB_DATA_TYPE_INT
)
{
getStatics_i32
(
primaryKey
,
(
int32_t
*
)
data
,
numOfRow
,
min
,
max
,
sum
,
minIndex
,
maxIndex
,
numOfNull
);
}
else
if
(
type
==
TSDB_DATA_TYPE_BIGINT
||
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
getStatics_i64
(
primaryKey
,
(
int64_t
*
)
data
,
numOfRow
,
min
,
max
,
sum
,
minIndex
,
maxIndex
,
numOfNull
);
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
getStatics_d
(
primaryKey
,
(
double
*
)
data
,
numOfRow
,
(
double
*
)
min
,
(
double
*
)
max
,
(
double
*
)
sum
,
minIndex
,
maxIndex
,
numOfNull
);
}
else
if
(
type
==
TSDB_DATA_TYPE_FLOAT
)
{
getStatics_f
(
primaryKey
,
(
float
*
)
data
,
numOfRow
,
(
double
*
)
min
,
(
double
*
)
max
,
(
double
*
)
sum
,
minIndex
,
maxIndex
,
numOfNull
);
}
}
}
/**
* param[1]: start time
...
...
src/common/src/ttypes.c
浏览文件 @
5ae9ed74
...
...
@@ -32,18 +32,280 @@ const int32_t TYPE_BYTES[11] = {
sizeof
(
VarDataOffsetT
)
// TSDB_DATA_TYPE_NCHAR
};
static
void
getStatics_i8
(
const
TSKEY
*
primaryKey
,
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
);
// int64_t lastKey = 0;
// int8_t lastVal = TSDB_DATA_TINYINT_NULL;
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
((
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_TINYINT
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
*
sum
+=
data
[
i
];
if
(
*
min
>
data
[
i
])
{
*
min
=
data
[
i
];
*
minIndex
=
i
;
}
if
(
*
max
<
data
[
i
])
{
*
max
=
data
[
i
];
*
maxIndex
=
i
;
}
}
}
static
void
getStatics_i16
(
const
TSKEY
*
primaryKey
,
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
);
// int64_t lastKey = 0;
// int16_t lastVal = TSDB_DATA_SMALLINT_NULL;
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
((
const
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_SMALLINT
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
*
sum
+=
data
[
i
];
if
(
*
min
>
data
[
i
])
{
*
min
=
data
[
i
];
*
minIndex
=
i
;
}
if
(
*
max
<
data
[
i
])
{
*
max
=
data
[
i
];
*
maxIndex
=
i
;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_SMALLINT)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
}
}
static
void
getStatics_i32
(
const
TSKEY
*
primaryKey
,
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
);
// int64_t lastKey = 0;
// int32_t lastVal = TSDB_DATA_INT_NULL;
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
((
const
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_INT
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
*
sum
+=
data
[
i
];
if
(
*
min
>
data
[
i
])
{
*
min
=
data
[
i
];
*
minIndex
=
i
;
}
if
(
*
max
<
data
[
i
])
{
*
max
=
data
[
i
];
*
maxIndex
=
i
;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_INT)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
}
}
static
void
getStatics_i64
(
const
TSKEY
*
primaryKey
,
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
(
isNull
((
const
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_BIGINT
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
*
sum
+=
data
[
i
];
if
(
*
min
>
data
[
i
])
{
*
min
=
data
[
i
];
*
minIndex
=
i
;
}
if
(
*
max
<
data
[
i
])
{
*
max
=
data
[
i
];
*
maxIndex
=
i
;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_BIGINT)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
}
}
static
void
getStatics_f
(
const
TSKEY
*
primaryKey
,
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
=
DBL_MAX
;
float
fmax
=
-
DBL_MAX
;
double
dsum
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
ASSERT
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
if
(
isNull
((
const
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_FLOAT
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
float
fv
=
0
;
fv
=
GET_FLOAT_VAL
(
&
(
data
[
i
]));
dsum
+=
fv
;
if
(
fmin
>
fv
)
{
fmin
=
fv
;
*
minIndex
=
i
;
}
if
(
fmax
<
fv
)
{
fmax
=
fv
;
*
maxIndex
=
i
;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_FLOAT)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
}
double
csum
=
0
;
csum
=
GET_DOUBLE_VAL
(
sum
);
csum
+=
dsum
;
#ifdef _TD_ARM_32_
SET_DOUBLE_VAL_ALIGN
(
sum
,
&
csum
);
SET_DOUBLE_VAL_ALIGN
(
max
,
&
fmax
);
SET_DOUBLE_VAL_ALIGN
(
min
,
&
fmin
);
#else
*
sum
=
csum
;
*
max
=
fmax
;
*
min
=
fmin
;
#endif
}
static
void
getStatics_d
(
const
TSKEY
*
primaryKey
,
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
(
isNull
((
const
char
*
)
&
data
[
i
],
TSDB_DATA_TYPE_DOUBLE
))
{
(
*
numOfNull
)
+=
1
;
continue
;
}
double
dv
=
0
;
dv
=
GET_DOUBLE_VAL
(
&
(
data
[
i
]));
dsum
+=
dv
;
if
(
dmin
>
dv
)
{
dmin
=
dv
;
*
minIndex
=
i
;
}
if
(
dmax
<
dv
)
{
dmax
=
dv
;
*
maxIndex
=
i
;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_DOUBLE)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
}
double
csum
=
0
;
csum
=
GET_DOUBLE_VAL
(
sum
);
csum
+=
dsum
;
#ifdef _TD_ARM_32_
SET_DOUBLE_VAL_ALIGN
(
sum
,
&
csum
);
SET_DOUBLE_VAL_ALIGN
(
max
,
&
dmax
);
SET_DOUBLE_VAL_ALIGN
(
min
,
&
dmin
);
#else
*
sum
=
csum
;
*
max
=
dmax
;
*
min
=
dmin
;
#endif
}
tDataTypeDescriptor
tDataTypeDesc
[
11
]
=
{
{
TSDB_DATA_TYPE_NULL
,
6
,
1
,
"NOTYPE"
,
NULL
,
NULL
},
{
TSDB_DATA_TYPE_BOOL
,
4
,
CHAR_BYTES
,
"BOOL"
,
tsCompressBool
,
tsDecompressBool
},
{
TSDB_DATA_TYPE_TINYINT
,
7
,
CHAR_BYTES
,
"TINYINT"
,
tsCompressTinyint
,
tsDecompressTinyint
},
{
TSDB_DATA_TYPE_SMALLINT
,
8
,
SHORT_BYTES
,
"SMALLINT"
,
tsCompressSmallint
,
tsDecompressSmallint
},
{
TSDB_DATA_TYPE_INT
,
3
,
INT_BYTES
,
"INT"
,
tsCompressInt
,
tsDecompressInt
},
{
TSDB_DATA_TYPE_BIGINT
,
6
,
LONG_BYTES
,
"BIGINT"
,
tsCompressBigint
,
tsDecompressBigint
},
{
TSDB_DATA_TYPE_FLOAT
,
5
,
FLOAT_BYTES
,
"FLOAT"
,
tsCompressFloat
,
tsDecompressFloat
},
{
TSDB_DATA_TYPE_DOUBLE
,
6
,
DOUBLE_BYTES
,
"DOUBLE"
,
tsCompressDouble
,
tsDecompressDouble
},
{
TSDB_DATA_TYPE_BINARY
,
6
,
0
,
"BINARY"
,
tsCompressString
,
tsDecompressString
},
{
TSDB_DATA_TYPE_TIMESTAMP
,
9
,
LONG_BYTES
,
"TIMESTAMP"
,
tsCompressTimestamp
,
tsDecompressTimestamp
},
{
TSDB_DATA_TYPE_NCHAR
,
5
,
8
,
"NCHAR"
,
tsCompressString
,
tsDecompressString
},
{
TSDB_DATA_TYPE_NULL
,
6
,
1
,
"NOTYPE"
,
NULL
,
NULL
,
NULL
},
{
TSDB_DATA_TYPE_BOOL
,
4
,
CHAR_BYTES
,
"BOOL"
,
tsCompressBool
,
tsDecompressBool
,
NULL
},
{
TSDB_DATA_TYPE_TINYINT
,
7
,
CHAR_BYTES
,
"TINYINT"
,
tsCompressTinyint
,
tsDecompressTinyint
,
getStatics_i8
},
{
TSDB_DATA_TYPE_SMALLINT
,
8
,
SHORT_BYTES
,
"SMALLINT"
,
tsCompressSmallint
,
tsDecompressSmallint
,
getStatics_i16
},
{
TSDB_DATA_TYPE_INT
,
3
,
INT_BYTES
,
"INT"
,
tsCompressInt
,
tsDecompressInt
,
getStatics_i32
},
{
TSDB_DATA_TYPE_BIGINT
,
6
,
LONG_BYTES
,
"BIGINT"
,
tsCompressBigint
,
tsDecompressBigint
,
getStatics_i64
},
{
TSDB_DATA_TYPE_FLOAT
,
5
,
FLOAT_BYTES
,
"FLOAT"
,
tsCompressFloat
,
tsDecompressFloat
,
getStatics_f
},
{
TSDB_DATA_TYPE_DOUBLE
,
6
,
DOUBLE_BYTES
,
"DOUBLE"
,
tsCompressDouble
,
tsDecompressDouble
,
getStatics_d
},
{
TSDB_DATA_TYPE_BINARY
,
6
,
0
,
"BINARY"
,
tsCompressString
,
tsDecompressString
,
NULL
},
{
TSDB_DATA_TYPE_TIMESTAMP
,
9
,
LONG_BYTES
,
"TIMESTAMP"
,
tsCompressTimestamp
,
tsDecompressTimestamp
,
NULL
},
{
TSDB_DATA_TYPE_NCHAR
,
5
,
8
,
"NCHAR"
,
tsCompressString
,
tsDecompressString
,
NULL
},
};
char
tTokenTypeSwitcher
[
13
]
=
{
...
...
src/inc/taosdef.h
浏览文件 @
5ae9ed74
...
...
@@ -147,6 +147,8 @@ typedef struct tDataTypeDescriptor {
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
(
*
decompFunc
)(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
void
(
*
getStatisFunc
)(
const
TSKEY
*
primaryKey
,
const
void
*
pData
,
int32_t
numofrow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minindex
,
int16_t
*
maxindex
,
int16_t
*
numofnull
);
}
tDataTypeDescriptor
;
extern
tDataTypeDescriptor
tDataTypeDesc
[
11
];
...
...
src/tsdb/inc/tsdbMain.h
浏览文件 @
5ae9ed74
...
...
@@ -325,6 +325,13 @@ typedef struct {
int16_t
len
;
// Column length // TODO: int16_t is not enough
int32_t
type
:
8
;
int32_t
offset
:
24
;
int64_t
sum
;
int64_t
max
;
int64_t
min
;
int16_t
maxIndex
;
int16_t
minIndex
;
int16_t
numOfNull
;
char
padding
[
2
];
}
SCompCol
;
// TODO: Take recover into account
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
5ae9ed74
...
...
@@ -703,6 +703,11 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
pCompCol
->
colId
=
pDataCol
->
colId
;
pCompCol
->
type
=
pDataCol
->
type
;
if
(
tDataTypeDesc
[
pDataCol
->
type
].
getStatisFunc
)
{
(
*
tDataTypeDesc
[
pDataCol
->
type
].
getStatisFunc
)(
(
TSKEY
*
)(
pDataCols
->
cols
[
0
].
pData
),
pDataCol
->
pData
,
rowsToWrite
,
&
(
pCompCol
->
min
),
&
(
pCompCol
->
max
),
&
(
pCompCol
->
sum
),
&
(
pCompCol
->
minIndex
),
&
(
pCompCol
->
maxIndex
),
&
(
pCompCol
->
numOfNull
));
}
nColsNotAllNull
++
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录