Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
f5bfcc0b
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f5bfcc0b
编写于
3月 29, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-2819]
上级
0e0e6d5a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
46 addition
and
21 deletion
+46
-21
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-2
src/common/inc/texpr.h
src/common/inc/texpr.h
+13
-13
src/common/src/texpr.c
src/common/src/texpr.c
+31
-5
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+1
-1
未找到文件。
src/client/src/tscUtil.c
浏览文件 @
f5bfcc0b
...
...
@@ -1285,8 +1285,6 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) {
for
(
int32_t
j
=
0
;
j
<
pSqlExpr
->
numOfParams
;
++
j
)
{
tVariantDestroy
(
&
pSqlExpr
->
param
[
j
]);
}
tfree
(
pInfo
->
pExpr
->
pExpr
);
}
}
...
...
@@ -1486,6 +1484,7 @@ void tscSqlExprAssign(SExprInfo* dst, const SExprInfo* src) {
assert
(
dst
!=
NULL
&&
src
!=
NULL
);
*
dst
=
*
src
;
dst
->
pExpr
=
exprdup
(
src
->
pExpr
);
memset
(
dst
->
base
.
param
,
0
,
sizeof
(
tVariant
)
*
tListLen
(
dst
->
base
.
param
));
for
(
int32_t
j
=
0
;
j
<
src
->
base
.
numOfParams
;
++
j
)
{
...
...
src/common/inc/texpr.h
浏览文件 @
f5bfcc0b
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_T
AST
_H
#define TDENGINE_T
AST
_H
#ifndef TDENGINE_T
EXPR
_H
#define TDENGINE_T
EXPR
_H
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -64,30 +64,30 @@ typedef struct tExprNode {
struct
{
uint8_t
optr
;
// filter operator
uint8_t
hasPK
;
// 0: do not contain primary filter, 1: contain
void
*
info
;
// support filter operation on this expression only available for leaf node
void
*
info
;
// support filter operation on this expression only available for leaf node
struct
tExprNode
*
pLeft
;
// left child pointer
struct
tExprNode
*
pRight
;
// right child pointer
}
_node
;
struct
SSchema
*
pSchema
;
tVariant
*
pVal
;
tVariant
*
pVal
;
};
}
tExprNode
;
typedef
struct
SExprTraverseSupp
{
__result_filter_fn_t
nodeFilterFn
;
__do_filter_suppl_fn_t
setupInfoFn
;
void
*
pExtInfo
;
void
*
pExtInfo
;
}
SExprTraverseSupp
;
void
tExprTreeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
));
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
tExprNode
*
exprTreeFromBinary
(
const
void
*
data
,
size_t
size
);
tExprNode
*
exprTreeFromTableName
(
const
char
*
tbnameCond
);
tExprNode
*
exprdup
(
tExprNode
*
pTree
);
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
bool
exprTreeApplayFilter
(
tExprNode
*
pExpr
,
const
void
*
pItem
,
SExprTraverseSupp
*
param
);
bool
exprTreeApplyFilter
(
tExprNode
*
pExpr
,
const
void
*
pItem
,
SExprTraverseSupp
*
param
);
typedef
void
(
*
_arithmetic_operator_fn_t
)(
void
*
left
,
int32_t
numLeft
,
int32_t
leftType
,
void
*
right
,
int32_t
numRight
,
int32_t
rightType
,
void
*
output
,
int32_t
order
);
...
...
@@ -99,4 +99,4 @@ void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
}
#endif
#endif // TDENGINE_T
AST
_H
#endif // TDENGINE_T
EXPR
_H
src/common/src/texpr.c
浏览文件 @
f5bfcc0b
...
...
@@ -15,6 +15,7 @@
#include "os.h"
#include "texpr.h"
#include "exception.h"
#include "taosdef.h"
#include "taosmsg.h"
...
...
@@ -145,25 +146,25 @@ static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) {
*
pExpr
=
NULL
;
}
bool
exprTreeAppl
a
yFilter
(
tExprNode
*
pExpr
,
const
void
*
pItem
,
SExprTraverseSupp
*
param
)
{
bool
exprTreeApplyFilter
(
tExprNode
*
pExpr
,
const
void
*
pItem
,
SExprTraverseSupp
*
param
)
{
tExprNode
*
pLeft
=
pExpr
->
_node
.
pLeft
;
tExprNode
*
pRight
=
pExpr
->
_node
.
pRight
;
//non-leaf nodes, recursively traverse the expression tree in the post-root order
if
(
pLeft
->
nodeType
==
TSQL_NODE_EXPR
&&
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
if
(
pExpr
->
_node
.
optr
==
TSDB_RELATION_OR
)
{
// or
if
(
exprTreeAppl
a
yFilter
(
pLeft
,
pItem
,
param
))
{
if
(
exprTreeApplyFilter
(
pLeft
,
pItem
,
param
))
{
return
true
;
}
// left child does not satisfy the query condition, try right child
return
exprTreeAppl
a
yFilter
(
pRight
,
pItem
,
param
);
return
exprTreeApplyFilter
(
pRight
,
pItem
,
param
);
}
else
{
// and
if
(
!
exprTreeAppl
a
yFilter
(
pLeft
,
pItem
,
param
))
{
if
(
!
exprTreeApplyFilter
(
pLeft
,
pItem
,
param
))
{
return
false
;
}
return
exprTreeAppl
a
yFilter
(
pRight
,
pItem
,
param
);
return
exprTreeApplyFilter
(
pRight
,
pItem
,
param
);
}
}
...
...
@@ -463,3 +464,28 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
CLEANUP_EXECUTE_TO
(
anchor
,
false
);
return
expr
;
}
tExprNode
*
exprdup
(
tExprNode
*
pTree
)
{
if
(
pTree
==
NULL
)
{
return
NULL
;
}
tExprNode
*
pNode
=
calloc
(
1
,
sizeof
(
tExprNode
));
if
(
pTree
->
nodeType
==
TSQL_NODE_EXPR
)
{
tExprNode
*
pLeft
=
exprdup
(
pTree
->
_node
.
pLeft
);
tExprNode
*
pRight
=
exprdup
(
pTree
->
_node
.
pRight
);
pNode
->
nodeType
=
TSQL_NODE_EXPR
;
pNode
->
_node
.
pLeft
=
pLeft
;
pNode
->
_node
.
pRight
=
pRight
;
}
else
if
(
pTree
->
nodeType
==
TSQL_NODE_VALUE
)
{
pNode
->
pVal
=
calloc
(
1
,
sizeof
(
tVariant
));
tVariantAssign
(
pNode
->
pVal
,
pTree
->
pVal
);
}
else
if
(
pTree
->
nodeType
==
TSQL_NODE_COL
)
{
pNode
->
pSchema
=
calloc
(
1
,
sizeof
(
SSchema
));
*
pNode
->
pSchema
=
*
pTree
->
pSchema
;
}
return
pNode
;
}
src/tsdb/src/tsdbRead.c
浏览文件 @
f5bfcc0b
...
...
@@ -3428,7 +3428,7 @@ static void applyFilterToSkipListNode(SSkipList *pSkipList, tExprNode *pExpr, SA
// Scan each node in the skiplist by using iterator
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
if
(
exprTreeAppl
a
yFilter
(
pExpr
,
pNode
,
param
))
{
if
(
exprTreeApplyFilter
(
pExpr
,
pNode
,
param
))
{
taosArrayPush
(
pResult
,
&
(
SL_GET_NODE_DATA
(
pNode
)));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录