Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a9db4f82
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看板
未验证
提交
a9db4f82
编写于
8月 02, 2021
作者:
H
Haojun Liao
提交者:
GitHub
8月 02, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7088 from taosdata/fix/ZhiqiangWang/TD-5547-arm32-byte-alignment-error
[TD-5547]<fix>: arm32 byte alignment bus error.
上级
699e28bc
29f6538b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
45 addition
and
23 deletion
+45
-23
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+45
-23
未找到文件。
src/query/src/qAggMain.c
浏览文件 @
a9db4f82
...
...
@@ -512,6 +512,28 @@ int32_t countRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
int32_t
noDataRequired
(
SQLFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
return
BLK_DATA_NO_NEEDED
;
}
#define LIST_ADD_N_DOUBLE_FLOAT(x, ctx, p, t, numOfElem, tsdbType) \
do { \
t *d = (t *)(p); \
for (int32_t i = 0; i < (ctx)->size; ++i) { \
if (((ctx)->hasNull) && isNull((char *)&(d)[i], tsdbType)) { \
continue; \
}; \
SET_DOUBLE_VAL(&(x) , GET_DOUBLE_VAL(&(x)) + GET_FLOAT_VAL(&(d)[i])); \
(numOfElem)++; \
} \
} while(0)
#define LIST_ADD_N_DOUBLE(x, ctx, p, t, numOfElem, tsdbType) \
do { \
t *d = (t *)(p); \
for (int32_t i = 0; i < (ctx)->size; ++i) { \
if (((ctx)->hasNull) && isNull((char *)&(d)[i], tsdbType)) { \
continue; \
}; \
SET_DOUBLE_VAL(&(x) , (x) + (d)[i]); \
(numOfElem)++; \
} \
} while(0)
#define LIST_ADD_N(x, ctx, p, t, numOfElem, tsdbType) \
do { \
...
...
@@ -575,7 +597,7 @@ static void do_sum(SQLFunctionCtx *pCtx) {
*
retVal
+=
(
uint64_t
)
pCtx
->
preAggVals
.
statis
.
sum
;
}
else
if
(
IS_FLOAT_TYPE
(
pCtx
->
inputType
))
{
double
*
retVal
=
(
double
*
)
pCtx
->
pOutput
;
*
retVal
+=
GET_DOUBLE_VAL
((
const
char
*
)
&
(
pCtx
->
preAggVals
.
statis
.
sum
));
SET_DOUBLE_VAL
(
retVal
,
*
retVal
+
GET_DOUBLE_VAL
((
const
char
*
)
&
(
pCtx
->
preAggVals
.
statis
.
sum
)
));
}
}
else
{
// computing based on the true data block
void
*
pData
=
GET_INPUT_DATA_LIST
(
pCtx
);
...
...
@@ -607,10 +629,10 @@ static void do_sum(SQLFunctionCtx *pCtx) {
}
}
else
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
*
retVal
=
(
double
*
)
pCtx
->
pOutput
;
LIST_ADD_N
(
*
retVal
,
pCtx
,
pData
,
double
,
notNullElems
,
pCtx
->
inputType
);
LIST_ADD_N
_DOUBLE
(
*
retVal
,
pCtx
,
pData
,
double
,
notNullElems
,
pCtx
->
inputType
);
}
else
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_FLOAT
)
{
double
*
retVal
=
(
double
*
)
pCtx
->
pOutput
;
LIST_ADD_N
(
*
retVal
,
pCtx
,
pData
,
float
,
notNullElems
,
pCtx
->
inputType
);
LIST_ADD_N
_DOUBLE_FLOAT
(
*
retVal
,
pCtx
,
pData
,
float
,
notNullElems
,
pCtx
->
inputType
);
}
}
...
...
@@ -654,7 +676,7 @@ static void sum_func_merge(SQLFunctionCtx *pCtx) {
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
*
(
uint64_t
*
)
pCtx
->
pOutput
+=
pInput
->
usum
;
}
else
{
*
(
double
*
)
pCtx
->
pOutput
+=
pInput
->
dsum
;
SET_DOUBLE_VAL
((
double
*
)
pCtx
->
pOutput
,
*
(
double
*
)
pCtx
->
pOutput
+
pInput
->
dsum
)
;
}
}
...
...
@@ -778,9 +800,9 @@ static void avg_function(SQLFunctionCtx *pCtx) {
}
else
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_BIGINT
)
{
LIST_ADD_N
(
*
pVal
,
pCtx
,
pData
,
int64_t
,
notNullElems
,
pCtx
->
inputType
);
}
else
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_DOUBLE
)
{
LIST_ADD_N
(
*
pVal
,
pCtx
,
pData
,
double
,
notNullElems
,
pCtx
->
inputType
);
LIST_ADD_N
_DOUBLE
(
*
pVal
,
pCtx
,
pData
,
double
,
notNullElems
,
pCtx
->
inputType
);
}
else
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_FLOAT
)
{
LIST_ADD_N
(
*
pVal
,
pCtx
,
pData
,
float
,
notNullElems
,
pCtx
->
inputType
);
LIST_ADD_N
_DOUBLE_FLOAT
(
*
pVal
,
pCtx
,
pData
,
float
,
notNullElems
,
pCtx
->
inputType
);
}
else
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_UTINYINT
)
{
LIST_ADD_N
(
*
pVal
,
pCtx
,
pData
,
uint8_t
,
notNullElems
,
pCtx
->
inputType
);
}
else
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_USMALLINT
)
{
...
...
@@ -821,7 +843,7 @@ static void avg_func_merge(SQLFunctionCtx *pCtx) {
continue
;
}
*
sum
+=
pInput
->
sum
;
SET_DOUBLE_VAL
(
sum
,
*
sum
+
pInput
->
sum
)
;
// keep the number of data into the temp buffer
*
(
int64_t
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
)
+=
pInput
->
num
;
...
...
@@ -842,7 +864,7 @@ static void avg_finalizer(SQLFunctionCtx *pCtx) {
return
;
}
*
(
double
*
)
pCtx
->
pOutput
=
(
*
(
double
*
)
pCtx
->
pOutput
)
/
*
(
int64_t
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
SET_DOUBLE_VAL
((
double
*
)
pCtx
->
pOutput
,(
*
(
double
*
)
pCtx
->
pOutput
)
/
*
(
int64_t
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
)
);
}
else
{
// this is the secondary merge, only in the secondary merge, the input type is TSDB_DATA_TYPE_BINARY
assert
(
IS_NUMERIC_TYPE
(
pCtx
->
inputType
));
SAvgInfo
*
pAvgInfo
=
(
SAvgInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
...
@@ -852,7 +874,7 @@ static void avg_finalizer(SQLFunctionCtx *pCtx) {
return
;
}
*
(
double
*
)
pCtx
->
pOutput
=
pAvgInfo
->
sum
/
pAvgInfo
->
num
;
SET_DOUBLE_VAL
((
double
*
)
pCtx
->
pOutput
,
pAvgInfo
->
sum
/
pAvgInfo
->
num
)
;
}
// cannot set the numOfIteratedElems again since it is set during previous iteration
...
...
@@ -1049,7 +1071,7 @@ static bool min_func_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResultInfo
*
((
float
*
)
pCtx
->
pOutput
)
=
FLT_MAX
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
*
((
double
*
)
pCtx
->
pOutput
)
=
DBL_MAX
;
SET_DOUBLE_VAL
(((
double
*
)
pCtx
->
pOutput
),
DBL_MAX
)
;
break
;
default:
qError
(
"illegal data type:%d in min/max query"
,
pCtx
->
inputType
);
...
...
@@ -1076,7 +1098,7 @@ static bool max_func_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResultInfo
*
((
float
*
)
pCtx
->
pOutput
)
=
-
FLT_MAX
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
*
((
double
*
)
pCtx
->
pOutput
)
=
-
DBL_MAX
;
SET_DOUBLE_VAL
(((
double
*
)
pCtx
->
pOutput
),
-
DBL_MAX
)
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
*
((
int64_t
*
)
pCtx
->
pOutput
)
=
INT64_MIN
;
...
...
@@ -1322,7 +1344,7 @@ static void stddev_finalizer(SQLFunctionCtx *pCtx) {
setNull
(
pCtx
->
pOutput
,
pCtx
->
outputType
,
pCtx
->
outputBytes
);
}
else
{
double
*
retValue
=
(
double
*
)
pCtx
->
pOutput
;
*
retValue
=
sqrt
(
pStd
->
res
/
pStd
->
num
);
SET_DOUBLE_VAL
(
retValue
,
sqrt
(
pStd
->
res
/
pStd
->
num
)
);
SET_VAL
(
pCtx
,
1
,
1
);
}
...
...
@@ -1455,7 +1477,7 @@ static void stddev_dst_finalizer(SQLFunctionCtx *pCtx) {
setNull
(
pCtx
->
pOutput
,
pCtx
->
outputType
,
pCtx
->
outputBytes
);
}
else
{
double
*
retValue
=
(
double
*
)
pCtx
->
pOutput
;
*
retValue
=
sqrt
(
pStd
->
res
/
pStd
->
num
);
SET_DOUBLE_VAL
(
retValue
,
sqrt
(
pStd
->
res
/
pStd
->
num
)
);
SET_VAL
(
pCtx
,
1
,
1
);
}
...
...
@@ -1947,7 +1969,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
*
output
=
(
double
*
)
pCtx
->
pOutput
;
for
(
int32_t
i
=
0
;
i
<
len
;
++
i
,
output
+=
step
)
{
*
output
=
tvp
[
i
]
->
v
.
dKey
;
SET_DOUBLE_VAL
(
output
,
tvp
[
i
]
->
v
.
dKey
)
;
}
break
;
}
...
...
@@ -2366,7 +2388,7 @@ static void percentile_finalizer(SQLFunctionCtx *pCtx) {
assert
(
ppInfo
->
numOfElems
==
0
);
setNull
(
pCtx
->
pOutput
,
pCtx
->
outputType
,
pCtx
->
outputBytes
);
}
else
{
*
(
double
*
)
pCtx
->
pOutput
=
getPercentile
(
pMemBucket
,
v
);
SET_DOUBLE_VAL
((
double
*
)
pCtx
->
pOutput
,
getPercentile
(
pMemBucket
,
v
)
);
}
tMemBucketDestroy
(
pMemBucket
);
...
...
@@ -2782,7 +2804,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
!
pDerivInfo
->
valueSet
)
{
// initial value is not set yet
pDerivInfo
->
valueSet
=
true
;
}
else
{
*
pOutput
=
((
pData
[
i
]
-
pDerivInfo
->
prevValue
)
*
pDerivInfo
->
tsWindow
)
/
(
tsList
[
i
]
-
pDerivInfo
->
prevTs
);
SET_DOUBLE_VAL
(
pOutput
,
((
pData
[
i
]
-
pDerivInfo
->
prevValue
)
*
pDerivInfo
->
tsWindow
)
/
(
tsList
[
i
]
-
pDerivInfo
->
prevTs
)
);
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
...
...
@@ -3017,7 +3039,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
}
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
*
pOutput
=
pData
[
i
]
-
pCtx
->
param
[
1
].
dKey
;
// direct previous may be null
SET_DOUBLE_VAL
(
pOutput
,
pData
[
i
]
-
pCtx
->
param
[
1
].
dKey
)
;
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
...
...
@@ -3290,7 +3312,7 @@ void spread_function_finalizer(SQLFunctionCtx *pCtx) {
return
;
}
*
(
double
*
)
pCtx
->
pOutput
=
pCtx
->
param
[
3
].
dKey
-
pCtx
->
param
[
0
].
dKey
;
SET_DOUBLE_VAL
((
double
*
)
pCtx
->
pOutput
,
pCtx
->
param
[
3
].
dKey
-
pCtx
->
param
[
0
].
dKey
)
;
}
else
{
assert
(
IS_NUMERIC_TYPE
(
pCtx
->
inputType
)
||
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_TIMESTAMP
));
...
...
@@ -3300,7 +3322,7 @@ void spread_function_finalizer(SQLFunctionCtx *pCtx) {
return
;
}
*
(
double
*
)
pCtx
->
pOutput
=
pInfo
->
max
-
pInfo
->
min
;
SET_DOUBLE_VAL
((
double
*
)
pCtx
->
pOutput
,
pInfo
->
max
-
pInfo
->
min
)
;
}
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
1
;
// todo add test case
...
...
@@ -3628,9 +3650,9 @@ void twa_function_finalizer(SQLFunctionCtx *pCtx) {
assert
(
pInfo
->
win
.
ekey
==
pInfo
->
p
.
key
&&
pInfo
->
hasResult
==
pResInfo
->
hasResult
);
if
(
pInfo
->
win
.
ekey
==
pInfo
->
win
.
skey
)
{
*
(
double
*
)
pCtx
->
pOutput
=
pInfo
->
p
.
val
;
SET_DOUBLE_VAL
((
double
*
)
pCtx
->
pOutput
,
pInfo
->
p
.
val
)
;
}
else
{
*
(
double
*
)
pCtx
->
pOutput
=
pInfo
->
dOutput
/
(
pInfo
->
win
.
ekey
-
pInfo
->
win
.
skey
);
SET_DOUBLE_VAL
((
double
*
)
pCtx
->
pOutput
,
pInfo
->
dOutput
/
(
pInfo
->
win
.
ekey
-
pInfo
->
win
.
skey
)
);
}
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
1
;
...
...
@@ -3923,7 +3945,7 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) {
return
;
}
*
(
double
*
)
pCtx
->
pOutput
=
do_calc_rate
(
pRateInfo
,
(
double
)
TSDB_TICK_PER_SECOND
(
pCtx
->
param
[
0
].
i64
));
SET_DOUBLE_VAL
((
double
*
)
pCtx
->
pOutput
,
do_calc_rate
(
pRateInfo
,
(
double
)
TSDB_TICK_PER_SECOND
(
pCtx
->
param
[
0
].
i64
)
));
// cannot set the numOfIteratedElems again since it is set during previous iteration
pResInfo
->
numOfRes
=
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录