Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d77c190e
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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,发现更多精彩内容 >>
提交
d77c190e
编写于
7月 22, 2021
作者:
W
wpan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support filter duplicated unit
上级
e270cf37
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
124 addition
and
50 deletion
+124
-50
src/query/inc/qFilter.h
src/query/inc/qFilter.h
+4
-2
src/query/src/qFilter.c
src/query/src/qFilter.c
+120
-48
未找到文件。
src/query/inc/qFilter.h
浏览文件 @
d77c190e
...
@@ -21,10 +21,12 @@ extern "C" {
...
@@ -21,10 +21,12 @@ extern "C" {
#endif
#endif
#include "texpr.h"
#include "texpr.h"
#include "hash.h"
#define FILTER_DEFAULT_GROUP_SIZE 4
#define FILTER_DEFAULT_GROUP_SIZE 4
#define FILTER_DEFAULT_UNIT_SIZE 4
#define FILTER_DEFAULT_UNIT_SIZE 4
#define FILTER_DEFAULT_FIELD_SIZE 4
#define FILTER_DEFAULT_FIELD_SIZE 4
#define FILTER_DEFAULT_VALUE_SIZE 4
#define FILTER_DEFAULT_GROUP_UNIT_SIZE 2
#define FILTER_DEFAULT_GROUP_UNIT_SIZE 2
enum
{
enum
{
...
@@ -175,7 +177,7 @@ typedef struct SFilterInfo {
...
@@ -175,7 +177,7 @@ typedef struct SFilterInfo {
SFilterUnit
*
units
;
SFilterUnit
*
units
;
uint8_t
*
unitRes
;
// result
uint8_t
*
unitRes
;
// result
uint8_t
*
unitFlags
;
// got result
uint8_t
*
unitFlags
;
// got result
SFilterPCtx
*
pctx
;
SFilterPCtx
pctx
;
}
SFilterInfo
;
}
SFilterInfo
;
#define COL_FIELD_SIZE (sizeof(SFilterField) + 2 * sizeof(int64_t))
#define COL_FIELD_SIZE (sizeof(SFilterField) + 2 * sizeof(int64_t))
...
@@ -196,7 +198,7 @@ typedef struct SFilterInfo {
...
@@ -196,7 +198,7 @@ typedef struct SFilterInfo {
#define FILTER_CLR_FLAG(st, f) st &= (~f)
#define FILTER_CLR_FLAG(st, f) st &= (~f)
#define SIMPLE_COPY_VALUES(dst, src) *((int64_t *)dst) = *((int64_t *)src)
#define SIMPLE_COPY_VALUES(dst, src) *((int64_t *)dst) = *((int64_t *)src)
#define FILTER_PACKAGE_UNIT_HASH_KEY(v, optr, idx1, idx2) do { char *_t = (char *)v; _t[0] = optr; *(uint16_t *)(_t + 1) = idx1; *(uint16_t *)(_t + 3) = idx2; } while (0)
#define FILTER_GREATER(cr,sflag,eflag) ((cr > 0) || ((cr == 0) && (FILTER_GET_FLAG(sflag,RA_EXCLUDE) || FILTER_GET_FLAG(eflag,RA_EXCLUDE))))
#define FILTER_GREATER(cr,sflag,eflag) ((cr > 0) || ((cr == 0) && (FILTER_GET_FLAG(sflag,RA_EXCLUDE) || FILTER_GET_FLAG(eflag,RA_EXCLUDE))))
#define FILTER_COPY_RA(dst, src) do { (dst)->sflag = (src)->sflag; (dst)->eflag = (src)->eflag; (dst)->s = (src)->s; (dst)->e = (src)->e; } while (0)
#define FILTER_COPY_RA(dst, src) do { (dst)->sflag = (src)->sflag; (dst)->eflag = (src)->eflag; (dst)->s = (src)->s; (dst)->e = (src)->e; } while (0)
...
...
src/query/src/qFilter.c
浏览文件 @
d77c190e
...
@@ -576,7 +576,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) {
...
@@ -576,7 +576,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
filterGetFiled
(
SFilterFields
*
fields
,
int32_t
type
,
void
*
v
)
{
int32_t
filterGetFiled
ByDesc
(
SFilterFields
*
fields
,
int32_t
type
,
void
*
v
)
{
for
(
uint16_t
i
=
0
;
i
<
fields
->
num
;
++
i
)
{
for
(
uint16_t
i
=
0
;
i
<
fields
->
num
;
++
i
)
{
if
(
0
==
gDescCompare
[
type
](
fields
->
fields
[
i
].
desc
,
v
))
{
if
(
0
==
gDescCompare
[
type
](
fields
->
fields
[
i
].
desc
,
v
))
{
return
i
;
return
i
;
...
@@ -586,14 +586,36 @@ int32_t filterGetFiled(SFilterFields* fields, int32_t type, void *v) {
...
@@ -586,14 +586,36 @@ int32_t filterGetFiled(SFilterFields* fields, int32_t type, void *v) {
return
-
1
;
return
-
1
;
}
}
int32_t
filterAddField
(
SFilterInfo
*
info
,
void
*
desc
,
void
*
data
,
int32_t
type
,
SFilterFieldId
*
fid
)
{
int32_t
filterGetFiledByData
(
SFilterInfo
*
info
,
int32_t
type
,
void
*
v
,
int32_t
dataLen
)
{
if
(
type
==
FLD_TYPE_VALUE
)
{
if
(
info
->
pctx
.
valHash
==
false
)
{
qError
(
"value hash is empty"
);
return
-
1
;
}
void
*
hv
=
taosHashGet
(
info
->
pctx
.
valHash
,
v
,
dataLen
);
if
(
hv
)
{
return
*
(
int32_t
*
)
hv
;
}
}
return
-
1
;
}
int32_t
filterAddField
(
SFilterInfo
*
info
,
void
*
desc
,
void
*
data
,
int32_t
type
,
SFilterFieldId
*
fid
,
int32_t
dataLen
)
{
int32_t
idx
=
-
1
;
int32_t
idx
=
-
1
;
uint16_t
*
num
;
uint16_t
*
num
;
num
=
&
info
->
fields
[
type
].
num
;
num
=
&
info
->
fields
[
type
].
num
;
if
(
*
num
>
0
&&
type
!=
FLD_TYPE_VALUE
)
{
if
(
*
num
>
0
)
{
idx
=
filterGetFiled
(
&
info
->
fields
[
type
],
type
,
desc
);
if
(
type
==
FLD_TYPE_COLUMN
)
{
idx
=
filterGetFiledByDesc
(
&
info
->
fields
[
type
],
type
,
desc
);
}
else
if
(
dataLen
>
0
&&
FILTER_GET_FLAG
(
info
->
options
,
FI_OPTION_NEED_UNIQE
))
{
idx
=
filterGetFiledByData
(
info
,
type
,
data
,
dataLen
);
}
}
}
if
(
idx
<
0
)
{
if
(
idx
<
0
)
{
...
@@ -607,6 +629,14 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void *data, int32_t type,
...
@@ -607,6 +629,14 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void *data, int32_t type,
info
->
fields
[
type
].
fields
[
idx
].
desc
=
desc
;
info
->
fields
[
type
].
fields
[
idx
].
desc
=
desc
;
info
->
fields
[
type
].
fields
[
idx
].
data
=
data
;
info
->
fields
[
type
].
fields
[
idx
].
data
=
data
;
++
(
*
num
);
++
(
*
num
);
if
(
data
&&
dataLen
>
0
&&
FILTER_GET_FLAG
(
info
->
options
,
FI_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
);
}
taosHashPut
(
info
->
pctx
.
valHash
,
data
,
dataLen
,
&
idx
,
sizeof
(
idx
));
}
}
}
fid
->
type
=
type
;
fid
->
type
=
type
;
...
@@ -616,7 +646,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void *data, int32_t type,
...
@@ -616,7 +646,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void *data, int32_t type,
}
}
static
FORCE_INLINE
int32_t
filterAddColFieldFromField
(
SFilterInfo
*
info
,
SFilterField
*
field
,
SFilterFieldId
*
fid
)
{
static
FORCE_INLINE
int32_t
filterAddColFieldFromField
(
SFilterInfo
*
info
,
SFilterField
*
field
,
SFilterFieldId
*
fid
)
{
filterAddField
(
info
,
field
->
desc
,
field
->
data
,
FILTER_GET_TYPE
(
field
->
flag
),
fid
);
filterAddField
(
info
,
field
->
desc
,
field
->
data
,
FILTER_GET_TYPE
(
field
->
flag
),
fid
,
0
);
FILTER_SET_FLAG
(
field
->
flag
,
FLD_DESC_NO_FREE
);
FILTER_SET_FLAG
(
field
->
flag
,
FLD_DESC_NO_FREE
);
FILTER_SET_FLAG
(
field
->
flag
,
FLD_DATA_NO_FREE
);
FILTER_SET_FLAG
(
field
->
flag
,
FLD_DATA_NO_FREE
);
...
@@ -642,12 +672,26 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, tExprNode *node, SFilterFieldI
...
@@ -642,12 +672,26 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, tExprNode *node, SFilterFieldI
node
->
pVal
=
NULL
;
node
->
pVal
=
NULL
;
}
}
filterAddField
(
info
,
v
,
NULL
,
type
,
fid
);
filterAddField
(
info
,
v
,
NULL
,
type
,
fid
,
0
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
filterAddUnit
(
SFilterInfo
*
info
,
uint8_t
optr
,
SFilterFieldId
*
left
,
SFilterFieldId
*
right
)
{
int32_t
filterAddUnit
(
SFilterInfo
*
info
,
uint8_t
optr
,
SFilterFieldId
*
left
,
SFilterFieldId
*
right
,
uint16_t
*
uidx
)
{
if
(
FILTER_GET_FLAG
(
info
->
options
,
FI_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
{
int64_t
v
=
0
;
FILTER_PACKAGE_UNIT_HASH_KEY
(
&
v
,
optr
,
left
->
idx
,
right
?
right
->
idx
:
-
1
);
void
*
hu
=
taosHashGet
(
info
->
pctx
.
unitHash
,
&
v
,
sizeof
(
v
));
if
(
hu
)
{
*
uidx
=
*
(
uint16_t
*
)
hu
;
return
TSDB_CODE_SUCCESS
;
}
}
}
if
(
info
->
unitNum
>=
info
->
unitSize
)
{
if
(
info
->
unitNum
>=
info
->
unitSize
)
{
uint16_t
psize
=
info
->
unitSize
;
uint16_t
psize
=
info
->
unitSize
;
info
->
unitSize
+=
FILTER_DEFAULT_UNIT_SIZE
;
info
->
unitSize
+=
FILTER_DEFAULT_UNIT_SIZE
;
...
@@ -674,6 +718,14 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
...
@@ -674,6 +718,14 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
assert
(
FILTER_GET_FLAG
(
col
->
flag
,
FLD_TYPE_COLUMN
));
assert
(
FILTER_GET_FLAG
(
col
->
flag
,
FLD_TYPE_COLUMN
));
info
->
units
[
info
->
unitNum
].
compare
.
type
=
FILTER_GET_COL_FIELD_TYPE
(
col
);
info
->
units
[
info
->
unitNum
].
compare
.
type
=
FILTER_GET_COL_FIELD_TYPE
(
col
);
*
uidx
=
info
->
unitNum
;
if
(
FILTER_GET_FLAG
(
info
->
options
,
FI_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
));
}
++
info
->
unitNum
;
++
info
->
unitNum
;
...
@@ -702,8 +754,10 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
...
@@ -702,8 +754,10 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
tVariant
*
var
=
tree
->
_node
.
pRight
->
pVal
;
tVariant
*
var
=
tree
->
_node
.
pRight
->
pVal
;
int32_t
type
=
FILTER_GET_COL_FIELD_TYPE
(
FILTER_GET_FIELD
(
info
,
left
));
int32_t
type
=
FILTER_GET_COL_FIELD_TYPE
(
FILTER_GET_FIELD
(
info
,
left
));
int32_t
len
=
0
;
uint16_t
uidx
=
0
;
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_IN
&&
(
!
IS_VAR_DATA_TYPE
(
type
)))
{
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_IN
&&
(
!
IS_VAR_DATA_TYPE
(
type
)))
{
void
*
data
=
NULL
;
void
*
data
=
NULL
;
convertFilterSetFromBinary
((
void
**
)
&
data
,
var
->
pz
,
var
->
nLen
,
type
);
convertFilterSetFromBinary
((
void
**
)
&
data
,
var
->
pz
,
var
->
nLen
,
type
);
CHK_LRET
(
data
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"failed to convert in param"
);
CHK_LRET
(
data
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"failed to convert in param"
);
...
@@ -714,21 +768,23 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
...
@@ -714,21 +768,23 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
void
*
fdata
=
NULL
;
void
*
fdata
=
NULL
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
IS_VAR_DATA_TYPE
(
type
))
{
uint32_t
len
=
taosHashGetDataKeyLen
((
SHashObj
*
)
data
,
p
);
len
=
(
int32_t
)
taosHashGetDataKeyLen
((
SHashObj
*
)
data
,
p
);
fdata
=
malloc
(
len
+
VARSTR_HEADER_SIZE
);
fdata
=
malloc
(
len
+
VARSTR_HEADER_SIZE
);
varDataLen
(
fdata
)
=
len
;
varDataLen
(
fdata
)
=
len
;
memcpy
(
varDataVal
(
fdata
),
key
,
len
);
memcpy
(
varDataVal
(
fdata
),
key
,
len
);
len
+=
VARSTR_HEADER_SIZE
;
}
else
{
}
else
{
fdata
=
malloc
(
sizeof
(
int64_t
));
fdata
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
fdata
,
key
);
SIMPLE_COPY_VALUES
(
fdata
,
key
);
len
=
tDataTypes
[
type
].
bytes
;
}
}
filterAddField
(
info
,
NULL
,
fdata
,
FLD_TYPE_VALUE
,
&
right
);
filterAddField
(
info
,
NULL
,
fdata
,
FLD_TYPE_VALUE
,
&
right
,
len
);
filterAddUnit
(
info
,
TSDB_RELATION_EQUAL
,
&
left
,
&
right
);
filterAddUnit
(
info
,
TSDB_RELATION_EQUAL
,
&
left
,
&
right
,
&
uidx
);
SFilterGroup
fgroup
=
{
0
};
SFilterGroup
fgroup
=
{
0
};
filterAddUnitToGroup
(
&
fgroup
,
info
->
unitNum
-
1
);
filterAddUnitToGroup
(
&
fgroup
,
uidx
);
taosArrayPush
(
group
,
&
fgroup
);
taosArrayPush
(
group
,
&
fgroup
);
...
@@ -737,10 +793,10 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
...
@@ -737,10 +793,10 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
}
else
{
}
else
{
filterAddFieldFromNode
(
info
,
tree
->
_node
.
pRight
,
&
right
);
filterAddFieldFromNode
(
info
,
tree
->
_node
.
pRight
,
&
right
);
filterAddUnit
(
info
,
tree
->
_node
.
optr
,
&
left
,
&
right
);
filterAddUnit
(
info
,
tree
->
_node
.
optr
,
&
left
,
&
right
,
&
uidx
);
SFilterGroup
fgroup
=
{
0
};
SFilterGroup
fgroup
=
{
0
};
filterAddUnitToGroup
(
&
fgroup
,
info
->
unitNum
-
1
);
filterAddUnitToGroup
(
&
fgroup
,
uidx
);
taosArrayPush
(
group
,
&
fgroup
);
taosArrayPush
(
group
,
&
fgroup
);
}
}
...
@@ -749,15 +805,25 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
...
@@ -749,15 +805,25 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
}
}
int32_t
filterAddUnitFromUnit
(
SFilterInfo
*
dst
,
SFilterInfo
*
src
,
SFilterUnit
*
u
)
{
int32_t
filterAddUnitFromUnit
(
SFilterInfo
*
dst
,
SFilterInfo
*
src
,
SFilterUnit
*
u
,
uint16_t
*
uidx
)
{
SFilterFieldId
left
,
right
,
*
pright
=
&
right
;
SFilterFieldId
left
,
right
,
*
pright
=
&
right
;
int32_t
type
=
FILTER_UNIT_DATA_TYPE
(
u
);
filterAddField
(
dst
,
FILTER_UNIT_COL_DESC
(
src
,
u
),
NULL
,
FLD_TYPE_COLUMN
,
&
left
);
filterAddField
(
dst
,
FILTER_UNIT_COL_DESC
(
src
,
u
),
NULL
,
FLD_TYPE_COLUMN
,
&
left
,
0
);
SFilterField
*
t
=
FILTER_UNIT_LEFT_FIELD
(
src
,
u
);
SFilterField
*
t
=
FILTER_UNIT_LEFT_FIELD
(
src
,
u
);
FILTER_SET_FLAG
(
t
->
flag
,
FLD_DESC_NO_FREE
);
FILTER_SET_FLAG
(
t
->
flag
,
FLD_DESC_NO_FREE
);
if
(
u
->
right
.
type
==
FLD_TYPE_VALUE
)
{
if
(
u
->
right
.
type
==
FLD_TYPE_VALUE
)
{
filterAddField
(
dst
,
NULL
,
FILTER_UNIT_VAL_DATA
(
src
,
u
),
FLD_TYPE_VALUE
,
&
right
);
void
*
data
=
FILTER_UNIT_VAL_DATA
(
src
,
u
);
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
FILTER_UNIT_OPTR
(
u
)
==
TSDB_RELATION_IN
)
{
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
,
0
);
}
else
{
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
,
varDataTLen
(
data
));
}
}
else
{
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
);
}
t
=
FILTER_UNIT_RIGHT_FIELD
(
src
,
u
);
t
=
FILTER_UNIT_RIGHT_FIELD
(
src
,
u
);
FILTER_SET_FLAG
(
t
->
flag
,
FLD_DATA_NO_FREE
);
FILTER_SET_FLAG
(
t
->
flag
,
FLD_DATA_NO_FREE
);
}
else
{
}
else
{
...
@@ -765,29 +831,32 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u
...
@@ -765,29 +831,32 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u
}
}
return
filterAddUnit
(
dst
,
FILTER_UNIT_OPTR
(
u
),
&
left
,
pright
);
return
filterAddUnit
(
dst
,
FILTER_UNIT_OPTR
(
u
),
&
left
,
pright
,
uidx
);
}
}
int32_t
filterAddGroupUnitFromCtx
(
SFilterInfo
*
dst
,
SFilterInfo
*
src
,
SFilterRMCtx
*
ctx
,
uint16_t
cidx
,
SFilterGroup
*
g
,
int32_t
optr
,
SArray
*
res
)
{
int32_t
filterAddGroupUnitFromCtx
(
SFilterInfo
*
dst
,
SFilterInfo
*
src
,
SFilterRMCtx
*
ctx
,
uint16_t
cidx
,
SFilterGroup
*
g
,
int32_t
optr
,
SArray
*
res
)
{
SFilterFieldId
left
,
right
;
SFilterFieldId
left
,
right
;
uint16_t
uidx
=
0
;
SFilterField
*
col
=
FILTER_GET_COL_FIELD
(
src
,
cidx
);
SFilterField
*
col
=
FILTER_GET_COL_FIELD
(
src
,
cidx
);
filterAddColFieldFromField
(
dst
,
col
,
&
left
);
filterAddColFieldFromField
(
dst
,
col
,
&
left
);
int32_t
type
=
FILTER_GET_COL_FIELD_TYPE
(
FILTER_GET_FIELD
(
dst
,
left
));
if
(
optr
==
TSDB_RELATION_AND
)
{
if
(
optr
==
TSDB_RELATION_AND
)
{
if
(
ctx
->
isnull
)
{
if
(
ctx
->
isnull
)
{
assert
(
ctx
->
notnull
==
false
&&
ctx
->
isrange
==
false
);
assert
(
ctx
->
notnull
==
false
&&
ctx
->
isrange
==
false
);
filterAddUnit
(
dst
,
TSDB_RELATION_ISNULL
,
&
left
,
NULL
);
filterAddUnit
(
dst
,
TSDB_RELATION_ISNULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
dst
->
unitNum
-
1
);
filterAddUnitToGroup
(
g
,
uidx
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
ctx
->
notnull
)
{
if
(
ctx
->
notnull
)
{
assert
(
ctx
->
isnull
==
false
&&
ctx
->
isrange
==
false
);
assert
(
ctx
->
isnull
==
false
&&
ctx
->
isrange
==
false
);
filterAddUnit
(
dst
,
TSDB_RELATION_NOTNULL
,
&
left
,
NULL
);
filterAddUnit
(
dst
,
TSDB_RELATION_NOTNULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
dst
->
unitNum
-
1
);
filterAddUnitToGroup
(
g
,
uidx
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -803,14 +872,13 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
...
@@ -803,14 +872,13 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
assert
(
!
((
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_NULL
))
&&
(
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_NULL
))));
assert
(
!
((
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_NULL
))
&&
(
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_NULL
))));
if
((
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_NULL
))
&&
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_NULL
)))
{
if
((
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_NULL
))
&&
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_NULL
)))
{
int32_t
type
=
FILTER_GET_COL_FIELD_TYPE
(
FILTER_GET_FIELD
(
dst
,
left
));
__compar_fn_t
func
=
getComparFunc
(
type
,
0
);
__compar_fn_t
func
=
getComparFunc
(
type
,
0
);
if
(
func
(
&
ra
->
s
,
&
ra
->
e
)
==
0
)
{
if
(
func
(
&
ra
->
s
,
&
ra
->
e
)
==
0
)
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
s
);
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
s
);
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
);
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
);
filterAddUnit
(
dst
,
TSDB_RELATION_EQUAL
,
&
left
,
&
right
);
filterAddUnit
(
dst
,
TSDB_RELATION_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
dst
->
unitNum
-
1
);
filterAddUnitToGroup
(
g
,
uidx
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
...
@@ -818,17 +886,17 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
...
@@ -818,17 +886,17 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
if
(
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_NULL
))
{
if
(
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_NULL
))
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
s
);
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
s
);
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
);
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION_GREATER_EQUAL
,
&
left
,
&
right
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
sflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
dst
->
unitNum
-
1
);
filterAddUnitToGroup
(
g
,
uidx
);
}
}
if
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_NULL
))
{
if
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_NULL
))
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
e
);
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
e
);
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
);
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS_EQUAL
,
&
left
,
&
right
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
eflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
dst
->
unitNum
-
1
);
filterAddUnitToGroup
(
g
,
uidx
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -842,8 +910,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
...
@@ -842,8 +910,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
assert
(
ctx
->
isnull
||
ctx
->
notnull
||
ctx
->
isrange
);
assert
(
ctx
->
isnull
||
ctx
->
notnull
||
ctx
->
isrange
);
if
(
ctx
->
isnull
)
{
if
(
ctx
->
isnull
)
{
filterAddUnit
(
dst
,
TSDB_RELATION_ISNULL
,
&
left
,
NULL
);
filterAddUnit
(
dst
,
TSDB_RELATION_ISNULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
dst
->
unitNum
-
1
);
filterAddUnitToGroup
(
g
,
uidx
);
taosArrayPush
(
res
,
g
);
taosArrayPush
(
res
,
g
);
}
}
...
@@ -851,8 +919,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
...
@@ -851,8 +919,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
assert
(
!
ctx
->
isrange
);
assert
(
!
ctx
->
isrange
);
memset
(
g
,
0
,
sizeof
(
*
g
));
memset
(
g
,
0
,
sizeof
(
*
g
));
filterAddUnit
(
dst
,
TSDB_RELATION_NOTNULL
,
&
left
,
NULL
);
filterAddUnit
(
dst
,
TSDB_RELATION_NOTNULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
dst
->
unitNum
-
1
);
filterAddUnitToGroup
(
g
,
uidx
);
taosArrayPush
(
res
,
g
);
taosArrayPush
(
res
,
g
);
}
}
...
@@ -868,14 +936,13 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
...
@@ -868,14 +936,13 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
memset
(
g
,
0
,
sizeof
(
*
g
));
memset
(
g
,
0
,
sizeof
(
*
g
));
if
((
!
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_NULL
))
&&
(
!
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_NULL
)))
{
if
((
!
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_NULL
))
&&
(
!
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_NULL
)))
{
int32_t
type
=
FILTER_GET_COL_FIELD_TYPE
(
FILTER_GET_FIELD
(
dst
,
left
));
__compar_fn_t
func
=
getComparFunc
(
type
,
0
);
__compar_fn_t
func
=
getComparFunc
(
type
,
0
);
if
(
func
(
&
r
->
ra
.
s
,
&
r
->
ra
.
e
)
==
0
)
{
if
(
func
(
&
r
->
ra
.
s
,
&
r
->
ra
.
e
)
==
0
)
{
void
*
data
=
malloc
(
sizeof
(
int64_t
));
void
*
data
=
malloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
s
);
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
s
);
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
);
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
);
filterAddUnit
(
dst
,
TSDB_RELATION_EQUAL
,
&
left
,
&
right
);
filterAddUnit
(
dst
,
TSDB_RELATION_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
dst
->
unitNum
-
1
);
filterAddUnitToGroup
(
g
,
uidx
);
taosArrayPush
(
res
,
g
);
taosArrayPush
(
res
,
g
);
...
@@ -885,15 +952,19 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
...
@@ -885,15 +952,19 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRMC
}
}
if
(
!
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_NULL
))
{
if
(
!
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_NULL
))
{
filterAddField
(
dst
,
NULL
,
&
r
->
ra
.
s
,
FLD_TYPE_VALUE
,
&
right
);
void
*
data
=
malloc
(
sizeof
(
int64_t
));
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION_GREATER_EQUAL
,
&
left
,
&
right
);
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
s
);
filterAddUnitToGroup
(
g
,
dst
->
unitNum
-
1
);
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_GREATER
:
TSDB_RELATION_GREATER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
}
if
(
!
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_NULL
))
{
if
(
!
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_NULL
))
{
filterAddField
(
dst
,
NULL
,
&
r
->
ra
.
e
,
FLD_TYPE_VALUE
,
&
right
);
void
*
data
=
malloc
(
sizeof
(
int64_t
));
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS_EQUAL
,
&
left
,
&
right
);
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
e
);
filterAddUnitToGroup
(
g
,
dst
->
unitNum
-
1
);
filterAddField
(
dst
,
NULL
,
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RA_EXCLUDE
)
?
TSDB_RELATION_LESS
:
TSDB_RELATION_LESS_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
}
assert
(
g
->
unitNum
>
0
);
assert
(
g
->
unitNum
>
0
);
...
@@ -1667,6 +1738,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum
...
@@ -1667,6 +1738,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum
SFilterGroupCtx
*
res
=
NULL
;
SFilterGroupCtx
*
res
=
NULL
;
SFilterColInfo
*
colInfo
=
NULL
;
SFilterColInfo
*
colInfo
=
NULL
;
int32_t
optr
=
0
;
int32_t
optr
=
0
;
uint16_t
uidx
=
0
;
memset
(
info
,
0
,
sizeof
(
*
info
));
memset
(
info
,
0
,
sizeof
(
*
info
));
...
@@ -1690,8 +1762,8 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum
...
@@ -1690,8 +1762,8 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum
for
(
int32_t
n
=
0
;
n
<
usize
;
++
n
)
{
for
(
int32_t
n
=
0
;
n
<
usize
;
++
n
)
{
SFilterUnit
*
u
=
taosArrayGetP
((
SArray
*
)
colInfo
->
info
,
n
);
SFilterUnit
*
u
=
taosArrayGetP
((
SArray
*
)
colInfo
->
info
,
n
);
filterAddUnitFromUnit
(
info
,
&
oinfo
,
u
);
filterAddUnitFromUnit
(
info
,
&
oinfo
,
u
,
&
uidx
);
filterAddUnitToGroup
(
&
ng
,
info
->
unitNum
-
1
);
filterAddUnitToGroup
(
&
ng
,
uidx
);
}
}
continue
;
continue
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录