Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8a2623e9
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8a2623e9
编写于
3月 26, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-14240]<feature>: add math functions
上级
aaa2d209
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
16 deletion
+16
-16
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+4
-4
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+12
-12
未找到文件。
source/libs/scalar/src/sclfunc.c
浏览文件 @
8a2623e9
...
...
@@ -103,7 +103,7 @@ int32_t logFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
char
**
input
=
NULL
,
*
output
=
NULL
;
bool
hasNullInput
=
false
;
input
=
c
alloc
(
inputNum
,
sizeof
(
char
*
));
input
=
taosMemoryC
alloc
(
inputNum
,
sizeof
(
char
*
));
for
(
int32_t
i
=
0
;
i
<
pOutput
->
num
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
inputNum
;
++
j
)
{
if
(
pInput
[
j
].
num
==
1
)
{
...
...
@@ -131,7 +131,7 @@ int32_t logFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
SET_TYPED_DATA
(
output
,
pOutput
->
type
,
result
);
}
f
ree
(
input
);
taosMemoryF
ree
(
input
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -146,7 +146,7 @@ int32_t powFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
char
**
input
=
NULL
,
*
output
=
NULL
;
bool
hasNullInput
=
false
;
input
=
c
alloc
(
inputNum
,
sizeof
(
char
*
));
input
=
taosMemoryC
alloc
(
inputNum
,
sizeof
(
char
*
));
for
(
int32_t
i
=
0
;
i
<
pOutput
->
num
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
inputNum
;
++
j
)
{
if
(
pInput
[
j
].
num
==
1
)
{
...
...
@@ -174,7 +174,7 @@ int32_t powFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
SET_TYPED_DATA
(
output
,
pOutput
->
type
,
result
);
}
f
ree
(
input
);
taosMemoryF
ree
(
input
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
8a2623e9
...
...
@@ -1442,7 +1442,7 @@ TEST(columnTest, greater_and_lower) {
}
void
scltMakeDataBlock
(
SScalarParam
**
pInput
,
int32_t
type
,
void
*
pVal
,
int32_t
num
,
bool
setVal
)
{
SScalarParam
*
input
=
(
SScalarParam
*
)
c
alloc
(
1
,
sizeof
(
SScalarParam
));
SScalarParam
*
input
=
(
SScalarParam
*
)
taosMemoryC
alloc
(
1
,
sizeof
(
SScalarParam
));
int32_t
bytes
;
switch
(
type
)
{
case
TSDB_DATA_TYPE_TINYINT
:
{
...
...
@@ -1473,7 +1473,7 @@ void scltMakeDataBlock(SScalarParam **pInput, int32_t type, void *pVal, int32_t
input
->
type
=
type
;
input
->
num
=
num
;
input
->
data
=
c
alloc
(
num
,
bytes
);
input
->
data
=
taosMemoryC
alloc
(
num
,
bytes
);
input
->
bytes
=
bytes
;
if
(
setVal
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
...
...
@@ -1487,8 +1487,8 @@ void scltMakeDataBlock(SScalarParam **pInput, int32_t type, void *pVal, int32_t
}
void
scltDestroyDataBlock
(
SScalarParam
*
pInput
)
{
f
ree
(
pInput
->
data
);
f
ree
(
pInput
);
taosMemoryF
ree
(
pInput
->
data
);
taosMemoryF
ree
(
pInput
);
}
TEST
(
ScalarFunctionTest
,
absFunction_constant
)
{
...
...
@@ -2754,7 +2754,7 @@ TEST(ScalarFunctionTest, logFunction_constant) {
int32_t
type
;
int32_t
otype
=
TSDB_DATA_TYPE_DOUBLE
;
double
result
=
3.0
;
pInput
=
(
SScalarParam
*
)
c
alloc
(
2
,
sizeof
(
SScalarParam
));
pInput
=
(
SScalarParam
*
)
taosMemoryC
alloc
(
2
,
sizeof
(
SScalarParam
));
//TINYINT
int8_t
val_tinyint
[]
=
{
27
,
3
};
...
...
@@ -2819,7 +2819,7 @@ TEST(ScalarFunctionTest, logFunction_constant) {
scltDestroyDataBlock
(
input
[
0
]);
scltDestroyDataBlock
(
input
[
1
]);
scltDestroyDataBlock
(
pOutput
);
f
ree
(
pInput
);
taosMemoryF
ree
(
pInput
);
}
TEST
(
ScalarFunctionTest
,
logFunction_column
)
{
...
...
@@ -2830,7 +2830,7 @@ TEST(ScalarFunctionTest, logFunction_column) {
int32_t
type
;
int32_t
otype
=
TSDB_DATA_TYPE_DOUBLE
;
double
result
[]
=
{
2.0
,
4.0
,
3.0
};
pInput
=
(
SScalarParam
*
)
c
alloc
(
2
,
sizeof
(
SScalarParam
));
pInput
=
(
SScalarParam
*
)
taosMemoryC
alloc
(
2
,
sizeof
(
SScalarParam
));
//TINYINT
int8_t
val_tinyint
[
2
][
3
]
=
{{
25
,
81
,
64
},
{
5
,
3
,
4
}};
...
...
@@ -2910,7 +2910,7 @@ TEST(ScalarFunctionTest, logFunction_column) {
scltDestroyDataBlock
(
input
[
0
]);
scltDestroyDataBlock
(
input
[
1
]);
scltDestroyDataBlock
(
pOutput
);
f
ree
(
pInput
);
taosMemoryF
ree
(
pInput
);
}
TEST
(
ScalarFunctionTest
,
powFunction_constant
)
{
...
...
@@ -2921,7 +2921,7 @@ TEST(ScalarFunctionTest, powFunction_constant) {
int32_t
type
;
int32_t
otype
=
TSDB_DATA_TYPE_DOUBLE
;
double
result
=
16.0
;
pInput
=
(
SScalarParam
*
)
c
alloc
(
2
,
sizeof
(
SScalarParam
));
pInput
=
(
SScalarParam
*
)
taosMemoryC
alloc
(
2
,
sizeof
(
SScalarParam
));
//TINYINT
int8_t
val_tinyint
[]
=
{
2
,
4
};
...
...
@@ -2986,7 +2986,7 @@ TEST(ScalarFunctionTest, powFunction_constant) {
scltDestroyDataBlock
(
input
[
0
]);
scltDestroyDataBlock
(
input
[
1
]);
scltDestroyDataBlock
(
pOutput
);
f
ree
(
pInput
);
taosMemoryF
ree
(
pInput
);
}
TEST
(
ScalarFunctionTest
,
powFunction_column
)
{
...
...
@@ -2997,7 +2997,7 @@ TEST(ScalarFunctionTest, powFunction_column) {
int32_t
type
;
int32_t
otype
=
TSDB_DATA_TYPE_DOUBLE
;
double
result
[]
=
{
32.0
,
27.0
,
16.0
};
pInput
=
(
SScalarParam
*
)
c
alloc
(
2
,
sizeof
(
SScalarParam
));
pInput
=
(
SScalarParam
*
)
taosMemoryC
alloc
(
2
,
sizeof
(
SScalarParam
));
//TINYINT
int8_t
val_tinyint
[
2
][
3
]
=
{{
2
,
3
,
4
},
{
5
,
3
,
2
}};
...
...
@@ -3078,7 +3078,7 @@ TEST(ScalarFunctionTest, powFunction_column) {
scltDestroyDataBlock
(
input
[
0
]);
scltDestroyDataBlock
(
input
[
1
]);
scltDestroyDataBlock
(
pOutput
);
f
ree
(
pInput
);
taosMemoryF
ree
(
pInput
);
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录