Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aa556cb4
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aa556cb4
编写于
2月 23, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
b5982c5c
变更
14
显示空白变更内容
内联
并排
Showing
14 changed file
with
312 addition
and
329 deletion
+312
-329
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+0
-44
include/libs/scalar/filter.h
include/libs/scalar/filter.h
+19
-1
include/util/tdef.h
include/util/tdef.h
+45
-31
source/common/src/tname.c
source/common/src/tname.c
+1
-1
source/common/src/ttypes.c
source/common/src/ttypes.c
+1
-1
source/libs/function/src/texpr.c
source/libs/function/src/texpr.c
+6
-5
source/libs/parser/src/parserUtil.c
source/libs/parser/src/parserUtil.c
+20
-20
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+1
-1
source/libs/scalar/inc/filterInt.h
source/libs/scalar/inc/filterInt.h
+4
-24
source/libs/scalar/inc/sclvector.h
source/libs/scalar/inc/sclvector.h
+0
-1
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+187
-168
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+0
-3
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+14
-15
source/util/src/compare.c
source/util/src/compare.c
+14
-14
未找到文件。
include/libs/nodes/querynodes.h
浏览文件 @
aa556cb4
...
...
@@ -81,45 +81,6 @@ typedef struct SValueNode {
}
datum
;
}
SValueNode
;
typedef
enum
EOperatorType
{
// arithmetic operator
OP_TYPE_ADD
=
1
,
OP_TYPE_SUB
,
OP_TYPE_MULTI
,
OP_TYPE_DIV
,
OP_TYPE_MOD
,
// bit operator
OP_TYPE_BIT_AND
,
OP_TYPE_BIT_OR
,
// comparison operator
OP_TYPE_GREATER_THAN
,
OP_TYPE_GREATER_EQUAL
,
OP_TYPE_LOWER_THAN
,
OP_TYPE_LOWER_EQUAL
,
OP_TYPE_EQUAL
,
OP_TYPE_NOT_EQUAL
,
OP_TYPE_IN
,
OP_TYPE_NOT_IN
,
OP_TYPE_LIKE
,
OP_TYPE_NOT_LIKE
,
OP_TYPE_MATCH
,
OP_TYPE_NMATCH
,
OP_TYPE_IS_NULL
,
OP_TYPE_IS_NOT_NULL
,
OP_TYPE_IS_TRUE
,
OP_TYPE_IS_FALSE
,
OP_TYPE_IS_UNKNOWN
,
OP_TYPE_IS_NOT_TRUE
,
OP_TYPE_IS_NOT_FALSE
,
OP_TYPE_IS_NOT_UNKNOWN
,
// json operator
OP_TYPE_JSON_GET_VALUE
,
OP_TYPE_JSON_CONTAINS
}
EOperatorType
;
typedef
struct
SOperatorNode
{
SExprNode
node
;
// QUERY_NODE_OPERATOR
EOperatorType
opType
;
...
...
@@ -127,11 +88,6 @@ typedef struct SOperatorNode {
SNode
*
pRight
;
}
SOperatorNode
;
typedef
enum
ELogicConditionType
{
LOGIC_COND_TYPE_AND
,
LOGIC_COND_TYPE_OR
,
LOGIC_COND_TYPE_NOT
,
}
ELogicConditionType
;
typedef
struct
SLogicConditionNode
{
SExprNode
node
;
// QUERY_NODE_LOGIC_CONDITION
...
...
include/libs/scalar/filter.h
浏览文件 @
aa556cb4
...
...
@@ -20,6 +20,14 @@ extern "C" {
#endif
typedef
struct
SFilterInfo
SFilterInfo
;
typedef
int32_t
(
*
filer_get_col_from_id
)(
void
*
,
int32_t
,
void
**
);
enum
{
FLT_OPTION_NO_REWRITE
=
1
,
FLT_OPTION_TIMESTAMP
=
2
,
FLT_OPTION_NEED_UNIQE
=
4
,
};
typedef
struct
SFilterColumnParam
{
int32_t
numOfCols
;
...
...
@@ -27,6 +35,16 @@ typedef struct SFilterColumnParam{
}
SFilterColumnParam
;
extern
int32_t
filterInitFromNode
(
SNode
*
pNode
,
SFilterInfo
**
pinfo
,
uint32_t
options
);
extern
bool
filterExecute
(
SFilterInfo
*
info
,
SSDataBlock
*
pSrc
,
int8_t
**
p
,
SColumnDataAgg
*
statis
,
int16_t
numOfCols
);
extern
int32_t
filterSetDataFromSlotId
(
SFilterInfo
*
info
,
void
*
param
,
filer_get_col_from_id
fp
);
extern
int32_t
filterSetDataFromColId
(
SFilterInfo
*
info
,
void
*
param
,
filer_get_col_from_id
fp
);
extern
int32_t
filterGetTimeRange
(
SFilterInfo
*
info
,
STimeWindow
*
win
);
extern
int32_t
filterConverNcharColumns
(
SFilterInfo
*
pFilterInfo
,
int32_t
rows
,
bool
*
gotNchar
);
extern
int32_t
filterFreeNcharColumns
(
SFilterInfo
*
pFilterInfo
);
extern
void
filterFreeInfo
(
SFilterInfo
*
info
);
extern
bool
filterRangeExecute
(
SFilterInfo
*
info
,
SColumnDataAgg
*
pDataStatis
,
int32_t
numOfCols
,
int32_t
numOfRows
);
#ifdef __cplusplus
}
#endif
...
...
include/util/tdef.h
浏览文件 @
aa556cb4
...
...
@@ -108,35 +108,52 @@ do { \
(src) = (void *)((char *)src + sizeof(type));\
} while(0)
typedef
enum
EOperatorType
{
// arithmetic operator
OP_TYPE_ADD
=
1
,
OP_TYPE_SUB
,
OP_TYPE_MULTI
,
OP_TYPE_DIV
,
OP_TYPE_MOD
,
// bit operator
OP_TYPE_BIT_AND
,
OP_TYPE_BIT_OR
,
// comparison operator
OP_TYPE_GREATER_THAN
,
OP_TYPE_GREATER_EQUAL
,
OP_TYPE_LOWER_THAN
,
OP_TYPE_LOWER_EQUAL
,
OP_TYPE_EQUAL
,
OP_TYPE_NOT_EQUAL
,
OP_TYPE_IN
,
OP_TYPE_NOT_IN
,
OP_TYPE_LIKE
,
OP_TYPE_NOT_LIKE
,
OP_TYPE_MATCH
,
OP_TYPE_NMATCH
,
OP_TYPE_IS_NULL
,
OP_TYPE_IS_NOT_NULL
,
OP_TYPE_IS_TRUE
,
OP_TYPE_IS_FALSE
,
OP_TYPE_IS_UNKNOWN
,
OP_TYPE_IS_NOT_TRUE
,
OP_TYPE_IS_NOT_FALSE
,
OP_TYPE_IS_NOT_UNKNOWN
,
// json operator
OP_TYPE_JSON_GET_VALUE
,
OP_TYPE_JSON_CONTAINS
}
EOperatorType
;
typedef
enum
ELogicConditionType
{
LOGIC_COND_TYPE_AND
,
LOGIC_COND_TYPE_OR
,
LOGIC_COND_TYPE_NOT
,
}
ELogicConditionType
;
// TODO: check if below is necessary
#define TSDB_RELATION_INVALID 0
#define TSDB_RELATION_LESS 1
#define TSDB_RELATION_GREATER 2
#define TSDB_RELATION_EQUAL 3
#define TSDB_RELATION_LESS_EQUAL 4
#define TSDB_RELATION_GREATER_EQUAL 5
#define TSDB_RELATION_NOT_EQUAL 6
#define TSDB_RELATION_LIKE 7
#define TSDB_RELATION_NOT_LIKE 8
#define TSDB_RELATION_ISNULL 9
#define TSDB_RELATION_NOTNULL 10
#define TSDB_RELATION_IN 11
#define TSDB_RELATION_NOT_IN 12
#define TSDB_RELATION_AND 13
#define TSDB_RELATION_OR 14
#define TSDB_RELATION_NOT 15
#define TSDB_RELATION_MATCH 16
#define TSDB_RELATION_NMATCH 17
#define TSDB_BINARY_OP_ADD 4000
#define TSDB_BINARY_OP_SUBTRACT 4001
#define TSDB_BINARY_OP_MULTIPLY 4002
#define TSDB_BINARY_OP_DIVIDE 4003
#define TSDB_BINARY_OP_REMAINDER 4004
#define TSDB_BINARY_OP_CONCAT 4005
#define FUNCTION_CEIL 4500
#define FUNCTION_FLOOR 4501
...
...
@@ -148,9 +165,6 @@ do { \
#define FUNCTION_LTRIM 4802
#define FUNCTION_RTRIM 4803
#define IS_RELATION_OPTR(op) (((op) >= TSDB_RELATION_LESS) && ((op) < TSDB_RELATION_IN))
#define IS_ARITHMETIC_OPTR(op) (((op) >= TSDB_BINARY_OP_ADD) && ((op) <= TSDB_BINARY_OP_REMAINDER))
#define TSDB_NAME_DELIMITER_LEN 1
#define TSDB_UNI_LEN 24
...
...
source/common/src/tname.c
浏览文件 @
aa556cb4
...
...
@@ -31,7 +31,7 @@ SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFil
}
assert
(
src
->
filterstr
==
0
||
src
->
filterstr
==
1
);
assert
(
!
(
src
->
lowerRelOptr
==
TSDB_RELATION_INVALID
&&
src
->
upperRelOptr
==
TSDB_RELATION_INVALID
));
assert
(
!
(
src
->
lowerRelOptr
==
0
&&
src
->
upperRelOptr
==
0
));
return
pFilter
;
}
...
...
source/common/src/ttypes.c
浏览文件 @
aa556cb4
...
...
@@ -585,7 +585,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
}
void
operateVal
(
void
*
dst
,
void
*
s1
,
void
*
s2
,
int32_t
optr
,
int32_t
type
)
{
if
(
optr
==
TSDB_BINARY_OP
_ADD
)
{
if
(
optr
==
OP_TYPE
_ADD
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_TINYINT
:
*
((
int8_t
*
)
dst
)
=
GET_INT8_VAL
(
s1
)
+
GET_INT8_VAL
(
s2
);
...
...
source/libs/function/src/texpr.c
浏览文件 @
aa556cb4
...
...
@@ -25,6 +25,7 @@
#include "thash.h"
#include "texpr.h"
#include "tvariant.h"
#include "tdef.h"
//static uint8_t UNUSED_FUNC isQueryOnPrimaryKey(const char *primaryColumnName, const tExprNode *pLeft, const tExprNode *pRight) {
// if (pLeft->nodeType == TEXPR_COL_NODE) {
...
...
@@ -94,7 +95,7 @@ bool exprTreeApplyFilter(tExprNode *pExpr, const void *pItem, SExprTraverseSupp
//non-leaf nodes, recursively traverse the expression tree in the post-root order
if
(
pLeft
->
nodeType
==
TEXPR_BINARYEXPR_NODE
&&
pRight
->
nodeType
==
TEXPR_BINARYEXPR_NODE
)
{
if
(
pExpr
->
_node
.
optr
==
TSDB_RELATION
_OR
)
{
// or
if
(
pExpr
->
_node
.
optr
==
LOGIC_COND_TYPE
_OR
)
{
// or
if
(
exprTreeApplyFilter
(
pLeft
,
pItem
,
param
))
{
return
true
;
}
...
...
@@ -255,7 +256,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
if
(
strncmp
(
tbnameCond
,
QUERY_COND_REL_PREFIX_LIKE
,
QUERY_COND_REL_PREFIX_LIKE_LEN
)
==
0
)
{
right
->
nodeType
=
TEXPR_VALUE_NODE
;
expr
->
_node
.
optr
=
TSDB_RELATION
_LIKE
;
expr
->
_node
.
optr
=
OP_TYPE
_LIKE
;
SVariant
*
pVal
=
exception_calloc
(
1
,
sizeof
(
SVariant
));
right
->
pVal
=
pVal
;
size_t
len
=
strlen
(
tbnameCond
+
QUERY_COND_REL_PREFIX_LIKE_LEN
)
+
1
;
...
...
@@ -266,7 +267,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
}
else
if
(
strncmp
(
tbnameCond
,
QUERY_COND_REL_PREFIX_MATCH
,
QUERY_COND_REL_PREFIX_MATCH_LEN
)
==
0
)
{
right
->
nodeType
=
TEXPR_VALUE_NODE
;
expr
->
_node
.
optr
=
TSDB_RELATION
_MATCH
;
expr
->
_node
.
optr
=
OP_TYPE
_MATCH
;
SVariant
*
pVal
=
exception_calloc
(
1
,
sizeof
(
SVariant
));
right
->
pVal
=
pVal
;
size_t
len
=
strlen
(
tbnameCond
+
QUERY_COND_REL_PREFIX_MATCH_LEN
)
+
1
;
...
...
@@ -276,7 +277,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
pVal
->
nLen
=
(
int32_t
)
len
;
}
else
if
(
strncmp
(
tbnameCond
,
QUERY_COND_REL_PREFIX_NMATCH
,
QUERY_COND_REL_PREFIX_NMATCH_LEN
)
==
0
)
{
right
->
nodeType
=
TEXPR_VALUE_NODE
;
expr
->
_node
.
optr
=
TSDB_RELATION
_NMATCH
;
expr
->
_node
.
optr
=
OP_TYPE
_NMATCH
;
SVariant
*
pVal
=
exception_calloc
(
1
,
sizeof
(
SVariant
));
right
->
pVal
=
pVal
;
size_t
len
=
strlen
(
tbnameCond
+
QUERY_COND_REL_PREFIX_NMATCH_LEN
)
+
1
;
...
...
@@ -286,7 +287,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
pVal
->
nLen
=
(
int32_t
)
len
;
}
else
if
(
strncmp
(
tbnameCond
,
QUERY_COND_REL_PREFIX_IN
,
QUERY_COND_REL_PREFIX_IN_LEN
)
==
0
)
{
right
->
nodeType
=
TEXPR_VALUE_NODE
;
expr
->
_node
.
optr
=
TSDB_RELATION
_IN
;
expr
->
_node
.
optr
=
OP_TYPE
_IN
;
SVariant
*
pVal
=
exception_calloc
(
1
,
sizeof
(
SVariant
));
right
->
pVal
=
pVal
;
pVal
->
nType
=
TSDB_DATA_TYPE_POINTER_ARRAY
;
...
...
source/libs/parser/src/parserUtil.c
浏览文件 @
aa556cb4
...
...
@@ -884,7 +884,7 @@ SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFil
}
assert
(
src
->
filterstr
==
0
||
src
->
filterstr
==
1
);
assert
(
!
(
src
->
lowerRelOptr
==
TSDB_RELATION_INVALID
&&
src
->
upperRelOptr
==
TSDB_RELATION_INVALID
));
assert
(
!
(
src
->
lowerRelOptr
==
0
&&
src
->
upperRelOptr
==
0
));
return
pFilter
;
}
...
...
@@ -1507,45 +1507,45 @@ int32_t getTagFilterSerializeLen(SQueryStmtInfo* pQueryInfo) {
uint32_t
convertRelationalOperator
(
SToken
*
pToken
)
{
switch
(
pToken
->
type
)
{
case
TK_LT
:
return
TSDB_RELATION_LESS
;
return
OP_TYPE_LOWER_THAN
;
case
TK_LE
:
return
TSDB_RELATION_LESS
_EQUAL
;
return
OP_TYPE_LOWER
_EQUAL
;
case
TK_GT
:
return
TSDB_RELATION_GREATER
;
return
OP_TYPE_GREATER_THAN
;
case
TK_GE
:
return
TSDB_RELATION
_GREATER_EQUAL
;
return
OP_TYPE
_GREATER_EQUAL
;
case
TK_NE
:
return
TSDB_RELATION
_NOT_EQUAL
;
return
OP_TYPE
_NOT_EQUAL
;
case
TK_AND
:
return
TSDB_RELATION
_AND
;
return
LOGIC_COND_TYPE
_AND
;
case
TK_OR
:
return
TSDB_RELATION
_OR
;
return
LOGIC_COND_TYPE
_OR
;
case
TK_EQ
:
return
TSDB_RELATION
_EQUAL
;
return
OP_TYPE
_EQUAL
;
case
TK_PLUS
:
return
TSDB_BINARY_OP
_ADD
;
return
OP_TYPE
_ADD
;
case
TK_MINUS
:
return
TSDB_BINARY_OP_SUBTRACT
;
return
OP_TYPE_SUB
;
case
TK_STAR
:
return
TSDB_BINARY_OP_MULTIPLY
;
return
OP_TYPE_MULTI
;
case
TK_SLASH
:
case
TK_DIVIDE
:
return
TSDB_BINARY_OP_DIVIDE
;
return
OP_TYPE_DIV
;
case
TK_REM
:
return
TSDB_BINARY_OP_REMAINDER
;
return
OP_TYPE_MOD
;
case
TK_LIKE
:
return
TSDB_RELATION
_LIKE
;
return
OP_TYPE
_LIKE
;
case
TK_MATCH
:
return
TSDB_RELATION
_MATCH
;
return
OP_TYPE
_MATCH
;
case
TK_NMATCH
:
return
TSDB_RELATION
_NMATCH
;
return
OP_TYPE
_NMATCH
;
case
TK_ISNULL
:
return
TSDB_RELATION_IS
NULL
;
return
OP_TYPE_IS_
NULL
;
case
TK_NOTNULL
:
return
TSDB_RELATION_NOT
NULL
;
return
OP_TYPE_IS_NOT_
NULL
;
case
TK_IN
:
return
TSDB_RELATION
_IN
;
return
OP_TYPE
_IN
;
default:
{
return
0
;
}
}
}
...
...
source/libs/parser/test/parserTests.cpp
浏览文件 @
aa556cb4
...
...
@@ -593,7 +593,7 @@ TEST(testCase, function_Test6) {
SExprInfo
*
p2
=
(
SExprInfo
*
)
taosArrayGetP
(
pQueryInfo
->
exprList
[
1
],
0
);
ASSERT_EQ
(
p2
->
pExpr
->
nodeType
,
TEXPR_BINARYEXPR_NODE
);
ASSERT_EQ
(
p2
->
pExpr
->
_node
.
optr
,
TSDB_BINARY_OP
_ADD
);
ASSERT_EQ
(
p2
->
pExpr
->
_node
.
optr
,
OP_TYPE
_ADD
);
ASSERT_EQ
(
p2
->
pExpr
->
_node
.
pLeft
->
nodeType
,
TEXPR_COL_NODE
);
ASSERT_EQ
(
p2
->
pExpr
->
_node
.
pRight
->
nodeType
,
TEXPR_COL_NODE
);
...
...
source/libs/scalar/inc/filterInt.h
浏览文件 @
aa556cb4
...
...
@@ -43,7 +43,6 @@ enum {
FLD_TYPE_COLUMN
=
1
,
FLD_TYPE_VALUE
=
2
,
FLD_TYPE_MAX
=
3
,
FLD_DESC_NO_FREE
=
4
,
FLD_DATA_NO_FREE
=
8
,
FLD_DATA_IS_HASH
=
16
,
};
...
...
@@ -61,11 +60,6 @@ enum {
RANGE_FLG_NULL
=
4
,
};
enum
{
FI_OPTION_NO_REWRITE
=
1
,
FI_OPTION_TIMESTAMP
=
2
,
FI_OPTION_NEED_UNIQE
=
4
,
};
enum
{
FI_STATUS_ALL
=
1
,
...
...
@@ -107,7 +101,6 @@ typedef struct SFilterRange {
typedef
bool
(
*
rangeCompFunc
)
(
const
void
*
,
const
void
*
,
const
void
*
,
const
void
*
,
__compar_fn_t
);
typedef
int32_t
(
*
filter_desc_compare_func
)(
const
void
*
,
const
void
*
);
typedef
bool
(
*
filter_exec_func
)(
void
*
,
int32_t
,
int8_t
**
,
SColumnDataAgg
*
,
int16_t
);
typedef
int32_t
(
*
filer_get_col_from_id
)(
void
*
,
int32_t
,
void
**
);
typedef
int32_t
(
*
filer_get_col_from_name
)(
void
*
,
int32_t
,
char
*
,
void
**
);
typedef
struct
SFilterRangeCompare
{
...
...
@@ -264,12 +257,12 @@ typedef struct SFilterInfo {
}
SFilterInfo
;
#define FILTER_NO_MERGE_DATA_TYPE(t) ((t) == TSDB_DATA_TYPE_BINARY || (t) == TSDB_DATA_TYPE_NCHAR || (t) == TSDB_DATA_TYPE_JSON)
#define FILTER_NO_MERGE_OPTR(o) ((o) ==
TSDB_RELATION_ISNULL || (o) == TSDB_RELATION_NOT
NULL || (o) == FILTER_DUMMY_EMPTY_OPTR)
#define FILTER_NO_MERGE_OPTR(o) ((o) ==
OP_TYPE_IS_NULL || (o) == OP_TYPE_IS_NOT_
NULL || (o) == FILTER_DUMMY_EMPTY_OPTR)
#define MR_EMPTY_RES(ctx) (ctx->rs == NULL)
#define SET_AND_OPTR(ctx, o) do {if (o ==
TSDB_RELATION_ISNULL) { (ctx)->isnull = true; } else if (o == TSDB_RELATION_NOT
NULL) { if (!(ctx)->isrange) { (ctx)->notnull = true; } } else if (o != FILTER_DUMMY_EMPTY_OPTR) { (ctx)->isrange = true; (ctx)->notnull = false; } } while (0)
#define SET_OR_OPTR(ctx,o) do {if (o ==
TSDB_RELATION_ISNULL) { (ctx)->isnull = true; } else if (o == TSDB_RELATION_NOT
NULL) { (ctx)->notnull = true; (ctx)->isrange = false; } else if (o != FILTER_DUMMY_EMPTY_OPTR) { if (!(ctx)->notnull) { (ctx)->isrange = true; } } } while (0)
#define SET_AND_OPTR(ctx, o) do {if (o ==
OP_TYPE_IS_NULL) { (ctx)->isnull = true; } else if (o == OP_TYPE_IS_NOT_
NULL) { if (!(ctx)->isrange) { (ctx)->notnull = true; } } else if (o != FILTER_DUMMY_EMPTY_OPTR) { (ctx)->isrange = true; (ctx)->notnull = false; } } while (0)
#define SET_OR_OPTR(ctx,o) do {if (o ==
OP_TYPE_IS_NULL) { (ctx)->isnull = true; } else if (o == OP_TYPE_IS_NOT_
NULL) { (ctx)->notnull = true; (ctx)->isrange = false; } else if (o != FILTER_DUMMY_EMPTY_OPTR) { if (!(ctx)->notnull) { (ctx)->isrange = true; } } } while (0)
#define CHK_OR_OPTR(ctx) ((ctx)->isnull == true && (ctx)->notnull == true)
#define CHK_AND_OPTR(ctx) ((ctx)->isnull == true && (((ctx)->notnull == true) || ((ctx)->isrange == true)))
...
...
@@ -351,23 +344,10 @@ typedef struct SFilterInfo {
#define FILTER_ALL_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_ALL)
#define FILTER_EMPTY_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_EMPTY)
#if 0
extern int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options);
extern bool filterExecute(SFilterInfo *info, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols);
extern int32_t filterSetColFieldData(SFilterInfo *info, void *param, filer_get_col_from_id fp);
extern int32_t filterSetJsonColFieldData(SFilterInfo *info, void *param, filer_get_col_from_name fp);
extern int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win);
extern int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows, bool *gotNchar);
extern int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo);
extern void filterFreeInfo(SFilterInfo *info);
extern bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows);
#else
//REMOVE THESE!!!!!!!!!!!!!!!!!!!!
#include "function.h"
#endif
extern
bool
filterDoCompare
(
__compar_fn_t
func
,
uint8_t
optr
,
void
*
left
,
void
*
right
);
extern
__compar_fn_t
filterGetCompFunc
(
int32_t
type
,
int32_t
optr
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/scalar/inc/sclvector.h
浏览文件 @
aa556cb4
...
...
@@ -24,7 +24,6 @@ extern "C" {
typedef
void
(
*
_bin_scalar_fn_t
)(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
output
,
int32_t
order
);
_bin_scalar_fn_t
getBinScalarOperatorFn
(
int32_t
binOperator
);
bool
isBinaryStringOp
(
int32_t
op
);
#ifdef __cplusplus
}
...
...
source/libs/scalar/src/filter.c
浏览文件 @
aa556cb4
...
...
@@ -21,22 +21,42 @@
#include "filter.h"
OptrStr
gOptrStr
[]
=
{
{
TSDB_RELATION_INVALID
,
"invalid"
},
{
TSDB_RELATION_LESS
,
"<"
},
{
TSDB_RELATION_GREATER
,
">"
},
{
TSDB_RELATION_EQUAL
,
"="
},
{
TSDB_RELATION_LESS_EQUAL
,
"<="
},
{
TSDB_RELATION_GREATER_EQUAL
,
">="
},
{
TSDB_RELATION_NOT_EQUAL
,
"!="
},
{
TSDB_RELATION_LIKE
,
"like"
},
{
TSDB_RELATION_ISNULL
,
"is null"
},
{
TSDB_RELATION_NOTNULL
,
"not null"
},
{
TSDB_RELATION_IN
,
"in"
},
{
TSDB_RELATION_AND
,
"and"
},
{
TSDB_RELATION_OR
,
"or"
},
{
TSDB_RELATION_NOT
,
"not"
},
{
TSDB_RELATION_MATCH
,
"match"
},
{
TSDB_RELATION_NMATCH
,
"nmatch"
}
{
0
,
"invalid"
},
{
OP_TYPE_ADD
,
"+"
},
{
OP_TYPE_SUB
,
"-"
},
{
OP_TYPE_MULTI
,
"*"
},
{
OP_TYPE_DIV
,
"/"
},
{
OP_TYPE_MOD
,
"%"
},
// bit operator
{
OP_TYPE_BIT_AND
,
"&"
},
{
OP_TYPE_BIT_OR
,
"|"
},
// comparison operator
{
OP_TYPE_GREATER_THAN
,
">"
},
{
OP_TYPE_GREATER_EQUAL
,
">="
},
{
OP_TYPE_LOWER_THAN
,
"<"
},
{
OP_TYPE_LOWER_EQUAL
,
"<="
},
{
OP_TYPE_EQUAL
,
"=="
},
{
OP_TYPE_NOT_EQUAL
,
"!="
},
{
OP_TYPE_IN
,
"in"
},
{
OP_TYPE_NOT_IN
,
"not in"
},
{
OP_TYPE_LIKE
,
"like"
},
{
OP_TYPE_NOT_LIKE
,
"not like"
},
{
OP_TYPE_MATCH
,
"match"
},
{
OP_TYPE_NMATCH
,
"nmatch"
},
{
OP_TYPE_IS_NULL
,
"is null"
},
{
OP_TYPE_IS_NOT_NULL
,
"not null"
},
{
OP_TYPE_IS_TRUE
,
"is true"
},
{
OP_TYPE_IS_FALSE
,
"is false"
},
{
OP_TYPE_IS_UNKNOWN
,
"is unknown"
},
{
OP_TYPE_IS_NOT_TRUE
,
"not true"
},
{
OP_TYPE_IS_NOT_FALSE
,
"not false"
},
{
OP_TYPE_IS_NOT_UNKNOWN
,
"not unknown"
},
// json operator
{
OP_TYPE_JSON_GET_VALUE
,
"json get"
},
{
OP_TYPE_JSON_CONTAINS
,
"json contains"
}
};
bool
filterRangeCompGi
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
...
...
@@ -110,30 +130,30 @@ rangeCompFunc gRangeCompare[] = {filterRangeCompee, filterRangeCompei, filterRan
int8_t
filterGetRangeCompFuncFromOptrs
(
uint8_t
optr
,
uint8_t
optr2
)
{
if
(
optr2
)
{
assert
(
optr2
==
TSDB_RELATION_LESS
||
optr2
==
TSDB_RELATION_LESS
_EQUAL
);
assert
(
optr2
==
OP_TYPE_LOWER_THAN
||
optr2
==
OP_TYPE_LOWER
_EQUAL
);
if
(
optr
==
TSDB_RELATION_GREATER
)
{
if
(
optr2
==
TSDB_RELATION_LESS
)
{
if
(
optr
==
OP_TYPE_GREATER_THAN
)
{
if
(
optr2
==
OP_TYPE_LOWER_THAN
)
{
return
0
;
}
return
1
;
}
if
(
optr2
==
TSDB_RELATION_LESS
)
{
if
(
optr2
==
OP_TYPE_LOWER_THAN
)
{
return
2
;
}
return
3
;
}
else
{
switch
(
optr
)
{
case
TSDB_RELATION_GREATER
:
case
OP_TYPE_GREATER_THAN
:
return
4
;
case
TSDB_RELATION
_GREATER_EQUAL
:
case
OP_TYPE
_GREATER_EQUAL
:
return
5
;
case
TSDB_RELATION_LESS
:
case
OP_TYPE_LOWER_THAN
:
return
6
;
case
TSDB_RELATION_LESS
_EQUAL
:
case
OP_TYPE_LOWER
_EQUAL
:
return
7
;
default:
break
;
...
...
@@ -154,7 +174,7 @@ __compar_fn_t gDataCompare[] = {compareInt32Val, compareInt8Val, compareInt16Val
int8_t
filterGetCompFuncIdx
(
int32_t
type
,
int32_t
optr
)
{
int8_t
comparFn
=
0
;
if
(
optr
==
TSDB_RELATION
_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
if
(
optr
==
OP_TYPE
_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
...
...
@@ -177,7 +197,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
}
}
if
(
optr
==
TSDB_RELATION
_NOT_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
if
(
optr
==
OP_TYPE
_NOT_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
...
...
@@ -210,17 +230,17 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
case
TSDB_DATA_TYPE_FLOAT
:
comparFn
=
4
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
comparFn
=
5
;
break
;
case
TSDB_DATA_TYPE_BINARY
:
{
if
(
optr
==
TSDB_RELATION
_MATCH
)
{
if
(
optr
==
OP_TYPE
_MATCH
)
{
comparFn
=
19
;
}
else
if
(
optr
==
TSDB_RELATION
_NMATCH
)
{
}
else
if
(
optr
==
OP_TYPE
_NMATCH
)
{
comparFn
=
20
;
}
else
if
(
optr
==
TSDB_RELATION
_LIKE
)
{
/* wildcard query using like operator */
}
else
if
(
optr
==
OP_TYPE
_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
7
;
}
else
if
(
optr
==
TSDB_RELATION
_NOT_LIKE
)
{
/* wildcard query using like operator */
}
else
if
(
optr
==
OP_TYPE
_NOT_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
26
;
}
else
if
(
optr
==
TSDB_RELATION
_IN
)
{
}
else
if
(
optr
==
OP_TYPE
_IN
)
{
comparFn
=
8
;
}
else
if
(
optr
==
TSDB_RELATION
_NOT_IN
)
{
}
else
if
(
optr
==
OP_TYPE
_NOT_IN
)
{
comparFn
=
25
;
}
else
{
/* normal relational comparFn */
comparFn
=
6
;
...
...
@@ -230,17 +250,17 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
}
case
TSDB_DATA_TYPE_NCHAR
:
{
if
(
optr
==
TSDB_RELATION
_MATCH
)
{
if
(
optr
==
OP_TYPE
_MATCH
)
{
comparFn
=
19
;
}
else
if
(
optr
==
TSDB_RELATION
_NMATCH
)
{
}
else
if
(
optr
==
OP_TYPE
_NMATCH
)
{
comparFn
=
20
;
}
else
if
(
optr
==
TSDB_RELATION
_LIKE
)
{
}
else
if
(
optr
==
OP_TYPE
_LIKE
)
{
comparFn
=
9
;
}
else
if
(
optr
==
TSDB_RELATION
_LIKE
)
{
}
else
if
(
optr
==
OP_TYPE
_LIKE
)
{
comparFn
=
27
;
}
else
if
(
optr
==
TSDB_RELATION
_IN
)
{
}
else
if
(
optr
==
OP_TYPE
_IN
)
{
comparFn
=
8
;
}
else
if
(
optr
==
TSDB_RELATION
_NOT_IN
)
{
}
else
if
(
optr
==
OP_TYPE
_NOT_IN
)
{
comparFn
=
25
;
}
else
{
comparFn
=
10
;
...
...
@@ -383,7 +403,7 @@ int32_t filterConvertRange(SFilterRangeCtx *cur, SFilterRange *ra, bool *notNull
int32_t
filterAddRangeOptr
(
void
*
h
,
uint8_t
raOptr
,
int32_t
optr
,
bool
*
empty
,
bool
*
all
)
{
SFilterRangeCtx
*
ctx
=
(
SFilterRangeCtx
*
)
h
;
if
(
optr
==
TSDB_RELATION
_AND
)
{
if
(
optr
==
LOGIC_COND_TYPE
_AND
)
{
SET_AND_OPTR
(
ctx
,
raOptr
);
if
(
CHK_AND_OPTR
(
ctx
)
||
(
raOptr
==
FILTER_DUMMY_EMPTY_OPTR
))
{
FILTER_SET_FLAG
(
ctx
->
status
,
MR_ST_EMPTY
);
...
...
@@ -407,8 +427,8 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) {
if
(
ctx
->
rs
==
NULL
)
{
if
((
FILTER_GET_FLAG
(
ctx
->
status
,
MR_ST_START
)
==
0
)
||
(
FILTER_GET_FLAG
(
ctx
->
status
,
MR_ST_ALL
)
&&
(
optr
==
TSDB_RELATION
_AND
))
||
((
!
FILTER_GET_FLAG
(
ctx
->
status
,
MR_ST_ALL
))
&&
(
optr
==
TSDB_RELATION
_OR
)))
{
||
(
FILTER_GET_FLAG
(
ctx
->
status
,
MR_ST_ALL
)
&&
(
optr
==
LOGIC_COND_TYPE
_AND
))
||
((
!
FILTER_GET_FLAG
(
ctx
->
status
,
MR_ST_ALL
))
&&
(
optr
==
LOGIC_COND_TYPE
_OR
)))
{
APPEND_RANGE
(
ctx
,
ctx
->
rs
,
ra
);
FILTER_SET_FLAG
(
ctx
->
status
,
MR_ST_START
);
}
...
...
@@ -420,7 +440,7 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) {
SFilterRangeNode
*
rn
=
NULL
;
int32_t
cr
=
0
;
if
(
optr
==
TSDB_RELATION
_AND
)
{
if
(
optr
==
LOGIC_COND_TYPE
_AND
)
{
while
(
r
!=
NULL
)
{
cr
=
ctx
->
pCompareFunc
(
&
r
->
ra
.
s
,
&
ra
->
e
);
if
(
FILTER_GREATER
(
cr
,
r
->
ra
.
sflag
,
ra
->
eflag
))
{
...
...
@@ -532,7 +552,7 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) {
if
(
notnull
)
{
bool
all
=
false
;
FREE_FROM_RANGE
(
ctx
,
ctx
->
rs
);
filterAddRangeOptr
(
h
,
TSDB_RELATION_NOT
NULL
,
optr
,
NULL
,
&
all
);
filterAddRangeOptr
(
h
,
OP_TYPE_IS_NOT_
NULL
,
optr
,
NULL
,
&
all
);
if
(
all
)
{
FILTER_SET_FLAG
(
ctx
->
status
,
MR_ST_ALL
);
}
...
...
@@ -563,7 +583,7 @@ int32_t filterAddRangeCtx(void *dst, void *src, int32_t optr) {
SFilterRangeCtx
*
dctx
=
(
SFilterRangeCtx
*
)
dst
;
SFilterRangeCtx
*
sctx
=
(
SFilterRangeCtx
*
)
src
;
assert
(
optr
==
TSDB_RELATION
_OR
);
assert
(
optr
==
LOGIC_COND_TYPE
_OR
);
if
(
sctx
->
rs
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -614,13 +634,13 @@ int32_t filterFinishRange(void* h) {
return
TSDB_CODE_SUCCESS
;
}
if
(
FILTER_GET_FLAG
(
ctx
->
options
,
F
I
_OPTION_TIMESTAMP
))
{
if
(
FILTER_GET_FLAG
(
ctx
->
options
,
F
LT
_OPTION_TIMESTAMP
))
{
SFilterRangeNode
*
r
=
ctx
->
rs
;
SFilterRangeNode
*
rn
=
NULL
;
while
(
r
&&
r
->
next
)
{
int64_t
tmp
=
1
;
operateVal
(
&
tmp
,
&
r
->
ra
.
e
,
&
tmp
,
TSDB_BINARY_OP
_ADD
,
ctx
->
type
);
operateVal
(
&
tmp
,
&
r
->
ra
.
e
,
&
tmp
,
OP_TYPE
_ADD
,
ctx
->
type
);
if
(
ctx
->
pCompareFunc
(
&
tmp
,
&
r
->
next
->
ra
.
s
)
==
0
)
{
rn
=
r
->
next
;
SIMPLE_COPY_VALUES
((
char
*
)
&
r
->
next
->
ra
.
s
,
(
char
*
)
&
r
->
ra
.
s
);
...
...
@@ -685,14 +705,14 @@ int32_t filterSourceRangeFromCtx(SFilterRangeCtx *ctx, void *sctx, int32_t optr,
SFilterRangeCtx
*
src
=
(
SFilterRangeCtx
*
)
sctx
;
if
(
src
->
isnull
){
filterAddRangeOptr
(
ctx
,
TSDB_RELATION_IS
NULL
,
optr
,
empty
,
all
);
filterAddRangeOptr
(
ctx
,
OP_TYPE_IS_
NULL
,
optr
,
empty
,
all
);
if
(
FILTER_GET_FLAG
(
ctx
->
status
,
MR_ST_ALL
))
{
*
all
=
true
;
}
}
if
(
src
->
notnull
)
{
filterAddRangeOptr
(
ctx
,
TSDB_RELATION_NOT
NULL
,
optr
,
empty
,
all
);
filterAddRangeOptr
(
ctx
,
OP_TYPE_IS_NOT_
NULL
,
optr
,
empty
,
all
);
if
(
FILTER_GET_FLAG
(
ctx
->
status
,
MR_ST_ALL
))
{
*
all
=
true
;
}
...
...
@@ -701,7 +721,7 @@ int32_t filterSourceRangeFromCtx(SFilterRangeCtx *ctx, void *sctx, int32_t optr,
if
(
src
->
isrange
)
{
filterAddRangeOptr
(
ctx
,
0
,
optr
,
empty
,
all
);
if
(
!
(
optr
==
TSDB_RELATION
_OR
&&
ctx
->
notnull
))
{
if
(
!
(
optr
==
LOGIC_COND_TYPE
_OR
&&
ctx
->
notnull
))
{
filterAddRangeCtx
(
ctx
,
src
,
optr
);
}
...
...
@@ -764,13 +784,26 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) {
int32_t
rightSize
=
(
int32_t
)
taosArrayGetSize
(
right
);
if
(
taosArrayGetSize
(
left
)
<=
0
)
{
fltDebug
(
"empty group"
);
if
(
taosArrayGetSize
(
right
)
<=
0
)
{
fltError
(
"both groups are empty"
);
FLT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
SFilterGroup
*
gp
=
NULL
;
while
(
gp
=
(
SFilterGroup
*
)
taosArrayPop
(
right
))
{
taosArrayPush
(
group
,
gp
);
}
return
TSDB_CODE_SUCCESS
;
}
if
(
taosArrayGetSize
(
right
)
<=
0
)
{
fltDebug
(
"empty group"
);
FLT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
SFilterGroup
*
gp
=
NULL
;
while
(
gp
=
(
SFilterGroup
*
)
taosArrayPop
(
left
))
{
taosArrayPush
(
group
,
gp
);
}
return
TSDB_CODE_SUCCESS
;
}
for
(
int32_t
l
=
0
;
l
<
leftSize
;
++
l
)
{
...
...
@@ -825,7 +858,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type,
if
(
*
num
>
0
)
{
if
(
type
==
FLD_TYPE_COLUMN
)
{
idx
=
filterGetFiledByDesc
(
&
info
->
fields
[
type
],
type
,
desc
);
}
else
if
(
data
&&
(
*
data
)
&&
dataLen
>
0
&&
FILTER_GET_FLAG
(
info
->
options
,
F
I
_OPTION_NEED_UNIQE
))
{
}
else
if
(
data
&&
(
*
data
)
&&
dataLen
>
0
&&
FILTER_GET_FLAG
(
info
->
options
,
F
LT
_OPTION_NEED_UNIQE
))
{
idx
=
filterGetFiledByData
(
info
,
type
,
*
data
,
dataLen
);
}
}
...
...
@@ -847,7 +880,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type,
++
(
*
num
);
if
(
data
&&
(
*
data
)
&&
dataLen
>
0
&&
FILTER_GET_FLAG
(
info
->
options
,
F
I
_OPTION_NEED_UNIQE
))
{
if
(
data
&&
(
*
data
)
&&
dataLen
>
0
&&
FILTER_GET_FLAG
(
info
->
options
,
F
LT
_OPTION_NEED_UNIQE
))
{
if
(
info
->
pctx
.
valHash
==
NULL
)
{
info
->
pctx
.
valHash
=
taosHashInit
(
FILTER_DEFAULT_GROUP_SIZE
*
FILTER_DEFAULT_VALUE_SIZE
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
false
);
}
...
...
@@ -855,10 +888,6 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type,
taosHashPut
(
info
->
pctx
.
valHash
,
*
data
,
dataLen
,
&
idx
,
sizeof
(
idx
));
}
}
else
{
if
(
freeIfExists
)
{
tfree
(
desc
);
}
if
(
data
&&
freeIfExists
)
{
tfree
(
*
data
);
}
...
...
@@ -873,7 +902,6 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type,
static
FORCE_INLINE
int32_t
filterAddColFieldFromField
(
SFilterInfo
*
info
,
SFilterField
*
field
,
SFilterFieldId
*
fid
)
{
filterAddField
(
info
,
field
->
desc
,
&
field
->
data
,
FILTER_GET_TYPE
(
field
->
flag
),
fid
,
0
,
false
);
FILTER_SET_FLAG
(
field
->
flag
,
FLD_DESC_NO_FREE
);
FILTER_SET_FLAG
(
field
->
flag
,
FLD_DATA_NO_FREE
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -907,7 +935,7 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *f
}
int32_t
filterAddUnit
(
SFilterInfo
*
info
,
uint8_t
optr
,
SFilterFieldId
*
left
,
SFilterFieldId
*
right
,
uint32_t
*
uidx
)
{
if
(
FILTER_GET_FLAG
(
info
->
options
,
F
I
_OPTION_NEED_UNIQE
))
{
if
(
FILTER_GET_FLAG
(
info
->
options
,
F
LT
_OPTION_NEED_UNIQE
))
{
if
(
info
->
pctx
.
unitHash
==
NULL
)
{
info
->
pctx
.
unitHash
=
taosHashInit
(
FILTER_DEFAULT_GROUP_SIZE
*
FILTER_DEFAULT_UNIT_SIZE
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
false
);
}
else
{
...
...
@@ -940,7 +968,7 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
SFilterField
*
val
=
FILTER_UNIT_RIGHT_FIELD
(
info
,
u
);
assert
(
FILTER_GET_FLAG
(
val
->
flag
,
FLD_TYPE_VALUE
));
}
else
{
if
(
optr
!=
TSDB_RELATION_ISNULL
&&
optr
!=
TSDB_RELATION_NOT
NULL
&&
optr
!=
FILTER_DUMMY_EMPTY_OPTR
){
if
(
optr
!=
OP_TYPE_IS_NULL
&&
optr
!=
OP_TYPE_IS_NOT_
NULL
&&
optr
!=
FILTER_DUMMY_EMPTY_OPTR
){
return
-
1
;
}
}
...
...
@@ -952,7 +980,7 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
*
uidx
=
info
->
unitNum
;
if
(
FILTER_GET_FLAG
(
info
->
options
,
F
I
_OPTION_NEED_UNIQE
))
{
if
(
FILTER_GET_FLAG
(
info
->
options
,
F
LT
_OPTION_NEED_UNIQE
))
{
int64_t
v
=
0
;
FILTER_PACKAGE_UNIT_HASH_KEY
(
&
v
,
optr
,
left
->
idx
,
right
?
right
->
idx
:
-
1
);
taosHashPut
(
info
->
pctx
.
unitHash
,
&
v
,
sizeof
(
v
),
uidx
,
sizeof
(
*
uidx
));
...
...
@@ -1010,7 +1038,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) {
filterAddField
(
info
,
NULL
,
&
fdata
,
FLD_TYPE_VALUE
,
&
right
,
len
,
true
);
filterAddUnit
(
info
,
TSDB_RELATION
_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
info
,
OP_TYPE
_EQUAL
,
&
left
,
&
right
,
&
uidx
);
SFilterGroup
fgroup
=
{
0
};
filterAddUnitToGroup
(
&
fgroup
,
uidx
);
...
...
@@ -1035,16 +1063,15 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) {
int32_t
filterAddUnitFromUnit
(
SFilterInfo
*
dst
,
SFilterInfo
*
src
,
SFilterUnit
*
u
,
uint32_t
*
uidx
)
{
SFilterFieldId
left
,
right
,
*
pright
=
&
right
;
int32_t
type
=
FILTER_UNIT_DATA_TYPE
(
u
);
uint16_t
flag
=
FLD_DESC_NO_FREE
;
uint16_t
flag
=
0
;
filterAddField
(
dst
,
FILTER_UNIT_COL_DESC
(
src
,
u
),
NULL
,
FLD_TYPE_COLUMN
,
&
left
,
0
,
false
);
SFilterField
*
t
=
FILTER_UNIT_LEFT_FIELD
(
src
,
u
);
FILTER_SET_FLAG
(
t
->
flag
,
flag
);
if
(
u
->
right
.
type
==
FLD_TYPE_VALUE
)
{
void
*
data
=
FILTER_UNIT_VAL_DATA
(
src
,
u
);
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
FILTER_UNIT_OPTR
(
u
)
==
TSDB_RELATION
_IN
)
{
if
(
FILTER_UNIT_OPTR
(
u
)
==
OP_TYPE
_IN
)
{
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
POINTER_BYTES
,
false
);
// POINTER_BYTES should be sizeof(SHashObj), but POINTER_BYTES is also right.
t
=
FILTER_GET_FIELD
(
dst
,
right
);
...
...
@@ -1087,17 +1114,17 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
int32_t
type
=
FILTER_GET_COL_FIELD_TYPE
(
FILTER_GET_FIELD
(
dst
,
left
));
if
(
optr
==
TSDB_RELATION
_AND
)
{
if
(
optr
==
LOGIC_COND_TYPE
_AND
)
{
if
(
ctx
->
isnull
)
{
assert
(
ctx
->
notnull
==
false
&&
ctx
->
isrange
==
false
);
filterAddUnit
(
dst
,
TSDB_RELATION_IS
NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnit
(
dst
,
OP_TYPE_IS_
NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
return
TSDB_CODE_SUCCESS
;
}
if
(
ctx
->
notnull
)
{
assert
(
ctx
->
isnull
==
false
&&
ctx
->
isrange
==
false
);
filterAddUnit
(
dst
,
TSDB_RELATION_NOT
NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnit
(
dst
,
OP_TYPE_IS_NOT_
NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1119,7 +1146,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
s
);
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
TSDB_RELATION
_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
dst
,
OP_TYPE
_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
return
TSDB_CODE_SUCCESS
;
}
else
{
...
...
@@ -1130,8 +1157,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
SIMPLE_COPY_VALUES
(
data2
,
&
ra
->
e
);
filterAddField
(
dst
,
NULL
,
&
data2
,
FLD_TYPE_VALUE
,
&
right2
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION
_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitRight
(
dst
,
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS
_EQUAL
,
&
right2
,
uidx
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_EXCLUDE
)
?
OP_TYPE_GREATER_THAN
:
OP_TYPE
_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitRight
(
dst
,
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_EXCLUDE
)
?
OP_TYPE_LOWER_THAN
:
OP_TYPE_LOWER
_EQUAL
,
&
right2
,
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1141,7 +1168,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
s
);
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION
_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_EXCLUDE
)
?
OP_TYPE_GREATER_THAN
:
OP_TYPE
_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
...
...
@@ -1149,7 +1176,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
e
);
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS
_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_EXCLUDE
)
?
OP_TYPE_LOWER_THAN
:
OP_TYPE_LOWER
_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
...
...
@@ -1164,7 +1191,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
assert
(
ctx
->
isnull
||
ctx
->
notnull
||
ctx
->
isrange
);
if
(
ctx
->
isnull
)
{
filterAddUnit
(
dst
,
TSDB_RELATION_IS
NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnit
(
dst
,
OP_TYPE_IS_
NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
taosArrayPush
(
res
,
g
);
}
...
...
@@ -1173,7 +1200,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
assert
(
!
ctx
->
isrange
);
memset
(
g
,
0
,
sizeof
(
*
g
));
filterAddUnit
(
dst
,
TSDB_RELATION_NOT
NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnit
(
dst
,
OP_TYPE_IS_NOT_
NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
taosArrayPush
(
res
,
g
);
}
...
...
@@ -1195,7 +1222,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
s
);
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
TSDB_RELATION
_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
dst
,
OP_TYPE
_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
else
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
...
...
@@ -1205,8 +1232,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
SIMPLE_COPY_VALUES
(
data2
,
&
r
->
ra
.
e
);
filterAddField
(
dst
,
NULL
,
&
data2
,
FLD_TYPE_VALUE
,
&
right2
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RANGE_FLG_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION
_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitRight
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RANGE_FLG_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS
_EQUAL
,
&
right2
,
uidx
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RANGE_FLG_EXCLUDE
)
?
OP_TYPE_GREATER_THAN
:
OP_TYPE
_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitRight
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RANGE_FLG_EXCLUDE
)
?
OP_TYPE_LOWER_THAN
:
OP_TYPE_LOWER
_EQUAL
,
&
right2
,
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
...
...
@@ -1221,7 +1248,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
s
);
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RANGE_FLG_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION
_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RANGE_FLG_EXCLUDE
)
?
OP_TYPE_GREATER_THAN
:
OP_TYPE
_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
...
...
@@ -1229,7 +1256,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
e
);
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RANGE_FLG_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS
_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RANGE_FLG_EXCLUDE
)
?
OP_TYPE_LOWER_THAN
:
OP_TYPE_LOWER
_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
...
...
@@ -1262,7 +1289,7 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) {
SArray
*
preGroup
=
NULL
;
SArray
*
newGroup
=
NULL
;
SArray
*
resGroup
=
NULL
;
ENodeType
nType
=
nodeType
(
nTyp
e
);
ENodeType
nType
=
nodeType
(
pNod
e
);
SFltBuildGroupCtx
*
ctx
=
(
SFltBuildGroupCtx
*
)
pContext
;
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pNode
))
{
...
...
@@ -1280,16 +1307,16 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) {
FLT_ERR_JRET
(
filterDetachCnfGroups
(
resGroup
,
preGroup
,
newGroup
));
taosArrayDestroyEx
(
newGroup
,
filterFreeGroup
);
newGroup
=
NULL
;
taosArrayDestroyEx
(
preGroup
,
filterFreeGroup
);
preGroup
=
resGroup
;
resGroup
=
NULL
;
}
taosArrayAddAll
(
ctx
->
group
,
res
Group
);
taosArrayAddAll
(
ctx
->
group
,
pre
Group
);
taosArrayDestroyEx
(
newGroup
,
filterFreeGroup
);
taosArrayDestroyEx
(
preGroup
,
filterFreeGroup
);
taosArrayDestroyEx
(
resGroup
,
filterFreeGroup
);
taosArrayDestroy
(
preGroup
);
return
DEAL_RES_IGNORE_CHILD
;
}
...
...
@@ -1312,7 +1339,7 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) {
if
(
QUERY_NODE_OPERATOR
==
nType
)
{
FLT_ERR_JRET
(
fltAddGroupUnitFromNode
(
ctx
->
info
,
pNode
,
ctx
->
group
));
return
DEAL_RES_
CONTINUE
;
return
DEAL_RES_
IGNORE_CHILD
;
}
fltError
(
"invalid node type for filter, type:%d"
,
nodeType
(
pNode
));
...
...
@@ -1448,11 +1475,11 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
SFilterField
*
left
=
FILTER_UNIT_LEFT_FIELD
(
info
,
unit
);
SColumnRefNode
*
refNode
=
(
SColumnRefNode
*
)
left
->
desc
;
if
(
unit
->
compare
.
optr
>=
TSDB_RELATION_INVALID
&&
unit
->
compare
.
optr
<=
TSDB_RELATION_NMATCH
){
if
(
unit
->
compare
.
optr
>=
0
&&
unit
->
compare
.
optr
<=
OP_TYPE_JSON_CONTAINS
){
len
=
sprintf
(
str
,
"UNIT[%d] => [%d][%d] %s ["
,
i
,
refNode
->
tupleId
,
refNode
->
slotId
,
gOptrStr
[
unit
->
compare
.
optr
].
str
);
}
if
(
unit
->
right
.
type
==
FLD_TYPE_VALUE
&&
FILTER_UNIT_OPTR
(
unit
)
!=
TSDB_RELATION
_IN
)
{
if
(
unit
->
right
.
type
==
FLD_TYPE_VALUE
&&
FILTER_UNIT_OPTR
(
unit
)
!=
OP_TYPE
_IN
)
{
SFilterField
*
right
=
FILTER_UNIT_RIGHT_FIELD
(
info
,
unit
);
char
*
data
=
right
->
data
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
...
...
@@ -1467,11 +1494,11 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
if
(
unit
->
compare
.
optr2
)
{
strcat
(
str
,
" && "
);
if
(
unit
->
compare
.
optr2
>=
TSDB_RELATION_INVALID
&&
unit
->
compare
.
optr2
<=
TSDB_RELATION_NMATCH
){
if
(
unit
->
compare
.
optr2
>=
0
&&
unit
->
compare
.
optr2
<=
OP_TYPE_JSON_CONTAINS
){
sprintf
(
str
+
strlen
(
str
),
"[%d][%d] %s ["
,
refNode
->
tupleId
,
refNode
->
slotId
,
gOptrStr
[
unit
->
compare
.
optr2
].
str
);
}
if
(
unit
->
right2
.
type
==
FLD_TYPE_VALUE
&&
FILTER_UNIT_OPTR
(
unit
)
!=
TSDB_RELATION
_IN
)
{
if
(
unit
->
right2
.
type
==
FLD_TYPE_VALUE
&&
FILTER_UNIT_OPTR
(
unit
)
!=
OP_TYPE
_IN
)
{
SFilterField
*
right
=
FILTER_UNIT_RIGHT2_FIELD
(
info
,
unit
);
char
*
data
=
right
->
data
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
...
...
@@ -1619,14 +1646,6 @@ void filterFreeField(SFilterField* field, int32_t type) {
return
;
}
if
(
!
FILTER_GET_FLAG
(
field
->
flag
,
FLD_DESC_NO_FREE
))
{
if
(
type
==
FLD_TYPE_VALUE
)
{
taosVariantDestroy
(
field
->
desc
);
}
tfree
(
field
->
desc
);
}
if
(
!
FILTER_GET_FLAG
(
field
->
flag
,
FLD_DATA_NO_FREE
))
{
if
(
FILTER_GET_FLAG
(
field
->
flag
,
FLD_DATA_IS_HASH
))
{
taosHashCleanup
(
field
->
data
);
...
...
@@ -1688,15 +1707,15 @@ int32_t filterHandleValueExtInfo(SFilterUnit* unit, char extInfo) {
uint8_t
optr
=
FILTER_UNIT_OPTR
(
unit
);
switch
(
optr
)
{
case
TSDB_RELATION_GREATER
:
case
TSDB_RELATION
_GREATER_EQUAL
:
unit
->
compare
.
optr
=
(
extInfo
>
0
)
?
FILTER_DUMMY_EMPTY_OPTR
:
TSDB_RELATION_NOT
NULL
;
case
OP_TYPE_GREATER_THAN
:
case
OP_TYPE
_GREATER_EQUAL
:
unit
->
compare
.
optr
=
(
extInfo
>
0
)
?
FILTER_DUMMY_EMPTY_OPTR
:
OP_TYPE_IS_NOT_
NULL
;
break
;
case
TSDB_RELATION_LESS
:
case
TSDB_RELATION_LESS
_EQUAL
:
unit
->
compare
.
optr
=
(
extInfo
>
0
)
?
TSDB_RELATION_NOT
NULL
:
FILTER_DUMMY_EMPTY_OPTR
;
case
OP_TYPE_LOWER_THAN
:
case
OP_TYPE_LOWER
_EQUAL
:
unit
->
compare
.
optr
=
(
extInfo
>
0
)
?
OP_TYPE_IS_NOT_
NULL
:
FILTER_DUMMY_EMPTY_OPTR
;
break
;
case
TSDB_RELATION
_EQUAL
:
case
OP_TYPE
_EQUAL
:
unit
->
compare
.
optr
=
FILTER_DUMMY_EMPTY_OPTR
;
break
;
default:
...
...
@@ -1711,7 +1730,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
for
(
uint32_t
i
=
0
;
i
<
info
->
unitNum
;
++
i
)
{
SFilterUnit
*
unit
=
&
info
->
units
[
i
];
if
(
unit
->
right
.
type
!=
FLD_TYPE_VALUE
)
{
assert
(
unit
->
compare
.
optr
==
TSDB_RELATION_ISNULL
||
unit
->
compare
.
optr
==
TSDB_RELATION_NOT
NULL
||
unit
->
compare
.
optr
==
FILTER_DUMMY_EMPTY_OPTR
);
assert
(
unit
->
compare
.
optr
==
OP_TYPE_IS_NULL
||
unit
->
compare
.
optr
==
OP_TYPE_IS_NOT_
NULL
||
unit
->
compare
.
optr
==
FILTER_DUMMY_EMPTY_OPTR
);
continue
;
}
...
...
@@ -1729,7 +1748,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
continue
;
}
if
(
unit
->
compare
.
optr
==
TSDB_RELATION
_IN
)
{
if
(
unit
->
compare
.
optr
==
OP_TYPE
_IN
)
{
FLT_ERR_RET
(
scalarGenerateSetFromList
((
void
**
)
&
fi
->
data
,
fi
->
desc
,
type
));
if
(
fi
->
data
==
NULL
)
{
fltError
(
"failed to convert in param"
);
...
...
@@ -1779,7 +1798,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
// match/nmatch for nchar type need convert from ucs4 to mbs
if
(
type
==
TSDB_DATA_TYPE_NCHAR
&&
(
unit
->
compare
.
optr
==
TSDB_RELATION_MATCH
||
unit
->
compare
.
optr
==
TSDB_RELATION
_NMATCH
)){
(
unit
->
compare
.
optr
==
OP_TYPE_MATCH
||
unit
->
compare
.
optr
==
OP_TYPE
_NMATCH
)){
char
newValData
[
TSDB_REGEX_STRING_DEFAULT_LEN
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
int32_t
len
=
taosUcs4ToMbs
(
varDataVal
(
fi
->
data
),
varDataLen
(
fi
->
data
),
varDataVal
(
newValData
));
if
(
len
<
0
){
...
...
@@ -1799,40 +1818,40 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right)
int32_t
ret
=
func
(
left
,
right
);
switch
(
optr
)
{
case
TSDB_RELATION
_EQUAL
:
{
case
OP_TYPE
_EQUAL
:
{
return
ret
==
0
;
}
case
TSDB_RELATION
_NOT_EQUAL
:
{
case
OP_TYPE
_NOT_EQUAL
:
{
return
ret
!=
0
;
}
case
TSDB_RELATION
_GREATER_EQUAL
:
{
case
OP_TYPE
_GREATER_EQUAL
:
{
return
ret
>=
0
;
}
case
TSDB_RELATION_GREATER
:
{
case
OP_TYPE_GREATER_THAN
:
{
return
ret
>
0
;
}
case
TSDB_RELATION_LESS
_EQUAL
:
{
case
OP_TYPE_LOWER
_EQUAL
:
{
return
ret
<=
0
;
}
case
TSDB_RELATION_LESS
:
{
case
OP_TYPE_LOWER_THAN
:
{
return
ret
<
0
;
}
case
TSDB_RELATION
_LIKE
:
{
case
OP_TYPE
_LIKE
:
{
return
ret
==
0
;
}
case
TSDB_RELATION
_NOT_LIKE
:
{
case
OP_TYPE
_NOT_LIKE
:
{
return
ret
==
0
;
}
case
TSDB_RELATION
_MATCH
:
{
case
OP_TYPE
_MATCH
:
{
return
ret
==
0
;
}
case
TSDB_RELATION
_NMATCH
:
{
case
OP_TYPE
_NMATCH
:
{
return
ret
==
0
;
}
case
TSDB_RELATION
_IN
:
{
case
OP_TYPE
_IN
:
{
return
ret
==
1
;
}
case
TSDB_RELATION
_NOT_IN
:
{
case
OP_TYPE
_NOT_IN
:
{
return
ret
==
1
;
}
...
...
@@ -1852,25 +1871,25 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit* u, SFilterRangeCtx *c
int64_t
tmp
=
0
;
switch
(
uoptr
)
{
case
TSDB_RELATION_GREATER
:
case
OP_TYPE_GREATER_THAN
:
SIMPLE_COPY_VALUES
(
&
ra
.
s
,
val
);
FILTER_SET_FLAG
(
ra
.
sflag
,
RANGE_FLG_EXCLUDE
);
FILTER_SET_FLAG
(
ra
.
eflag
,
RANGE_FLG_NULL
);
break
;
case
TSDB_RELATION
_GREATER_EQUAL
:
case
OP_TYPE
_GREATER_EQUAL
:
SIMPLE_COPY_VALUES
(
&
ra
.
s
,
val
);
FILTER_SET_FLAG
(
ra
.
eflag
,
RANGE_FLG_NULL
);
break
;
case
TSDB_RELATION_LESS
:
case
OP_TYPE_LOWER_THAN
:
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
val
);
FILTER_SET_FLAG
(
ra
.
eflag
,
RANGE_FLG_EXCLUDE
);
FILTER_SET_FLAG
(
ra
.
sflag
,
RANGE_FLG_NULL
);
break
;
case
TSDB_RELATION_LESS
_EQUAL
:
case
OP_TYPE_LOWER
_EQUAL
:
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
val
);
FILTER_SET_FLAG
(
ra
.
sflag
,
RANGE_FLG_NULL
);
break
;
case
TSDB_RELATION
_NOT_EQUAL
:
case
OP_TYPE
_NOT_EQUAL
:
assert
(
type
==
TSDB_DATA_TYPE_BOOL
);
if
(
GET_INT8_VAL
(
val
))
{
SIMPLE_COPY_VALUES
(
&
ra
.
s
,
&
tmp
);
...
...
@@ -1881,7 +1900,7 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit* u, SFilterRangeCtx *c
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
&
tmp
);
}
break
;
case
TSDB_RELATION
_EQUAL
:
case
OP_TYPE
_EQUAL
:
SIMPLE_COPY_VALUES
(
&
ra
.
s
,
val
);
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
val
);
break
;
...
...
@@ -1935,15 +1954,15 @@ int32_t filterMergeUnits(SFilterInfo *info, SFilterGroupCtx* gRes, uint32_t colI
SFilterUnit
*
u
=
taosArrayGetP
(
colArray
,
i
);
uint8_t
optr
=
FILTER_UNIT_OPTR
(
u
);
filterAddRangeOptr
(
ctx
,
optr
,
TSDB_RELATION
_AND
,
empty
,
NULL
);
filterAddRangeOptr
(
ctx
,
optr
,
LOGIC_COND_TYPE
_AND
,
empty
,
NULL
);
FLT_CHK_JMP
(
*
empty
);
if
(
!
FILTER_NO_MERGE_OPTR
(
optr
))
{
filterAddUnitRange
(
info
,
u
,
ctx
,
TSDB_RELATION
_AND
);
filterAddUnitRange
(
info
,
u
,
ctx
,
LOGIC_COND_TYPE
_AND
);
FLT_CHK_JMP
(
MR_EMPTY_RES
(
ctx
));
}
if
(
FILTER_UNIT_OPTR
(
u
)
==
TSDB_RELATION
_EQUAL
&&
!
FILTER_NO_MERGE_DATA_TYPE
(
FILTER_UNIT_DATA_TYPE
(
u
))){
gRes
->
colInfo
[
colIdx
].
optr
=
TSDB_RELATION
_EQUAL
;
if
(
FILTER_UNIT_OPTR
(
u
)
==
OP_TYPE
_EQUAL
&&
!
FILTER_NO_MERGE_DATA_TYPE
(
FILTER_UNIT_DATA_TYPE
(
u
))){
gRes
->
colInfo
[
colIdx
].
optr
=
OP_TYPE
_EQUAL
;
SIMPLE_COPY_VALUES
(
&
gRes
->
colInfo
[
colIdx
].
value
,
FILTER_UNIT_VAL_DATA
(
info
,
u
));
}
}
...
...
@@ -2063,7 +2082,7 @@ void filterCheckColConflict(SFilterGroupCtx* gRes1, SFilterGroupCtx* gRes2, bool
}
// for long in operation
if
(
gRes1
->
colInfo
[
idx1
].
optr
==
TSDB_RELATION_EQUAL
&&
gRes2
->
colInfo
[
idx2
].
optr
==
TSDB_RELATION
_EQUAL
)
{
if
(
gRes1
->
colInfo
[
idx1
].
optr
==
OP_TYPE_EQUAL
&&
gRes2
->
colInfo
[
idx2
].
optr
==
OP_TYPE
_EQUAL
)
{
SFilterRangeCtx
*
ctx
=
gRes1
->
colInfo
[
idx1
].
info
;
if
(
ctx
->
pCompareFunc
(
&
gRes1
->
colInfo
[
idx1
].
value
,
&
gRes2
->
colInfo
[
idx2
].
value
)){
*
conflict
=
true
;
...
...
@@ -2139,7 +2158,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter
++
merNum
;
filterMergeTwoGroupsImpl
(
info
,
&
ctx
,
TSDB_RELATION
_OR
,
idx1
,
*
gRes1
,
*
gRes2
,
NULL
,
all
);
filterMergeTwoGroupsImpl
(
info
,
&
ctx
,
LOGIC_COND_TYPE
_OR
,
idx1
,
*
gRes1
,
*
gRes2
,
NULL
,
all
);
FLT_CHK_JMP
(
*
all
);
...
...
@@ -2353,14 +2372,14 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum
oinfo
.
colRangeNum
=
0
;
oinfo
.
colRange
=
NULL
;
FILTER_SET_FLAG
(
info
->
options
,
F
I
_OPTION_NEED_UNIQE
);
FILTER_SET_FLAG
(
info
->
options
,
F
LT
_OPTION_NEED_UNIQE
);
filterInitUnitsFields
(
info
);
for
(
int32_t
i
=
0
;
i
<
gResNum
;
++
i
)
{
res
=
gRes
[
i
];
optr
=
(
res
->
colNum
>
1
)
?
TSDB_RELATION_AND
:
TSDB_RELATION
_OR
;
optr
=
(
res
->
colNum
>
1
)
?
LOGIC_COND_TYPE_AND
:
LOGIC_COND_TYPE
_OR
;
SFilterGroup
ng
=
{
0
};
...
...
@@ -2457,7 +2476,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_
assert
(
colInfo
->
type
==
RANGE_TYPE_MR_CTX
);
bool
all
=
false
;
filterSourceRangeFromCtx
(
info
->
colRange
[
m
],
colInfo
->
info
,
TSDB_RELATION
_OR
,
NULL
,
&
all
);
filterSourceRangeFromCtx
(
info
->
colRange
[
m
],
colInfo
->
info
,
LOGIC_COND_TYPE
_OR
,
NULL
,
&
all
);
if
(
all
)
{
filterFreeRangeCtx
(
info
->
colRange
[
m
]);
info
->
colRange
[
m
]
=
NULL
;
...
...
@@ -2572,20 +2591,20 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
}
if
(
pDataStatis
[
index
].
numOfNull
<=
0
)
{
if
(
cunit
->
optr
==
TSDB_RELATION_IS
NULL
)
{
if
(
cunit
->
optr
==
OP_TYPE_IS_
NULL
)
{
info
->
blkUnitRes
[
k
]
=
-
1
;
rmUnit
=
1
;
continue
;
}
if
(
cunit
->
optr
==
TSDB_RELATION_NOT
NULL
)
{
if
(
cunit
->
optr
==
OP_TYPE_IS_NOT_
NULL
)
{
info
->
blkUnitRes
[
k
]
=
1
;
rmUnit
=
1
;
continue
;
}
}
else
{
if
(
pDataStatis
[
index
].
numOfNull
==
numOfRows
)
{
if
(
cunit
->
optr
==
TSDB_RELATION_IS
NULL
)
{
if
(
cunit
->
optr
==
OP_TYPE_IS_
NULL
)
{
info
->
blkUnitRes
[
k
]
=
1
;
rmUnit
=
1
;
continue
;
...
...
@@ -2597,9 +2616,9 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
}
}
if
(
cunit
->
optr
==
TSDB_RELATION_ISNULL
||
cunit
->
optr
==
TSDB_RELATION_NOT
NULL
||
cunit
->
optr
==
TSDB_RELATION_IN
||
cunit
->
optr
==
TSDB_RELATION_LIKE
||
cunit
->
optr
==
TSDB_RELATION
_MATCH
||
cunit
->
optr
==
TSDB_RELATION
_NOT_EQUAL
)
{
if
(
cunit
->
optr
==
OP_TYPE_IS_NULL
||
cunit
->
optr
==
OP_TYPE_IS_NOT_
NULL
||
cunit
->
optr
==
OP_TYPE_IN
||
cunit
->
optr
==
OP_TYPE_LIKE
||
cunit
->
optr
==
OP_TYPE
_MATCH
||
cunit
->
optr
==
OP_TYPE
_NOT_EQUAL
)
{
continue
;
}
...
...
@@ -2629,8 +2648,8 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
info
->
blkUnitRes
[
k
]
=
1
;
rmUnit
=
1
;
}
else
if
((
!
minRes
)
&&
(
!
maxRes
))
{
minRes
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
TSDB_RELATION_LESS
_EQUAL
,
minVal
,
cunit
->
valData
);
maxRes
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
TSDB_RELATION
_GREATER_EQUAL
,
maxVal
,
cunit
->
valData2
);
minRes
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
OP_TYPE_LOWER
_EQUAL
,
minVal
,
cunit
->
valData
);
maxRes
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
OP_TYPE
_GREATER_EQUAL
,
maxVal
,
cunit
->
valData2
);
if
(
minRes
&&
maxRes
)
{
continue
;
...
...
@@ -2647,9 +2666,9 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
info
->
blkUnitRes
[
k
]
=
1
;
rmUnit
=
1
;
}
else
if
((
!
minRes
)
&&
(
!
maxRes
))
{
if
(
cunit
->
optr
==
TSDB_RELATION
_EQUAL
)
{
minRes
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
TSDB_RELATION_GREATER
,
minVal
,
cunit
->
valData
);
maxRes
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
TSDB_RELATION_LESS
,
maxVal
,
cunit
->
valData
);
if
(
cunit
->
optr
==
OP_TYPE
_EQUAL
)
{
minRes
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
OP_TYPE_GREATER_THAN
,
minVal
,
cunit
->
valData
);
maxRes
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
OP_TYPE_LOWER_THAN
,
maxVal
,
cunit
->
valData
);
if
(
minRes
||
maxRes
)
{
info
->
blkUnitRes
[
k
]
=
-
1
;
rmUnit
=
1
;
...
...
@@ -2753,11 +2772,11 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
uint8_t
optr
=
cunit
->
optr
;
if
(
isNull
(
colData
,
cunit
->
dataType
))
{
(
*
p
)[
i
]
=
optr
==
TSDB_RELATION_IS
NULL
?
true
:
false
;
(
*
p
)[
i
]
=
optr
==
OP_TYPE_IS_
NULL
?
true
:
false
;
}
else
{
if
(
optr
==
TSDB_RELATION_NOT
NULL
)
{
if
(
optr
==
OP_TYPE_IS_NOT_
NULL
)
{
(
*
p
)[
i
]
=
1
;
}
else
if
(
optr
==
TSDB_RELATION_IS
NULL
)
{
}
else
if
(
optr
==
OP_TYPE_IS_
NULL
)
{
(
*
p
)[
i
]
=
0
;
}
else
if
(
cunit
->
rfunc
>=
0
)
{
(
*
p
)[
i
]
=
(
*
gRangeCompare
[
cunit
->
rfunc
])(
colData
,
colData
,
cunit
->
valData
,
cunit
->
valData2
,
gDataCompare
[
cunit
->
func
]);
...
...
@@ -2959,7 +2978,7 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa
}
// match/nmatch for nchar type need convert from ucs4 to mbs
if
(
info
->
cunits
[
uidx
].
dataType
==
TSDB_DATA_TYPE_NCHAR
&&
(
info
->
cunits
[
uidx
].
optr
==
TSDB_RELATION_MATCH
||
info
->
cunits
[
uidx
].
optr
==
TSDB_RELATION
_NMATCH
)){
if
(
info
->
cunits
[
uidx
].
dataType
==
TSDB_DATA_TYPE_NCHAR
&&
(
info
->
cunits
[
uidx
].
optr
==
OP_TYPE_MATCH
||
info
->
cunits
[
uidx
].
optr
==
OP_TYPE
_NMATCH
)){
char
*
newColData
=
calloc
(
info
->
cunits
[
uidx
].
dataSize
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
,
1
);
int32_t
len
=
taosUcs4ToMbs
(
varDataVal
(
colData
),
varDataLen
(
colData
),
varDataVal
(
newColData
));
if
(
len
<
0
){
...
...
@@ -3010,16 +3029,16 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg
uint8_t
optr
=
cunit
->
optr
;
if
(
colData
==
NULL
||
isNull
(
colData
,
cunit
->
dataType
))
{
(
*
p
)[
i
]
=
optr
==
TSDB_RELATION_IS
NULL
?
true
:
false
;
(
*
p
)[
i
]
=
optr
==
OP_TYPE_IS_
NULL
?
true
:
false
;
}
else
{
if
(
optr
==
TSDB_RELATION_NOT
NULL
)
{
if
(
optr
==
OP_TYPE_IS_NOT_
NULL
)
{
(
*
p
)[
i
]
=
1
;
}
else
if
(
optr
==
TSDB_RELATION_IS
NULL
)
{
}
else
if
(
optr
==
OP_TYPE_IS_
NULL
)
{
(
*
p
)[
i
]
=
0
;
}
else
if
(
cunit
->
rfunc
>=
0
)
{
(
*
p
)[
i
]
=
(
*
gRangeCompare
[
cunit
->
rfunc
])(
colData
,
colData
,
cunit
->
valData
,
cunit
->
valData2
,
gDataCompare
[
cunit
->
func
]);
}
else
{
if
(
cunit
->
dataType
==
TSDB_DATA_TYPE_NCHAR
&&
(
cunit
->
optr
==
TSDB_RELATION_MATCH
||
cunit
->
optr
==
TSDB_RELATION
_NMATCH
)){
if
(
cunit
->
dataType
==
TSDB_DATA_TYPE_NCHAR
&&
(
cunit
->
optr
==
OP_TYPE_MATCH
||
cunit
->
optr
==
OP_TYPE
_NMATCH
)){
char
*
newColData
=
calloc
(
cunit
->
dataSize
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
,
1
);
int32_t
len
=
taosUcs4ToMbs
(
varDataVal
(
colData
),
varDataLen
(
colData
),
varDataVal
(
newColData
));
if
(
len
<
0
){
...
...
@@ -3072,12 +3091,12 @@ int32_t filterSetExecFunc(SFilterInfo *info) {
return
TSDB_CODE_SUCCESS
;
}
if
(
info
->
units
[
0
].
compare
.
optr
==
TSDB_RELATION_IS
NULL
)
{
if
(
info
->
units
[
0
].
compare
.
optr
==
OP_TYPE_IS_
NULL
)
{
info
->
func
=
filterExecuteImplIsNull
;
return
TSDB_CODE_SUCCESS
;
}
if
(
info
->
units
[
0
].
compare
.
optr
==
TSDB_RELATION_NOT
NULL
)
{
if
(
info
->
units
[
0
].
compare
.
optr
==
OP_TYPE_IS_NOT_
NULL
)
{
info
->
func
=
filterExecuteImplNotNull
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -3173,7 +3192,7 @@ int32_t fltInitFromNode(SNode* tree, SFilterInfo *info, uint32_t options) {
FLT_ERR_JRET
(
fltInitValFieldData
(
info
));
if
(
!
FILTER_GET_FLAG
(
info
->
options
,
F
I
_OPTION_NO_REWRITE
))
{
if
(
!
FILTER_GET_FLAG
(
info
->
options
,
F
LT
_OPTION_NO_REWRITE
))
{
filterDumpInfoToString
(
info
,
"Before preprocess"
,
0
);
FLT_ERR_JRET
(
filterPreprocess
(
info
));
...
...
@@ -3194,7 +3213,7 @@ int32_t fltInitFromNode(SNode* tree, SFilterInfo *info, uint32_t options) {
_return:
qInfo
(
"
No filter
, code:%d"
,
code
);
qInfo
(
"
init from node failed
, code:%d"
,
code
);
return
code
;
}
...
...
@@ -3291,8 +3310,8 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t
int32_t
filterGetTimeRange
(
SFilterInfo
*
info
,
STimeWindow
*
win
)
{
SFilterRange
ra
=
{
0
};
SFilterRangeCtx
*
prev
=
filterInitRangeCtx
(
TSDB_DATA_TYPE_TIMESTAMP
,
F
I
_OPTION_TIMESTAMP
);
SFilterRangeCtx
*
tmpc
=
filterInitRangeCtx
(
TSDB_DATA_TYPE_TIMESTAMP
,
F
I
_OPTION_TIMESTAMP
);
SFilterRangeCtx
*
prev
=
filterInitRangeCtx
(
TSDB_DATA_TYPE_TIMESTAMP
,
F
LT
_OPTION_TIMESTAMP
);
SFilterRangeCtx
*
tmpc
=
filterInitRangeCtx
(
TSDB_DATA_TYPE_TIMESTAMP
,
F
LT
_OPTION_TIMESTAMP
);
SFilterRangeCtx
*
cur
=
NULL
;
int32_t
num
=
0
;
int32_t
optr
=
0
;
...
...
@@ -3303,10 +3322,10 @@ int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win) {
SFilterGroup
*
group
=
&
info
->
groups
[
i
];
if
(
group
->
unitNum
>
1
)
{
cur
=
tmpc
;
optr
=
TSDB_RELATION
_AND
;
optr
=
LOGIC_COND_TYPE
_AND
;
}
else
{
cur
=
prev
;
optr
=
TSDB_RELATION
_OR
;
optr
=
LOGIC_COND_TYPE
_OR
;
}
for
(
uint32_t
u
=
0
;
u
<
group
->
unitNum
;
++
u
)
{
...
...
@@ -3315,7 +3334,7 @@ int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win) {
uint8_t
raOptr
=
FILTER_UNIT_OPTR
(
unit
);
filterAddRangeOptr
(
cur
,
raOptr
,
TSDB_RELATION
_AND
,
&
empty
,
NULL
);
filterAddRangeOptr
(
cur
,
raOptr
,
LOGIC_COND_TYPE
_AND
,
&
empty
,
NULL
);
FLT_CHK_JMP
(
empty
);
if
(
FILTER_NO_MERGE_OPTR
(
raOptr
))
{
...
...
@@ -3338,7 +3357,7 @@ int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win) {
}
if
(
group
->
unitNum
>
1
)
{
filterSourceRangeFromCtx
(
prev
,
cur
,
TSDB_RELATION
_OR
,
&
empty
,
&
all
);
filterSourceRangeFromCtx
(
prev
,
cur
,
LOGIC_COND_TYPE
_OR
,
&
empty
,
&
all
);
filterResetRangeCtx
(
cur
);
if
(
all
)
{
break
;
...
...
@@ -3469,7 +3488,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
if
(
QUERY_NODE_VALUE
==
nodeType
(
*
pNode
))
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
*
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
*
pNode
)
||
QUERY_NODE_COLUMN_REF
==
nodeType
(
*
pNode
)
)
{
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -3623,7 +3642,7 @@ _return:
FLT_RET
(
code
);
}
FORCE_INLINE
bool
filterExecute
(
SFilterInfo
*
info
,
SSDataBlock
*
pSrc
,
int8_t
**
p
,
SColumnDataAgg
*
statis
,
int16_t
numOfCols
)
{
bool
filterExecute
(
SFilterInfo
*
info
,
SSDataBlock
*
pSrc
,
int8_t
**
p
,
SColumnDataAgg
*
statis
,
int16_t
numOfCols
)
{
if
(
info
->
scalarMode
)
{
SScalarParam
output
=
{
0
};
FLT_ERR_RET
(
scalarCalculate
(
info
->
sclCtx
.
node
,
pSrc
,
&
output
));
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
aa556cb4
...
...
@@ -268,9 +268,6 @@ static void setScalarFuncParam(SScalarParam* param, int32_t type, int32_t bytes,
param
->
data
=
pInput
;
}
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,
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
aa556cb4
...
...
@@ -23,6 +23,7 @@
#include "query.h"
#include "sclInt.h"
#include "tep.h"
#include "filter.h"
//GET_TYPED_DATA(v, double, pRight->type, (char *)&((right)[i]));
...
...
@@ -1380,51 +1381,51 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
}
void
vectorGreater
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION_GREATER
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE_GREATER_THAN
);
}
void
vectorGreaterEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION
_GREATER_EQUAL
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE
_GREATER_EQUAL
);
}
void
vectorLower
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION_LESS
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE_LOWER_THAN
);
}
void
vectorLowerEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION_LESS
_EQUAL
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE_LOWER
_EQUAL
);
}
void
vectorEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION
_EQUAL
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE
_EQUAL
);
}
void
vectorNotEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION
_NOT_EQUAL
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE
_NOT_EQUAL
);
}
void
vectorIn
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION
_IN
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE
_IN
);
}
void
vectorNotIn
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION
_NOT_IN
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE
_NOT_IN
);
}
void
vectorLike
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION
_LIKE
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE
_LIKE
);
}
void
vectorNotLike
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION
_NOT_LIKE
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE
_NOT_LIKE
);
}
void
vectorMatch
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION
_MATCH
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE
_MATCH
);
}
void
vectorNotMatch
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
TSDB_RELATION
_NMATCH
);
vectorCompare
(
pLeft
,
pRight
,
out
,
_ord
,
OP_TYPE
_NMATCH
);
}
void
vectorIsNull
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
...
...
@@ -1543,6 +1544,4 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) {
}
}
bool
isBinaryStringOp
(
int32_t
op
)
{
return
op
==
TSDB_BINARY_OP_CONCAT
;
}
source/util/src/compare.c
浏览文件 @
aa556cb4
...
...
@@ -466,7 +466,7 @@ int32_t compareWStrPatternNotMatch(const void* pLeft, const void* pRight) {
__compar_fn_t
getComparFunc
(
int32_t
type
,
int32_t
optr
)
{
__compar_fn_t
comparFn
=
NULL
;
if
(
optr
==
TSDB_RELATION
_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
if
(
optr
==
OP_TYPE
_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
...
...
@@ -489,7 +489,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
}
}
if
(
optr
==
TSDB_RELATION
_NOT_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
if
(
optr
==
OP_TYPE
_NOT_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
...
...
@@ -522,17 +522,17 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
case
TSDB_DATA_TYPE_FLOAT
:
comparFn
=
compareFloatVal
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
comparFn
=
compareDoubleVal
;
break
;
case
TSDB_DATA_TYPE_BINARY
:
{
if
(
optr
==
TSDB_RELATION
_MATCH
)
{
if
(
optr
==
OP_TYPE
_MATCH
)
{
comparFn
=
compareStrRegexCompMatch
;
}
else
if
(
optr
==
TSDB_RELATION
_NMATCH
)
{
}
else
if
(
optr
==
OP_TYPE
_NMATCH
)
{
comparFn
=
compareStrRegexCompNMatch
;
}
else
if
(
optr
==
TSDB_RELATION
_LIKE
)
{
/* wildcard query using like operator */
}
else
if
(
optr
==
OP_TYPE
_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
compareStrPatternMatch
;
}
else
if
(
optr
==
TSDB_RELATION
_NOT_LIKE
)
{
/* wildcard query using like operator */
}
else
if
(
optr
==
OP_TYPE
_NOT_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
compareStrPatternNotMatch
;
}
else
if
(
optr
==
TSDB_RELATION
_IN
)
{
}
else
if
(
optr
==
OP_TYPE
_IN
)
{
comparFn
=
compareChkInString
;
}
else
if
(
optr
==
TSDB_RELATION
_NOT_IN
)
{
}
else
if
(
optr
==
OP_TYPE
_NOT_IN
)
{
comparFn
=
compareChkNotInString
;
}
else
{
/* normal relational comparFn */
comparFn
=
compareLenPrefixedStr
;
...
...
@@ -542,17 +542,17 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
}
case
TSDB_DATA_TYPE_NCHAR
:
{
if
(
optr
==
TSDB_RELATION
_MATCH
)
{
if
(
optr
==
OP_TYPE
_MATCH
)
{
comparFn
=
compareStrRegexCompMatch
;
}
else
if
(
optr
==
TSDB_RELATION
_NMATCH
)
{
}
else
if
(
optr
==
OP_TYPE
_NMATCH
)
{
comparFn
=
compareStrRegexCompNMatch
;
}
else
if
(
optr
==
TSDB_RELATION
_LIKE
)
{
}
else
if
(
optr
==
OP_TYPE
_LIKE
)
{
comparFn
=
compareWStrPatternMatch
;
}
else
if
(
optr
==
TSDB_RELATION
_NOT_LIKE
)
{
}
else
if
(
optr
==
OP_TYPE
_NOT_LIKE
)
{
comparFn
=
compareWStrPatternNotMatch
;
}
else
if
(
optr
==
TSDB_RELATION
_IN
)
{
}
else
if
(
optr
==
OP_TYPE
_IN
)
{
comparFn
=
compareChkInString
;
}
else
if
(
optr
==
TSDB_RELATION
_NOT_IN
)
{
}
else
if
(
optr
==
OP_TYPE
_NOT_IN
)
{
comparFn
=
compareChkNotInString
;
}
else
{
comparFn
=
compareLenPrefixedWStr
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录