Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ef0d9262
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看板
提交
ef0d9262
编写于
2月 14, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
ae8e556b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
155 addition
and
9 deletion
+155
-9
include/nodes/nodes.h
include/nodes/nodes.h
+1
-0
source/libs/function/inc/tscalar.h
source/libs/function/inc/tscalar.h
+41
-0
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+1
-1
source/libs/function/src/tbinoperator.c
source/libs/function/src/tbinoperator.c
+5
-7
source/libs/function/src/tscalar.c
source/libs/function/src/tscalar.c
+73
-0
source/libs/function/src/tscalarfunction.c
source/libs/function/src/tscalarfunction.c
+3
-0
source/nodes/src/nodesUtilFuncs.c
source/nodes/src/nodesUtilFuncs.c
+31
-1
未找到文件。
include/nodes/nodes.h
浏览文件 @
ef0d9262
...
...
@@ -337,6 +337,7 @@ SNodeList* nodesListAppend(SNodeList* pList, SNode* pNode);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
SNode
*
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
);
void
nodesDestroyList
(
SNodeList
*
pList
);
void
*
nodesGetValueFromNode
(
SValueNode
*
pNode
);
typedef
enum
EDealRes
{
DEAL_RES_CONTINUE
=
1
,
...
...
source/libs/function/inc/tscalar.h
0 → 100644
浏览文件 @
ef0d9262
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_SCALAR_H
#define TDENGINE_SCALAR_H
#ifdef __cplusplus
extern
"C"
{
#endif
#define sclFatal(...) qFatal(__VA_ARGS__)
#define sclError(...) qError(__VA_ARGS__)
#define sclWarn(...) qWarn(__VA_ARGS__)
#define sclInfo(...) qInfo(__VA_ARGS__)
#define sclDebug(...) qDebug(__VA_ARGS__)
#define sclTrace(...) qTrace(__VA_ARGS__)
#define SCL_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define SCL_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define SCL_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_SCALAR_H
source/libs/function/src/taggfunction.c
浏览文件 @
ef0d9262
...
...
@@ -3243,7 +3243,7 @@ static void arithmetic_function(SqlFunctionCtx *pCtx) {
SScalarFuncParam
output
=
{
0
};
output
.
data
=
pCtx
->
pOutput
;
evaluateExprNodeTree
(
pSup
->
pExprInfo
->
pExpr
,
pCtx
->
size
,
&
output
,
pSup
,
getArithColumnData
);
//
evaluateExprNodeTree(pSup->pExprInfo->pExpr, pCtx->size, &output, pSup, getArithColumnData);
}
#define LIST_MINMAX_N(ctx, minOutput, maxOutput, elemCnt, data, type, tsdbType, numOfNotNullElem) \
...
...
source/libs/function/src/tbinoperator.c
浏览文件 @
ef0d9262
...
...
@@ -465,18 +465,16 @@ void vectorConcat(SScalarFuncParam* pLeft, SScalarFuncParam* pRight, void *out,
_bin_scalar_fn_t
getBinScalarOperatorFn
(
int32_t
binFunctionId
)
{
switch
(
binFunctionId
)
{
case
TSDB_BINARY_OP
_ADD
:
case
OP_TYPE
_ADD
:
return
vectorAdd
;
case
TSDB_BINARY_OP_SUBTRACT
:
case
OP_TYPE_SUB
:
return
vectorSub
;
case
TSDB_BINARY_OP_MULTIPLY
:
case
OP_TYPE_MULTI
:
return
vectorMultiply
;
case
TSDB_BINARY_OP_DIVIDE
:
case
OP_TYPE_DIV
:
return
vectorDivide
;
case
TSDB_BINARY_OP_REMAINDER
:
case
OP_TYPE_MOD
:
return
vectorRemainder
;
case
TSDB_BINARY_OP_CONCAT
:
return
vectorConcat
;
default:
assert
(
0
);
return
NULL
;
...
...
source/libs/function/src/tscalar.c
0 → 100644
浏览文件 @
ef0d9262
#include "nodes.h"
#include "tscalar.h"
EDealRes
sclCalculateConstants
(
SNode
**
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
*
pNode
))
{
return
DEAL_RES_CONTINUE
;
}
if
(
QUERY_NODE_OPERATOR
!=
nodeType
(
*
pNode
))
{
sclError
(
"invalid node type for calculating constants, type:%d"
,
);
*
(
int32_t
*
)
pContext
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
SOperatorNode
*
oper
=
(
SOperatorNode
*
)
*
pNode
;
if
(
NULL
==
oper
->
pLeft
||
NULL
==
oper
->
pRight
)
{
sclError
(
"invalid operation node, left:%p, right:%p"
,
oper
->
pLeft
,
oper
->
pRight
);
*
(
int32_t
*
)
pContext
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
if
(
QUERY_NODE_VALUE
!=
nodeType
(
oper
->
pLeft
)
||
QUERY_NODE_VALUE
!=
nodeType
(
oper
->
pRight
))
{
sclError
(
"invalid operation node, leftType:%d, rightType:%d"
,
nodeType
(
oper
->
pLeft
),
nodeType
(
oper
->
pRight
));
*
(
int32_t
*
)
pContext
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
SValueNode
*
res
=
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
res
)
{
sclError
(
"make value node failed"
);
*
(
int32_t
*
)
pContext
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
}
res
->
node
.
resType
=
oper
->
node
.
resType
;
SValueNode
*
leftValue
=
(
SValueNode
*
)
oper
->
pLeft
;
SValueNode
*
rightValue
=
(
SValueNode
*
)
oper
->
pRight
;
SScalarFuncParam
leftParam
=
{
0
},
rightParam
=
{
0
};
_bin_scalar_fn_t
OperatorFn
=
getBinScalarOperatorFn
(
oper
->
opType
);
setScalarFuncParam
(
&
leftParam
,
leftValue
->
node
.
resType
,
0
,
nodesGetValueFromNode
(
leftValue
),
1
);
setScalarFuncParam
(
&
rightParam
,
rightValue
->
node
.
resType
,
0
,
nodesGetValueFromNode
(
rightValue
),
1
);
OperatorFn
(
&
leftParam
,
&
rightParam
,
nodesGetValueFromNode
(
res
),
TSDB_ORDER_ASC
);
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
res
;
return
DEAL_RES_CONTINUE
;
}
int32_t
scalarCalculateConstants
(
SNode
*
pNode
,
SNode
**
pRes
)
{
if
(
NULL
==
pNode
)
{
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
int32_t
code
=
0
;
nodesRewriteNodePostOrder
(
&
pNode
,
sclCalculateConstants
,
(
void
*
)
&
code
);
if
(
code
)
{
nodesDestroyNode
(
pNode
);
SCL_ERR_RET
(
code
);
}
*
pRes
=
pNode
;
SCL_RET
(
code
);
}
source/libs/function/src/tscalarfunction.c
浏览文件 @
ef0d9262
...
...
@@ -273,6 +273,7 @@ bool isStringOp(int32_t op) {
return
op
==
TSDB_BINARY_OP_CONCAT
;
}
#if 0
int32_t evaluateExprNodeTree(tExprNode* pExprs, int32_t numOfRows, SScalarFuncParam* pOutput, void* param,
char* (*getSourceDataBlock)(void*, const char*, int32_t)) {
if (pExprs == NULL) {
...
...
@@ -361,6 +362,8 @@ int32_t evaluateExprNodeTree(tExprNode* pExprs, int32_t numOfRows, SScalarFuncPa
return 0;
}
#endif
SScalarFunctionInfo
scalarFunc
[
8
]
=
{
{
"ceil"
,
FUNCTION_TYPE_SCALAR
,
FUNCTION_CEIL
,
tceil
},
...
...
source/nodes/src/nodesUtilFuncs.c
浏览文件 @
ef0d9262
...
...
@@ -152,6 +152,36 @@ void nodesDestroyList(SNodeList* pList) {
tfree
(
pList
);
}
void
*
nodesGetValueFromNode
(
SValueNode
*
pNode
)
{
switch
(
pNode
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
return
(
void
*
)
&
pNode
->
datum
.
b
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
(
void
*
)
&
pNode
->
datum
.
i
;
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
return
(
void
*
)
&
pNode
->
datum
.
u
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:
return
(
void
*
)
&
pNode
->
datum
.
d
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
return
(
void
*
)
pNode
->
datum
.
p
;
default:
break
;
}
return
NULL
;
}
bool
nodesIsExprNode
(
const
SNode
*
pNode
)
{
ENodeType
type
=
nodeType
(
pNode
);
return
(
QUERY_NODE_COLUMN
==
type
||
QUERY_NODE_VALUE
==
type
||
QUERY_NODE_OPERATOR
==
type
||
QUERY_NODE_FUNCTION
==
type
);
...
...
@@ -209,4 +239,4 @@ bool nodesIsTimeorderQuery(const SNode* pQuery) {
bool
nodesIsTimelineQuery
(
const
SNode
*
pQuery
)
{
return
false
;
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录