Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
93b2a931
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
93b2a931
编写于
9月 15, 2021
作者:
X
xywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2573]<enhance>: optimized functionality for unsigned types
上级
039f20ac
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
100 addition
and
294 deletion
+100
-294
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+100
-294
未找到文件。
src/query/src/qAggMain.c
浏览文件 @
93b2a931
...
...
@@ -4233,61 +4233,38 @@ void blockinfo_func_finalizer(SQLFunctionCtx* pCtx) {
doFinalizer
(
pCtx
);
}
void
setTagCtxList
(
SQLFunctionCtx
*
pCtx
)
{
if
(
pCtx
&&
pCtx
->
tagInfo
.
numOfTagCols
>
0
&&
pCtx
->
ptsList
)
{
int32_t
delta
=
4
;
void
*
data
=
GET_INPUT_DATA_LIST
(
pCtx
);
void
*
pData
=
data
;
char
**
p
=
calloc
(
pCtx
->
tagInfo
.
numOfTagCols
,
POINTER_BYTES
);
if
(
p
==
NULL
)
{
return
;
}
for
(
int32_t
j
=
0
;
j
<
pCtx
->
tagInfo
.
numOfTagCols
;
++
j
)
{
p
[
j
]
=
pCtx
->
tagInfo
.
pTagCtxList
[
j
]
->
pOutput
;
}
switch
(
pCtx
->
inputType
)
{
case
TSDB_DATA_TYPE_INT
:
delta
=
sizeof
(
int32_t
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_BIGINT
:
delta
=
sizeof
(
int64_t
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
delta
=
sizeof
(
double
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
delta
=
sizeof
(
float
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
delta
=
sizeof
(
int16_t
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
delta
=
sizeof
(
int8_t
);
break
;
default:
free
(
p
);
return
;
}
for
(
int32_t
j
=
0
;
j
<
pCtx
->
size
;
++
j
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
((
char
*
)
pData
+
j
*
delta
),
pCtx
->
inputType
))
{
continue
;
}
for
(
int32_t
k
=
0
;
k
<
pCtx
->
tagInfo
.
numOfTagCols
;
++
k
)
{
memcpy
(
p
[
k
],
&
pCtx
->
ptsList
[
j
],
(
size_t
)
pCtx
->
tagInfo
.
pTagCtxList
[
k
]
->
outputBytes
);
p
[
k
]
+=
pCtx
->
tagInfo
.
pTagCtxList
[
k
]
->
outputBytes
;
}
}
#define CFR_SET_VAL(type, data, pCtx, func, i, step, notNullElems) \
do { \
type *pData = (type *) data; \
type *pOutput = (type *) pCtx->pOutput; \
\
for (; i < pCtx->size && i >= 0; i += step) { \
if (pCtx->hasNull && isNull((const char*) &pData[i], pCtx->inputType)) { \
continue; \
} \
\
*pOutput++ = (type) func((double) pData[i]); \
\
notNullElems++; \
} \
} while (0)
free
(
p
);
}
}
#define CFR_SET_VAL_DOUBLE(data, pCtx, func, i, step, notNullElems) \
do { \
double *pData = (double *) data; \
double *pOutput = (double *) pCtx->pOutput; \
\
for (; i < pCtx->size && i >= 0; i += step) { \
if (pCtx->hasNull && isNull((const char*) &pData[i], pCtx->inputType)) { \
continue; \
} \
\
SET_DOUBLE_VAL(pOutput, func(pData[i])); \
pOutput++; \
\
notNullElems++; \
} \
} while (0)
static
void
ceil_function
(
SQLFunctionCtx
*
pCtx
)
{
void
*
data
=
GET_INPUT_DATA_LIST
(
pCtx
);
...
...
@@ -4299,101 +4276,43 @@ static void ceil_function(SQLFunctionCtx *pCtx) {
switch
(
pCtx
->
inputType
)
{
case
TSDB_DATA_TYPE_INT
:
{
int32_t
*
pData
=
(
int32_t
*
)
data
;
int32_t
*
pOutput
=
(
int32_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int32_t
)
ceil
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int32_t
,
data
,
pCtx
,
ceil
,
i
,
step
,
notNullElems
);
break
;
};
case
TSDB_DATA_TYPE_UINT
:
{
CFR_SET_VAL
(
uint32_t
,
data
,
pCtx
,
ceil
,
i
,
step
,
notNullElems
);
break
;
};
case
TSDB_DATA_TYPE_BIGINT
:
{
int64_t
*
pData
=
(
int64_t
*
)
data
;
int64_t
*
pOutput
=
(
int64_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int64_t
)
ceil
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int64_t
,
data
,
pCtx
,
ceil
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_UBIGINT
:
{
CFR_SET_VAL
(
uint64_t
,
data
,
pCtx
,
ceil
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
*
pData
=
(
double
*
)
data
;
double
*
pOutput
=
(
double
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
SET_DOUBLE_VAL
(
pOutput
,
ceil
(
pData
[
i
]));
pOutput
++
;
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL_DOUBLE
(
data
,
pCtx
,
ceil
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:
{
float
*
pData
=
(
float
*
)
data
;
float
*
pOutput
=
(
float
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
float
)
ceil
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
float
,
data
,
pCtx
,
ceil
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:
{
int16_t
*
pData
=
(
int16_t
*
)
data
;
int16_t
*
pOutput
=
(
int16_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int16_t
)
ceil
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int16_t
,
data
,
pCtx
,
ceil
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_USMALLINT
:
{
CFR_SET_VAL
(
uint16_t
,
data
,
pCtx
,
ceil
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_TINYINT
:
{
int8_t
*
pData
=
(
int8_t
*
)
data
;
int8_t
*
pOutput
=
(
int8_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int8_t
)
ceil
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int8_t
,
data
,
pCtx
,
ceil
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_UTINYINT
:
{
CFR_SET_VAL
(
uint8_t
,
data
,
pCtx
,
ceil
,
i
,
step
,
notNullElems
);
break
;
}
default:
...
...
@@ -4420,101 +4339,43 @@ static void floor_function(SQLFunctionCtx *pCtx) {
switch
(
pCtx
->
inputType
)
{
case
TSDB_DATA_TYPE_INT
:
{
int32_t
*
pData
=
(
int32_t
*
)
data
;
int32_t
*
pOutput
=
(
int32_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int32_t
)
floor
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int32_t
,
data
,
pCtx
,
floor
,
i
,
step
,
notNullElems
);
break
;
};
case
TSDB_DATA_TYPE_UINT
:
{
CFR_SET_VAL
(
uint32_t
,
data
,
pCtx
,
floor
,
i
,
step
,
notNullElems
);
break
;
};
case
TSDB_DATA_TYPE_BIGINT
:
{
int64_t
*
pData
=
(
int64_t
*
)
data
;
int64_t
*
pOutput
=
(
int64_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int64_t
)
floor
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int64_t
,
data
,
pCtx
,
floor
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_UBIGINT
:
{
CFR_SET_VAL
(
uint64_t
,
data
,
pCtx
,
floor
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
*
pData
=
(
double
*
)
data
;
double
*
pOutput
=
(
double
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
SET_DOUBLE_VAL
(
pOutput
,
floor
(
pData
[
i
]));
pOutput
++
;
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL_DOUBLE
(
data
,
pCtx
,
floor
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:
{
float
*
pData
=
(
float
*
)
data
;
float
*
pOutput
=
(
float
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
float
)
floor
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
float
,
data
,
pCtx
,
floor
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:
{
int16_t
*
pData
=
(
int16_t
*
)
data
;
int16_t
*
pOutput
=
(
int16_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int16_t
)
floor
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int16_t
,
data
,
pCtx
,
floor
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_USMALLINT
:
{
CFR_SET_VAL
(
uint16_t
,
data
,
pCtx
,
floor
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_TINYINT
:
{
int8_t
*
pData
=
(
int8_t
*
)
data
;
int8_t
*
pOutput
=
(
int8_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int8_t
)
floor
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int8_t
,
data
,
pCtx
,
floor
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_UTINYINT
:
{
CFR_SET_VAL
(
uint8_t
,
data
,
pCtx
,
floor
,
i
,
step
,
notNullElems
);
break
;
}
default:
...
...
@@ -4541,101 +4402,43 @@ static void round_function(SQLFunctionCtx *pCtx) {
switch
(
pCtx
->
inputType
)
{
case
TSDB_DATA_TYPE_INT
:
{
int32_t
*
pData
=
(
int32_t
*
)
data
;
int32_t
*
pOutput
=
(
int32_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int32_t
)
round
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int32_t
,
data
,
pCtx
,
round
,
i
,
step
,
notNullElems
);
break
;
};
case
TSDB_DATA_TYPE_UINT
:
{
CFR_SET_VAL
(
uint32_t
,
data
,
pCtx
,
round
,
i
,
step
,
notNullElems
);
break
;
};
case
TSDB_DATA_TYPE_BIGINT
:
{
int64_t
*
pData
=
(
int64_t
*
)
data
;
int64_t
*
pOutput
=
(
int64_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int64_t
)
round
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int64_t
,
data
,
pCtx
,
round
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_UBIGINT
:
{
CFR_SET_VAL
(
uint64_t
,
data
,
pCtx
,
round
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
*
pData
=
(
double
*
)
data
;
double
*
pOutput
=
(
double
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
SET_DOUBLE_VAL
(
pOutput
,
round
(
pData
[
i
]));
pOutput
++
;
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL_DOUBLE
(
data
,
pCtx
,
round
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:
{
float
*
pData
=
(
float
*
)
data
;
float
*
pOutput
=
(
float
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
float
)
round
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
float
,
data
,
pCtx
,
round
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:
{
int16_t
*
pData
=
(
int16_t
*
)
data
;
int16_t
*
pOutput
=
(
int16_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int16_t
)
round
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int16_t
,
data
,
pCtx
,
round
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_USMALLINT
:
{
CFR_SET_VAL
(
uint16_t
,
data
,
pCtx
,
round
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_TINYINT
:
{
int8_t
*
pData
=
(
int8_t
*
)
data
;
int8_t
*
pOutput
=
(
int8_t
*
)
pCtx
->
pOutput
;
for
(;
i
<
pCtx
->
size
&&
i
>=
0
;
i
+=
step
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
*
pOutput
++
=
(
int8_t
)
round
((
double
)
pData
[
i
]);
notNullElems
++
;
}
setTagCtxList
(
pCtx
);
CFR_SET_VAL
(
int8_t
,
data
,
pCtx
,
round
,
i
,
step
,
notNullElems
);
break
;
}
case
TSDB_DATA_TYPE_UTINYINT
:
{
CFR_SET_VAL
(
uint8_t
,
data
,
pCtx
,
round
,
i
,
step
,
notNullElems
);
break
;
}
default:
...
...
@@ -4652,6 +4455,9 @@ static void round_function(SQLFunctionCtx *pCtx) {
}
}
#undef CFR_SET_VAL
#undef CFR_SET_VAL_DOUBLE
/////////////////////////////////////////////////////////////////////////////////////////////
/*
* function compatible list.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录