Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
01b178eb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
01b178eb
编写于
11月 01, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-10564]refactor unary function.
上级
59219933
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
13 deletion
+29
-13
source/libs/function/inc/tbinoperator.h
source/libs/function/inc/tbinoperator.h
+1
-0
source/libs/function/src/tbinoperator.c
source/libs/function/src/tbinoperator.c
+4
-0
source/libs/function/src/tscalarfunction.c
source/libs/function/src/tscalarfunction.c
+20
-13
source/libs/function/src/tunaryoperator.c
source/libs/function/src/tunaryoperator.c
+4
-0
未找到文件。
source/libs/function/inc/tbinoperator.h
浏览文件 @
01b178eb
...
...
@@ -24,6 +24,7 @@ extern "C" {
typedef
void
(
*
_bin_scalar_fn_t
)(
SScalarFuncParam
*
pLeft
,
SScalarFuncParam
*
pRight
,
void
*
output
,
int32_t
order
);
_bin_scalar_fn_t
getBinScalarOperatorFn
(
int32_t
binOperator
);
bool
isBinaryStringOp
(
int32_t
op
);
#ifdef __cplusplus
}
...
...
source/libs/function/src/tbinoperator.c
浏览文件 @
01b178eb
...
...
@@ -482,3 +482,7 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) {
return
NULL
;
}
}
bool
isBinaryStringOp
(
int32_t
op
)
{
return
op
==
TSDB_BINARY_OP_CONCAT
;
}
source/libs/function/src/tscalarfunction.c
浏览文件 @
01b178eb
...
...
@@ -74,6 +74,10 @@ static void setScalarFuncParam(SScalarFuncParam* param, int32_t type, int32_t by
param
->
data
=
pInput
;
}
bool
isStringOp
(
int32_t
op
)
{
return
op
==
TSDB_BINARY_OP_CONCAT
;
}
int32_t
evaluateExprNodeTree
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
SScalarFuncParam
*
pOutput
,
void
*
param
,
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
))
{
if
(
pExprs
==
NULL
)
{
...
...
@@ -87,16 +91,14 @@ int32_t evaluateExprNodeTree(tExprNode* pExprs, int32_t numOfRows, SScalarFuncPa
SScalarFuncParam
leftOutput
=
{
0
};
SScalarFuncParam
rightOutput
=
{
0
};
leftOutput
.
data
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
if
(
pLeft
->
nodeType
==
TEXPR_BINARYEXPR_NODE
||
pLeft
->
nodeType
==
TEXPR_UNARYEXPR_NODE
)
{
leftOutput
.
data
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
evaluateExprNodeTree
(
pLeft
,
numOfRows
,
&
leftOutput
,
param
,
getSourceDataBlock
);
}
// the right output has result from the right child syntax tree
rightOutput
.
data
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
if
(
pRight
->
nodeType
==
TEXPR_BINARYEXPR_NODE
)
{
if
(
pRight
->
nodeType
==
TEXPR_BINARYEXPR_NODE
||
pRight
->
nodeType
==
TEXPR_UNARYEXPR_NODE
)
{
rightOutput
.
data
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
evaluateExprNodeTree
(
pRight
,
numOfRows
,
&
rightOutput
,
param
,
getSourceDataBlock
);
}
...
...
@@ -114,8 +116,6 @@ int32_t evaluateExprNodeTree(tExprNode* pExprs, int32_t numOfRows, SScalarFuncPa
}
else
if
(
pLeft
->
nodeType
==
TEXPR_VALUE_NODE
)
{
SVariant
*
pVar
=
pRight
->
pVal
;
setScalarFuncParam
(
&
left
,
pVar
->
nType
,
pVar
->
nLen
,
&
pVar
->
i
,
1
);
}
else
{
assert
(
0
);
}
if
(
pRight
->
nodeType
==
TEXPR_BINARYEXPR_NODE
||
pRight
->
nodeType
==
TEXPR_UNARYEXPR_NODE
)
{
...
...
@@ -127,14 +127,16 @@ int32_t evaluateExprNodeTree(tExprNode* pExprs, int32_t numOfRows, SScalarFuncPa
}
else
if
(
pRight
->
nodeType
==
TEXPR_VALUE_NODE
)
{
// exprLeft + 12
SVariant
*
pVar
=
pRight
->
pVal
;
setScalarFuncParam
(
&
right
,
pVar
->
nType
,
pVar
->
nLen
,
&
pVar
->
i
,
1
);
}
else
{
assert
(
0
);
}
OperatorFn
(
&
left
,
&
right
,
pOutput
->
data
,
TSDB_ORDER_ASC
);
void
*
outputBuf
=
pOutput
->
data
;
if
(
isStringOp
(
pExprs
->
_node
.
optr
))
{
outputBuf
=
realloc
(
pOutput
->
data
,
(
left
.
bytes
+
right
.
bytes
)
*
left
.
num
);
OperatorFn
(
&
left
,
&
right
,
outputBuf
,
TSDB_ORDER_ASC
);
}
// Set the result info
setScalarFuncParam
(
pOutput
,
TSDB_DATA_TYPE_DOUBLE
,
sizeof
(
double
),
pOutput
->
data
,
numOfRows
);
setScalarFuncParam
(
pOutput
,
TSDB_DATA_TYPE_DOUBLE
,
sizeof
(
double
),
outputBuf
,
numOfRows
);
}
else
if
(
pExprs
->
nodeType
==
TEXPR_UNARYEXPR_NODE
)
{
_unary_scalar_fn_t
OperatorFn
=
getUnaryScalarOperatorFn
(
pExprs
->
_node
.
optr
);
SScalarFuncParam
left
=
{
0
};
...
...
@@ -148,8 +150,13 @@ int32_t evaluateExprNodeTree(tExprNode* pExprs, int32_t numOfRows, SScalarFuncPa
}
else
if
(
pLeft
->
nodeType
==
TEXPR_VALUE_NODE
)
{
SVariant
*
pVar
=
pLeft
->
pVal
;
setScalarFuncParam
(
&
left
,
pVar
->
nType
,
pVar
->
nLen
,
&
pVar
->
i
,
1
);
}
else
{
assert
(
0
);
}
// reserve enough memory buffer
if
(
isBinaryStringOp
(
pExprs
->
_node
.
optr
))
{
void
*
outputBuf
=
realloc
(
pOutput
->
data
,
left
.
bytes
*
left
.
num
);
assert
(
outputBuf
!=
NULL
);
pOutput
->
data
=
outputBuf
;
}
OperatorFn
(
&
left
,
pOutput
);
...
...
source/libs/function/src/tunaryoperator.c
浏览文件 @
01b178eb
...
...
@@ -165,3 +165,7 @@ _unary_scalar_fn_t getUnaryScalarOperatorFn(int32_t operator) {
assert
(
0
);
}
}
bool
isStringOperatorFn
(
int32_t
op
)
{
return
op
==
TSDB_UNARY_OP_LEN
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录