Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0b3ebaeb
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
0b3ebaeb
编写于
8月 01, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix test cases
上级
6d1b2e6d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
257 addition
and
257 deletion
+257
-257
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+257
-257
未找到文件。
source/libs/scalar/src/filter.c
浏览文件 @
0b3ebaeb
...
...
@@ -98,7 +98,7 @@ rangeCompFunc filterGetRangeCompFunc(char sflag, char eflag) {
if
(
FILTER_GET_FLAG
(
eflag
,
RANGE_FLG_EXCLUDE
))
{
return
filterRangeCompLe
;
}
return
filterRangeCompLi
;
}
...
...
@@ -106,7 +106,7 @@ rangeCompFunc filterGetRangeCompFunc(char sflag, char eflag) {
if
(
FILTER_GET_FLAG
(
sflag
,
RANGE_FLG_EXCLUDE
))
{
return
filterRangeCompGe
;
}
return
filterRangeCompGi
;
}
...
...
@@ -131,7 +131,7 @@ rangeCompFunc gRangeCompare[] = {filterRangeCompee, filterRangeCompei, filterRan
int8_t
filterGetRangeCompFuncFromOptrs
(
uint8_t
optr
,
uint8_t
optr2
)
{
if
(
optr2
)
{
assert
(
optr2
==
OP_TYPE_LOWER_THAN
||
optr2
==
OP_TYPE_LOWER_EQUAL
);
assert
(
optr2
==
OP_TYPE_LOWER_THAN
||
optr2
==
OP_TYPE_LOWER_EQUAL
);
if
(
optr
==
OP_TYPE_GREATER_THAN
)
{
if
(
optr2
==
OP_TYPE_LOWER_THAN
)
{
...
...
@@ -165,9 +165,9 @@ int8_t filterGetRangeCompFuncFromOptrs(uint8_t optr, uint8_t optr2) {
}
__compar_fn_t
gDataCompare
[]
=
{
compareInt32Val
,
compareInt8Val
,
compareInt16Val
,
compareInt64Val
,
compareFloatVal
,
compareDoubleVal
,
compareLenPrefixedStr
,
compareStrPatternMatch
,
compareChkInString
,
compareWStrPatternMatch
,
compareDoubleVal
,
compareLenPrefixedStr
,
compareStrPatternMatch
,
compareChkInString
,
compareWStrPatternMatch
,
compareLenPrefixedWStr
,
compareUint8Val
,
compareUint16Val
,
compareUint32Val
,
compareUint64Val
,
setChkInBytes1
,
setChkInBytes2
,
setChkInBytes4
,
setChkInBytes8
,
compareStrRegexCompMatch
,
setChkInBytes1
,
setChkInBytes2
,
setChkInBytes4
,
setChkInBytes8
,
compareStrRegexCompMatch
,
compareStrRegexCompNMatch
,
setChkNotInBytes1
,
setChkNotInBytes2
,
setChkNotInBytes4
,
setChkNotInBytes8
,
compareChkNotInString
,
compareStrPatternNotMatch
,
compareWStrPatternNotMatch
};
...
...
@@ -178,20 +178,20 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
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
:
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
return
15
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
return
16
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
return
17
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
18
;
case
TSDB_DATA_TYPE_JSON
:
terrno
=
TSDB_CODE_QRY_JSON_IN_ERROR
;
...
...
@@ -204,20 +204,20 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
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
:
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
return
21
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
return
22
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
return
23
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
24
;
case
TSDB_DATA_TYPE_JSON
:
terrno
=
TSDB_CODE_QRY_JSON_IN_ERROR
;
...
...
@@ -257,10 +257,10 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
}
else
{
/* normal relational comparFn */
comparFn
=
6
;
}
break
;
}
case
TSDB_DATA_TYPE_NCHAR
:
{
if
(
optr
==
OP_TYPE_MATCH
)
{
comparFn
=
19
;
...
...
@@ -289,7 +289,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
comparFn
=
0
;
break
;
}
return
comparFn
;
}
...
...
@@ -308,7 +308,7 @@ static FORCE_INLINE int32_t filterCompareGroupCtx(const void *pLeft, const void
int32_t
filterInitUnitsFields
(
SFilterInfo
*
info
)
{
info
->
unitSize
=
FILTER_DEFAULT_UNIT_SIZE
;
info
->
units
=
taosMemoryCalloc
(
info
->
unitSize
,
sizeof
(
SFilterUnit
));
info
->
fields
[
FLD_TYPE_COLUMN
].
num
=
0
;
info
->
fields
[
FLD_TYPE_COLUMN
].
size
=
FILTER_DEFAULT_FIELD_SIZE
;
info
->
fields
[
FLD_TYPE_COLUMN
].
fields
=
taosMemoryCalloc
(
info
->
fields
[
FLD_TYPE_COLUMN
].
size
,
sizeof
(
SFilterField
));
...
...
@@ -321,7 +321,7 @@ int32_t filterInitUnitsFields(SFilterInfo *info) {
static
FORCE_INLINE
SFilterRangeNode
*
filterNewRange
(
SFilterRangeCtx
*
ctx
,
SFilterRange
*
ra
)
{
SFilterRangeNode
*
r
=
NULL
;
if
(
ctx
->
rf
)
{
r
=
ctx
->
rf
;
ctx
->
rf
=
ctx
->
rf
->
next
;
...
...
@@ -341,7 +341,7 @@ void* filterInitRangeCtx(int32_t type, int32_t options) {
qError
(
"not supported range type:%d"
,
type
);
return
NULL
;
}
SFilterRangeCtx
*
ctx
=
taosMemoryCalloc
(
1
,
sizeof
(
SFilterRangeCtx
));
ctx
->
type
=
type
;
...
...
@@ -366,7 +366,7 @@ int32_t filterResetRangeCtx(SFilterRangeCtx *ctx) {
ctx
->
isrange
=
false
;
SFilterRangeNode
*
r
=
ctx
->
rf
;
while
(
r
&&
r
->
next
)
{
r
=
r
->
next
;
}
...
...
@@ -402,7 +402,7 @@ int32_t filterConvertRange(SFilterRangeCtx *cur, SFilterRange *ra, bool *notNull
}
}
if
(
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_NULL
)
&&
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_NULL
))
{
*
notNull
=
true
;
}
else
{
...
...
@@ -438,7 +438,7 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) {
SFilterRangeCtx
*
ctx
=
(
SFilterRangeCtx
*
)
h
;
if
(
ctx
->
rs
==
NULL
)
{
if
((
FILTER_GET_FLAG
(
ctx
->
status
,
MR_ST_START
)
==
0
)
if
((
FILTER_GET_FLAG
(
ctx
->
status
,
MR_ST_START
)
==
0
)
||
(
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
);
...
...
@@ -489,23 +489,23 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) {
//TSDB_RELATION_OR
bool
smerged
=
false
;
bool
emerged
=
false
;
while
(
r
!=
NULL
)
{
cr
=
ctx
->
pCompareFunc
(
&
r
->
ra
.
s
,
&
ra
->
e
);
if
(
FILTER_GREATER
(
cr
,
r
->
ra
.
sflag
,
ra
->
eflag
))
{
if
(
FILTER_GREATER
(
cr
,
r
->
ra
.
sflag
,
ra
->
eflag
))
{
if
(
emerged
==
false
)
{
INSERT_RANGE
(
ctx
,
r
,
ra
);
}
break
;
}
if
(
smerged
==
false
)
{
cr
=
ctx
->
pCompareFunc
(
&
ra
->
s
,
&
r
->
ra
.
e
);
if
(
FILTER_GREATER
(
cr
,
ra
->
sflag
,
r
->
ra
.
eflag
))
{
if
(
FILTER_GREATER
(
cr
,
ra
->
sflag
,
r
->
ra
.
eflag
))
{
if
(
r
->
next
)
{
r
=
r
->
next
;
continue
;
...
...
@@ -516,23 +516,23 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) {
}
cr
=
ctx
->
pCompareFunc
(
&
r
->
ra
.
s
,
&
ra
->
s
);
if
(
FILTER_GREATER
(
cr
,
r
->
ra
.
sflag
,
ra
->
sflag
))
{
SIMPLE_COPY_VALUES
((
char
*
)
&
r
->
ra
.
s
,
&
ra
->
s
);
if
(
FILTER_GREATER
(
cr
,
r
->
ra
.
sflag
,
ra
->
sflag
))
{
SIMPLE_COPY_VALUES
((
char
*
)
&
r
->
ra
.
s
,
&
ra
->
s
);
cr
==
0
?
(
r
->
ra
.
sflag
&=
ra
->
sflag
)
:
(
r
->
ra
.
sflag
=
ra
->
sflag
);
}
smerged
=
true
;
}
if
(
emerged
==
false
)
{
cr
=
ctx
->
pCompareFunc
(
&
ra
->
e
,
&
r
->
ra
.
e
);
if
(
FILTER_GREATER
(
cr
,
ra
->
eflag
,
r
->
ra
.
eflag
))
{
SIMPLE_COPY_VALUES
((
char
*
)
&
r
->
ra
.
e
,
&
ra
->
e
);
if
(
cr
==
0
)
{
if
(
cr
==
0
)
{
r
->
ra
.
eflag
&=
ra
->
eflag
;
break
;
}
r
->
ra
.
eflag
=
ra
->
eflag
;
emerged
=
true
;
r
=
r
->
next
;
...
...
@@ -553,7 +553,7 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) {
SIMPLE_COPY_VALUES
(
&
r
->
prev
->
ra
.
e
,
(
char
*
)
&
r
->
ra
.
e
);
cr
==
0
?
(
r
->
prev
->
ra
.
eflag
&=
r
->
ra
.
eflag
)
:
(
r
->
prev
->
ra
.
eflag
=
r
->
ra
.
eflag
);
FREE_RANGE
(
ctx
,
r
);
break
;
}
}
...
...
@@ -571,12 +571,12 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) {
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
filterAddRange
(
void
*
h
,
SFilterRange
*
ra
,
int32_t
optr
)
{
SFilterRangeCtx
*
ctx
=
(
SFilterRangeCtx
*
)
h
;
if
(
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_NULL
))
{
SIMPLE_COPY_VALUES
(
&
ra
->
s
,
getDataMin
(
ctx
->
type
));
//FILTER_CLR_FLAG(ra->sflag, RA_NULL);
...
...
@@ -602,7 +602,7 @@ int32_t filterAddRangeCtx(void *dst, void *src, int32_t optr) {
}
SFilterRangeNode
*
r
=
sctx
->
rs
;
while
(
r
)
{
filterAddRange
(
dctx
,
&
r
->
ra
,
optr
);
r
=
r
->
next
;
...
...
@@ -616,14 +616,14 @@ int32_t filterCopyRangeCtx(void *dst, void *src) {
SFilterRangeCtx
*
sctx
=
(
SFilterRangeCtx
*
)
src
;
dctx
->
status
=
sctx
->
status
;
dctx
->
isnull
=
sctx
->
isnull
;
dctx
->
notnull
=
sctx
->
notnull
;
dctx
->
isrange
=
sctx
->
isrange
;
SFilterRangeNode
*
r
=
sctx
->
rs
;
SFilterRangeNode
*
dr
=
dctx
->
rs
;
while
(
r
)
{
APPEND_RANGE
(
dctx
,
dr
,
&
r
->
ra
);
if
(
dr
==
NULL
)
{
...
...
@@ -649,7 +649,7 @@ int32_t filterFinishRange(void* h) {
if
(
FILTER_GET_FLAG
(
ctx
->
options
,
FLT_OPTION_TIMESTAMP
))
{
SFilterRangeNode
*
r
=
ctx
->
rs
;
SFilterRangeNode
*
rn
=
NULL
;
while
(
r
&&
r
->
next
)
{
int64_t
tmp
=
1
;
operateVal
(
&
tmp
,
&
r
->
ra
.
e
,
&
tmp
,
OP_TYPE_ADD
,
ctx
->
type
);
...
...
@@ -658,10 +658,10 @@ int32_t filterFinishRange(void* h) {
SIMPLE_COPY_VALUES
((
char
*
)
&
r
->
next
->
ra
.
s
,
(
char
*
)
&
r
->
ra
.
s
);
FREE_RANGE
(
ctx
,
r
);
r
=
rn
;
continue
;
}
r
=
r
->
next
;
}
}
...
...
@@ -673,13 +673,13 @@ int32_t filterFinishRange(void* h) {
int32_t
filterGetRangeNum
(
void
*
h
,
int32_t
*
num
)
{
filterFinishRange
(
h
);
SFilterRangeCtx
*
ctx
=
(
SFilterRangeCtx
*
)
h
;
*
num
=
0
;
SFilterRangeNode
*
r
=
ctx
->
rs
;
while
(
r
)
{
++
(
*
num
);
r
=
r
->
next
;
...
...
@@ -695,7 +695,7 @@ int32_t filterGetRangeRes(void* h, SFilterRange *ra) {
SFilterRangeCtx
*
ctx
=
(
SFilterRangeCtx
*
)
h
;
uint32_t
num
=
0
;
SFilterRangeNode
*
r
=
ctx
->
rs
;
while
(
r
)
{
if
(
num
)
{
ra
->
e
=
r
->
ra
.
e
;
...
...
@@ -712,7 +712,7 @@ int32_t filterGetRangeRes(void* h, SFilterRange *ra) {
qError
(
"no range result"
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -740,7 +740,7 @@ int32_t filterSourceRangeFromCtx(SFilterRangeCtx *ctx, void *sctx, int32_t optr,
if
(
!
(
optr
==
LOGIC_COND_TYPE_OR
&&
ctx
->
notnull
))
{
filterAddRangeCtx
(
ctx
,
src
,
optr
);
}
if
(
FILTER_GET_FLAG
(
ctx
->
status
,
MR_ST_ALL
))
{
*
all
=
true
;
}
...
...
@@ -755,11 +755,11 @@ int32_t filterFreeRangeCtx(void* h) {
if
(
h
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
}
SFilterRangeCtx
*
ctx
=
(
SFilterRangeCtx
*
)
h
;
SFilterRangeNode
*
r
=
ctx
->
rs
;
SFilterRangeNode
*
rn
=
NULL
;
while
(
r
)
{
rn
=
r
->
next
;
taosMemoryFree
(
r
);
...
...
@@ -785,10 +785,10 @@ int32_t filterDetachCnfGroup(SFilterGroup *gp1, SFilterGroup *gp2, SArray* group
gp
.
unitNum
=
gp1
->
unitNum
+
gp2
->
unitNum
;
gp
.
unitIdxs
=
taosMemoryCalloc
(
gp
.
unitNum
,
sizeof
(
*
gp
.
unitIdxs
));
memcpy
(
gp
.
unitIdxs
,
gp1
->
unitIdxs
,
gp1
->
unitNum
*
sizeof
(
*
gp
.
unitIdxs
));
memcpy
(
gp
.
unitIdxs
+
gp1
->
unitNum
,
gp2
->
unitIdxs
,
gp2
->
unitNum
*
sizeof
(
*
gp
.
unitIdxs
));
memcpy
(
gp
.
unitIdxs
+
gp1
->
unitNum
,
gp2
->
unitIdxs
,
gp2
->
unitNum
*
sizeof
(
*
gp
.
unitIdxs
));
gp
.
unitFlags
=
NULL
;
taosArrayPush
(
group
,
&
gp
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -802,7 +802,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) {
if
(
taosArrayGetSize
(
left
)
<=
0
)
{
if
(
taosArrayGetSize
(
right
)
<=
0
)
{
fltError
(
"both groups are empty"
);
FLT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
FLT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
SFilterGroup
*
gp
=
NULL
;
...
...
@@ -813,7 +813,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) {
return
TSDB_CODE_SUCCESS
;
}
if
(
taosArrayGetSize
(
right
)
<=
0
)
{
if
(
taosArrayGetSize
(
right
)
<=
0
)
{
SFilterGroup
*
gp
=
NULL
;
while
((
gp
=
(
SFilterGroup
*
)
taosArrayPop
(
left
))
!=
NULL
)
{
taosArrayPush
(
group
,
gp
);
...
...
@@ -821,10 +821,10 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) {
return
TSDB_CODE_SUCCESS
;
}
for
(
int32_t
l
=
0
;
l
<
leftSize
;
++
l
)
{
SFilterGroup
*
gp1
=
taosArrayGet
(
left
,
l
);
for
(
int32_t
r
=
0
;
r
<
rightSize
;
++
r
)
{
SFilterGroup
*
gp2
=
taosArrayGet
(
right
,
r
);
...
...
@@ -878,15 +878,15 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type,
idx
=
filterGetFiledByData
(
info
,
type
,
*
data
,
dataLen
);
}
}
if
(
idx
<
0
)
{
idx
=
*
num
;
if
(
idx
>=
info
->
fields
[
type
].
size
)
{
info
->
fields
[
type
].
size
+=
FILTER_DEFAULT_FIELD_SIZE
;
info
->
fields
[
type
].
fields
=
taosMemoryRealloc
(
info
->
fields
[
type
].
fields
,
info
->
fields
[
type
].
size
*
sizeof
(
SFilterField
));
}
info
->
fields
[
type
].
fields
[
idx
].
flag
=
type
;
info
->
fields
[
type
].
fields
[
idx
].
flag
=
type
;
info
->
fields
[
type
].
fields
[
idx
].
desc
=
desc
;
info
->
fields
[
type
].
fields
[
idx
].
data
=
data
?
*
data
:
NULL
;
...
...
@@ -900,7 +900,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type,
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
));
}
}
else
{
...
...
@@ -911,7 +911,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type,
fid
->
type
=
type
;
fid
->
idx
=
idx
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -929,11 +929,11 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *f
fltError
(
"empty node"
);
FLT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
if
(
nodeType
(
node
)
!=
QUERY_NODE_COLUMN
&&
nodeType
(
node
)
!=
QUERY_NODE_VALUE
&&
nodeType
(
node
)
!=
QUERY_NODE_NODE_LIST
)
{
FLT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
int32_t
type
;
void
*
v
;
...
...
@@ -946,7 +946,7 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *f
}
filterAddField
(
info
,
v
,
NULL
,
type
,
fid
,
0
,
true
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -973,7 +973,7 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
}
SFilterUnit
*
u
=
&
info
->
units
[
info
->
unitNum
];
u
->
compare
.
optr
=
optr
;
u
->
left
=
*
left
;
if
(
right
)
{
...
...
@@ -981,7 +981,7 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
}
if
(
u
->
right
.
type
==
FLD_TYPE_VALUE
)
{
SFilterField
*
val
=
FILTER_UNIT_RIGHT_FIELD
(
info
,
u
);
SFilterField
*
val
=
FILTER_UNIT_RIGHT_FIELD
(
info
,
u
);
assert
(
FILTER_GET_FLAG
(
val
->
flag
,
FLD_TYPE_VALUE
));
}
else
{
int32_t
paramNum
=
scalarGetOperatorParamNum
(
optr
);
...
...
@@ -990,10 +990,10 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
SFilterField
*
col
=
FILTER_UNIT_LEFT_FIELD
(
info
,
u
);
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
.
precision
=
FILTER_GET_COL_FIELD_PRECISION
(
col
);
...
...
@@ -1001,12 +1001,12 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
if
(
FILTER_GET_FLAG
(
info
->
options
,
FLT_OPTION_NEED_UNIQE
))
{
int64_t
v
=
0
;
FILTER_PACKAGE_UNIT_HASH_KEY
(
&
v
,
optr
,
left
->
idx
,
right
?
right
->
idx
:
-
1
);
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
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1017,7 +1017,7 @@ int32_t filterAddUnitToGroup(SFilterGroup *group, uint32_t unitIdx) {
group
->
unitSize
+=
FILTER_DEFAULT_UNIT_SIZE
;
group
->
unitIdxs
=
taosMemoryRealloc
(
group
->
unitIdxs
,
group
->
unitSize
*
sizeof
(
*
group
->
unitIdxs
));
}
group
->
unitIdxs
[
group
->
unitNum
++
]
=
unitIdx
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1040,10 +1040,10 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) {
SScalarParam
out
=
{.
columnData
=
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
))};
out
.
columnData
->
info
.
type
=
type
;
out
.
columnData
->
info
.
bytes
=
tDataTypes
[
type
].
bytes
;
for
(
int32_t
i
=
0
;
i
<
listNode
->
pNodeList
->
length
;
++
i
)
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
cell
->
pNode
;
if
(
valueNode
->
node
.
resType
.
type
!=
type
)
{
if
(
valueNode
->
node
.
resType
.
type
!=
type
)
{
int32_t
overflow
=
0
;
code
=
doConvertDataType
(
valueNode
,
&
out
,
&
overflow
);
if
(
code
)
{
...
...
@@ -1055,7 +1055,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) {
cell
=
cell
->
pNext
;
continue
;
}
len
=
tDataTypes
[
type
].
bytes
;
filterAddField
(
info
,
NULL
,
(
void
**
)
&
out
.
columnData
->
pData
,
FLD_TYPE_VALUE
,
&
right
,
len
,
true
);
...
...
@@ -1066,13 +1066,13 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) {
FLT_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
memcpy
(
data
,
nodesGetValueFromNode
(
valueNode
),
tDataTypes
[
type
].
bytes
);
filterAddField
(
info
,
NULL
,
(
void
**
)
&
data
,
FLD_TYPE_VALUE
,
&
right
,
len
,
true
);
filterAddField
(
info
,
NULL
,
(
void
**
)
&
data
,
FLD_TYPE_VALUE
,
&
right
,
len
,
true
);
}
filterAddUnit
(
info
,
OP_TYPE_EQUAL
,
&
left
,
&
right
,
&
uidx
);
SFilterGroup
fgroup
=
{
0
};
filterAddUnitToGroup
(
&
fgroup
,
uidx
);
taosArrayPush
(
group
,
&
fgroup
);
cell
=
cell
->
pNext
;
...
...
@@ -1081,14 +1081,14 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) {
taosMemoryFree
(
out
.
columnData
);
}
else
{
filterAddFieldFromNode
(
info
,
node
->
pRight
,
&
right
);
FLT_ERR_RET
(
filterAddUnit
(
info
,
node
->
opType
,
&
left
,
&
right
,
&
uidx
));
SFilterGroup
fgroup
=
{
0
};
filterAddUnitToGroup
(
&
fgroup
,
uidx
);
taosArrayPush
(
group
,
&
fgroup
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1100,7 +1100,7 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u
filterAddField
(
dst
,
FILTER_UNIT_COL_DESC
(
src
,
u
),
NULL
,
FLD_TYPE_COLUMN
,
&
left
,
0
,
false
);
SFilterField
*
t
=
FILTER_UNIT_LEFT_FIELD
(
src
,
u
);
if
(
u
->
right
.
type
==
FLD_TYPE_VALUE
)
{
void
*
data
=
FILTER_UNIT_VAL_DATA
(
src
,
u
);
if
(
IS_VAR_DATA_TYPE
(
type
))
{
...
...
@@ -1116,7 +1116,7 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
false
);
}
flag
=
FLD_DATA_NO_FREE
;
flag
=
FLD_DATA_NO_FREE
;
t
=
FILTER_UNIT_RIGHT_FIELD
(
src
,
u
);
FILTER_SET_FLAG
(
t
->
flag
,
flag
);
}
else
{
...
...
@@ -1152,7 +1152,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
return
TSDB_CODE_SUCCESS
;
}
if
(
ctx
->
notnull
)
{
if
(
ctx
->
notnull
)
{
assert
(
ctx
->
isnull
==
false
&&
ctx
->
isrange
==
false
);
filterAddUnit
(
dst
,
OP_TYPE_IS_NOT_NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
...
...
@@ -1167,7 +1167,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
assert
(
ctx
->
rs
&&
ctx
->
rs
->
next
==
NULL
);
SFilterRange
*
ra
=
&
ctx
->
rs
->
ra
;
assert
(
!
((
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_NULL
))
&&
(
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_NULL
))));
if
((
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_NULL
))
&&
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_NULL
)))
{
...
...
@@ -1178,7 +1178,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
OP_TYPE_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
{
void
*
data
=
taosMemoryMalloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
s
);
...
...
@@ -1186,14 +1186,14 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
void
*
data2
=
taosMemoryMalloc
(
sizeof
(
int64_t
));
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
)
?
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
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_NULL
))
{
void
*
data
=
taosMemoryMalloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
ra
->
s
);
...
...
@@ -1208,28 +1208,28 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
filterAddField
(
dst
,
NULL
,
&
data
,
FLD_TYPE_VALUE
,
&
right
,
tDataTypes
[
type
].
bytes
,
true
);
filterAddUnit
(
dst
,
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_EXCLUDE
)
?
OP_TYPE_LOWER_THAN
:
OP_TYPE_LOWER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
}
}
return
TSDB_CODE_SUCCESS
;
}
return
TSDB_CODE_SUCCESS
;
}
// OR PROCESS
SFilterGroup
ng
=
{
0
};
g
=
&
ng
;
assert
(
ctx
->
isnull
||
ctx
->
notnull
||
ctx
->
isrange
);
if
(
ctx
->
isnull
)
{
filterAddUnit
(
dst
,
OP_TYPE_IS_NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
taosArrayPush
(
res
,
g
);
}
if
(
ctx
->
notnull
)
{
assert
(
!
ctx
->
isrange
);
memset
(
g
,
0
,
sizeof
(
*
g
));
filterAddUnit
(
dst
,
OP_TYPE_IS_NOT_NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
taosArrayPush
(
res
,
g
);
...
...
@@ -1242,7 +1242,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
}
SFilterRangeNode
*
r
=
ctx
->
rs
;
while
(
r
)
{
memset
(
g
,
0
,
sizeof
(
*
g
));
...
...
@@ -1261,19 +1261,19 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
void
*
data2
=
taosMemoryMalloc
(
sizeof
(
int64_t
));
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
)
?
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
);
}
taosArrayPush
(
res
,
g
);
r
=
r
->
next
;
continue
;
}
if
(
!
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RANGE_FLG_NULL
))
{
void
*
data
=
taosMemoryMalloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
s
);
...
...
@@ -1281,10 +1281,10 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
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
);
}
if
(
!
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RANGE_FLG_NULL
))
{
void
*
data
=
taosMemoryMalloc
(
sizeof
(
int64_t
));
SIMPLE_COPY_VALUES
(
data
,
&
r
->
ra
.
e
);
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
)
?
OP_TYPE_LOWER_THAN
:
OP_TYPE_LOWER_EQUAL
,
&
left
,
&
right
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
...
...
@@ -1307,7 +1307,7 @@ static void filterFreeGroup(void *pItem) {
if
(
pItem
==
NULL
)
{
return
;
}
SFilterGroup
*
p
=
(
SFilterGroup
*
)
pItem
;
taosMemoryFreeClear
(
p
->
unitIdxs
);
taosMemoryFreeClear
(
p
->
unitFlags
);
...
...
@@ -1329,17 +1329,17 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) {
for
(
int32_t
i
=
0
;
i
<
node
->
pParameterList
->
length
;
++
i
)
{
newGroup
=
taosArrayInit
(
4
,
sizeof
(
SFilterGroup
));
resGroup
=
taosArrayInit
(
4
,
sizeof
(
SFilterGroup
));
SFltBuildGroupCtx
tctx
=
{.
info
=
ctx
->
info
,
.
group
=
newGroup
};
nodesWalkExpr
(
cell
->
pNode
,
fltTreeToGroup
,
(
void
*
)
&
tctx
);
FLT_ERR_JRET
(
tctx
.
code
);
FLT_ERR_JRET
(
filterDetachCnfGroups
(
resGroup
,
preGroup
,
newGroup
));
taosArrayDestroyEx
(
newGroup
,
filterFreeGroup
);
newGroup
=
NULL
;
taosArrayDestroyEx
(
preGroup
,
filterFreeGroup
);
preGroup
=
resGroup
;
resGroup
=
NULL
;
...
...
@@ -1349,7 +1349,7 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) {
taosArrayAddAll
(
ctx
->
group
,
preGroup
);
taosArrayDestroy
(
preGroup
);
return
DEAL_RES_IGNORE_CHILD
;
}
...
...
@@ -1358,23 +1358,23 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) {
for
(
int32_t
i
=
0
;
i
<
node
->
pParameterList
->
length
;
++
i
)
{
nodesWalkExpr
(
cell
->
pNode
,
fltTreeToGroup
,
(
void
*
)
pContext
);
FLT_ERR_JRET
(
ctx
->
code
);
cell
=
cell
->
pNext
;
}
return
DEAL_RES_IGNORE_CHILD
;
}
ctx
->
code
=
TSDB_CODE_QRY_APP_ERROR
;
fltError
(
"invalid condition type, type:%d"
,
node
->
condType
);
return
DEAL_RES_ERROR
;
}
if
(
QUERY_NODE_OPERATOR
==
nType
)
{
FLT_ERR_JRET
(
fltAddGroupUnitFromNode
(
ctx
->
info
,
pNode
,
ctx
->
group
));
FLT_ERR_JRET
(
fltAddGroupUnitFromNode
(
ctx
->
info
,
pNode
,
ctx
->
group
));
return
DEAL_RES_IGNORE_CHILD
;
}
...
...
@@ -1497,7 +1497,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
SValueNode
*
var
=
(
SValueNode
*
)
field
->
desc
;
SDataType
*
dType
=
&
var
->
node
.
resType
;
if
(
dType
->
type
==
TSDB_DATA_TYPE_VALUE_ARRAY
)
{
qDebug
(
"VAL%d => [type:TS][val:[%"
PRIi64
"] - [%"
PRId64
"]]"
,
i
,
*
(
int64_t
*
)
field
->
data
,
*
(((
int64_t
*
)
field
->
data
)
+
1
));
qDebug
(
"VAL%d => [type:TS][val:[%"
PRIi64
"] - [%"
PRId64
"]]"
,
i
,
*
(
int64_t
*
)
field
->
data
,
*
(((
int64_t
*
)
field
->
data
)
+
1
));
}
else
{
qDebug
(
"VAL%d => [type:%d][val:%"
PRIx64
"]"
,
i
,
dType
->
type
,
var
->
datum
.
i
);
//TODO
}
...
...
@@ -1513,7 +1513,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
int32_t
len
=
0
;
int32_t
tlen
=
0
;
char
str
[
512
]
=
{
0
};
SFilterField
*
left
=
FILTER_UNIT_LEFT_FIELD
(
info
,
unit
);
SColumnNode
*
refNode
=
(
SColumnNode
*
)
left
->
desc
;
if
(
unit
->
compare
.
optr
>=
0
&&
unit
->
compare
.
optr
<=
OP_TYPE_JSON_CONTAINS
){
...
...
@@ -1538,7 +1538,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
if
(
unit
->
compare
.
optr2
>=
0
&&
unit
->
compare
.
optr2
<=
OP_TYPE_JSON_CONTAINS
){
sprintf
(
str
+
strlen
(
str
),
"[%d][%d] %s ["
,
refNode
->
dataBlockId
,
refNode
->
slotId
,
gOptrStr
[
unit
->
compare
.
optr2
].
str
);
}
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
;
...
...
@@ -1552,7 +1552,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
}
strcat
(
str
,
"]"
);
}
qDebug
(
"%s"
,
str
);
//TODO
}
...
...
@@ -1576,10 +1576,10 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
for
(
uint32_t
i
=
0
;
i
<
info
->
colRangeNum
;
++
i
)
{
SFilterRangeCtx
*
ctx
=
info
->
colRange
[
i
];
qDebug
(
"Column ID[%d] RANGE: isnull[%d],notnull[%d],range[%d]"
,
ctx
->
colId
,
ctx
->
isnull
,
ctx
->
notnull
,
ctx
->
isrange
);
if
(
ctx
->
isrange
)
{
if
(
ctx
->
isrange
)
{
SFilterRangeNode
*
r
=
ctx
->
rs
;
while
(
r
)
{
char
str
[
256
]
=
{
0
};
char
str
[
256
]
=
{
0
};
int32_t
tlen
=
0
;
if
(
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RANGE_FLG_NULL
))
{
strcat
(
str
,
"(NULL)"
);
...
...
@@ -1596,8 +1596,8 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
fltConverToStr
(
str
+
strlen
(
str
),
ctx
->
type
,
&
r
->
ra
.
e
,
tlen
>
32
?
32
:
tlen
,
&
tlen
);
FILTER_GET_FLAG
(
r
->
ra
.
eflag
,
RANGE_FLG_EXCLUDE
)
?
strcat
(
str
,
")"
)
:
strcat
(
str
,
"]"
);
}
qDebug
(
"range: %s"
,
str
);
qDebug
(
"range: %s"
,
str
);
r
=
r
->
next
;
}
}
...
...
@@ -1640,7 +1640,7 @@ void filterFreeColInfo(void *data) {
if
(
info
->
type
==
RANGE_TYPE_VAR_HASH
)
{
//TODO
}
else
if
(
info
->
type
==
RANGE_TYPE_MR_CTX
)
{
filterFreeRangeCtx
(
info
->
info
);
filterFreeRangeCtx
(
info
->
info
);
}
else
if
(
info
->
type
==
RANGE_TYPE_UNIT
)
{
taosArrayDestroy
((
SArray
*
)
info
->
info
);
}
...
...
@@ -1714,14 +1714,14 @@ void filterFreeInfo(SFilterInfo *info) {
for
(
uint32_t
f
=
0
;
f
<
info
->
fields
[
i
].
num
;
++
f
)
{
filterFreeField
(
&
info
->
fields
[
i
].
fields
[
f
],
i
);
}
taosMemoryFreeClear
(
info
->
fields
[
i
].
fields
);
}
for
(
uint32_t
i
=
0
;
i
<
info
->
groupNum
;
++
i
)
{
filterFreeGroup
(
&
info
->
groups
[
i
]);
filterFreeGroup
(
&
info
->
groups
[
i
]);
}
taosMemoryFreeClear
(
info
->
groups
);
taosMemoryFreeClear
(
info
->
units
);
...
...
@@ -1745,7 +1745,7 @@ void filterFreeInfo(SFilterInfo *info) {
int32_t
filterHandleValueExtInfo
(
SFilterUnit
*
unit
,
char
extInfo
)
{
assert
(
extInfo
>
0
||
extInfo
<
0
);
uint8_t
optr
=
FILTER_UNIT_OPTR
(
unit
);
switch
(
optr
)
{
case
OP_TYPE_GREATER_THAN
:
...
...
@@ -1774,7 +1774,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
assert
(
unit
->
compare
.
optr
==
FILTER_DUMMY_EMPTY_OPTR
||
scalarGetOperatorParamNum
(
unit
->
compare
.
optr
)
==
1
);
continue
;
}
SFilterField
*
right
=
FILTER_UNIT_RIGHT_FIELD
(
info
,
unit
);
assert
(
FILTER_GET_FLAG
(
right
->
flag
,
FLD_TYPE_VALUE
));
...
...
@@ -1782,7 +1782,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
uint32_t
type
=
FILTER_UNIT_DATA_TYPE
(
unit
);
int8_t
precision
=
FILTER_UNIT_DATA_PRECISION
(
unit
);
SFilterField
*
fi
=
right
;
SValueNode
*
var
=
(
SValueNode
*
)
fi
->
desc
;
if
(
var
==
NULL
)
{
assert
(
fi
->
data
!=
NULL
);
...
...
@@ -1797,7 +1797,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
}
FILTER_SET_FLAG
(
fi
->
flag
,
FLD_DATA_IS_HASH
);
continue
;
}
...
...
@@ -1950,11 +1950,11 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit* u, SFilterRangeCtx *c
assert
(
type
==
TSDB_DATA_TYPE_BOOL
);
if
(
GET_INT8_VAL
(
val
))
{
SIMPLE_COPY_VALUES
(
&
ra
.
s
,
&
tmp
);
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
&
tmp
);
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
&
tmp
);
}
else
{
*
(
bool
*
)
&
tmp
=
true
;
SIMPLE_COPY_VALUES
(
&
ra
.
s
,
&
tmp
);
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
&
tmp
);
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
&
tmp
);
}
break
;
case
OP_TYPE_EQUAL
:
...
...
@@ -1964,7 +1964,7 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit* u, SFilterRangeCtx *c
default:
assert
(
0
);
}
filterAddRange
(
ctx
,
&
ra
,
optr
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1978,13 +1978,13 @@ int32_t filterCompareRangeCtx(SFilterRangeCtx *ctx1, SFilterRangeCtx *ctx2, bool
SFilterRangeNode
*
r1
=
ctx1
->
rs
;
SFilterRangeNode
*
r2
=
ctx2
->
rs
;
while
(
r1
&&
r2
)
{
FLT_CHK_JMP
(
r1
->
ra
.
sflag
!=
r2
->
ra
.
sflag
);
FLT_CHK_JMP
(
r1
->
ra
.
eflag
!=
r2
->
ra
.
eflag
);
FLT_CHK_JMP
(
r1
->
ra
.
s
!=
r2
->
ra
.
s
);
FLT_CHK_JMP
(
r1
->
ra
.
e
!=
r2
->
ra
.
e
);
r1
=
r1
->
next
;
r2
=
r2
->
next
;
}
...
...
@@ -2006,7 +2006,7 @@ int32_t filterMergeUnits(SFilterInfo *info, SFilterGroupCtx* gRes, uint32_t colI
int32_t
size
=
(
int32_t
)
taosArrayGetSize
(
colArray
);
int32_t
type
=
gRes
->
colInfo
[
colIdx
].
dataType
;
SFilterRangeCtx
*
ctx
=
filterInitRangeCtx
(
type
,
0
);
for
(
uint32_t
i
=
0
;
i
<
size
;
++
i
)
{
SFilterUnit
*
u
=
taosArrayGetP
(
colArray
,
i
);
uint8_t
optr
=
FILTER_UNIT_OPTR
(
u
);
...
...
@@ -2045,7 +2045,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t
uint32_t
*
colIdx
=
taosMemoryMalloc
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
*
sizeof
(
uint32_t
));
uint32_t
colIdxi
=
0
;
uint32_t
gResIdx
=
0
;
for
(
uint32_t
i
=
0
;
i
<
info
->
groupNum
;
++
i
)
{
SFilterGroup
*
g
=
info
->
groups
+
i
;
...
...
@@ -2053,7 +2053,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t
gRes
[
gResIdx
]
->
colInfo
=
taosMemoryCalloc
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
,
sizeof
(
SFilterColInfo
));
colIdxi
=
0
;
empty
=
false
;
for
(
uint32_t
j
=
0
;
j
<
g
->
unitNum
;
++
j
)
{
SFilterUnit
*
u
=
FILTER_GROUP_UNIT
(
info
,
g
,
j
);
uint32_t
cidx
=
FILTER_UNIT_COL_IDX
(
u
);
...
...
@@ -2067,7 +2067,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t
FILTER_SET_FLAG
(
info
->
status
,
FI_STATUS_REWRITE
);
}
}
FILTER_PUSH_UNIT
(
gRes
[
gResIdx
]
->
colInfo
[
cidx
],
u
);
}
...
...
@@ -2093,10 +2093,10 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t
FILTER_SET_FLAG
(
info
->
status
,
FI_STATUS_REWRITE
);
filterFreeGroupCtx
(
gRes
[
gResIdx
]);
gRes
[
gResIdx
]
=
NULL
;
continue
;
}
gRes
[
gResIdx
]
->
colNum
=
colIdxi
;
FILTER_COPY_IDX
(
&
gRes
[
gResIdx
]
->
colIdx
,
colIdx
,
colIdxi
);
++
gResIdx
;
...
...
@@ -2105,7 +2105,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t
taosMemoryFreeClear
(
colIdx
);
*
gResNum
=
gResIdx
;
if
(
gResIdx
==
0
)
{
FILTER_SET_FLAG
(
info
->
status
,
FI_STATUS_EMPTY
);
}
...
...
@@ -2116,12 +2116,12 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t
void
filterCheckColConflict
(
SFilterGroupCtx
*
gRes1
,
SFilterGroupCtx
*
gRes2
,
bool
*
conflict
)
{
uint32_t
idx1
=
0
,
idx2
=
0
,
m
=
0
,
n
=
0
;
bool
equal
=
false
;
for
(;
m
<
gRes1
->
colNum
;
++
m
)
{
idx1
=
gRes1
->
colIdx
[
m
];
equal
=
false
;
for
(;
n
<
gRes2
->
colNum
;
++
n
)
{
idx2
=
gRes2
->
colIdx
[
n
];
if
(
idx1
<
idx2
)
{
...
...
@@ -2146,7 +2146,7 @@ void filterCheckColConflict(SFilterGroupCtx* gRes1, SFilterGroupCtx* gRes2, bool
return
;
}
}
++
n
;
equal
=
true
;
break
;
...
...
@@ -2185,7 +2185,7 @@ int32_t filterMergeTwoGroupsImpl(SFilterInfo *info, SFilterRangeCtx **ctx, int32
int32_t
filterMergeTwoGroups
(
SFilterInfo
*
info
,
SFilterGroupCtx
**
gRes1
,
SFilterGroupCtx
**
gRes2
,
bool
*
all
)
{
bool
conflict
=
false
;
filterCheckColConflict
(
*
gRes1
,
*
gRes2
,
&
conflict
);
if
(
conflict
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2203,7 +2203,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter
for
(;
m
<
(
*
gRes1
)
->
colNum
;
++
m
)
{
idx1
=
(
*
gRes1
)
->
colIdx
[
m
];
for
(;
n
<
(
*
gRes2
)
->
colNum
;
++
n
)
{
idx2
=
(
*
gRes2
)
->
colIdx
[
n
];
...
...
@@ -2212,9 +2212,9 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter
}
assert
(
idx1
==
idx2
);
++
merNum
;
filterMergeTwoGroupsImpl
(
info
,
&
ctx
,
LOGIC_COND_TYPE_OR
,
idx1
,
*
gRes1
,
*
gRes2
,
NULL
,
all
);
FLT_CHK_JMP
(
*
all
);
...
...
@@ -2231,7 +2231,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter
if
(
equal
)
{
++
equal1
;
}
filterCompareRangeCtx
(
ctx
,
(
*
gRes2
)
->
colInfo
[
idx2
].
info
,
&
equal
);
if
(
equal
)
{
++
equal2
;
...
...
@@ -2251,7 +2251,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter
FLT_CHK_JMP
(
equal1
!=
merNum
);
colCtx
.
colIdx
=
idx1
;
colCtx
.
ctx
=
ctx
;
colCtx
.
ctx
=
ctx
;
ctx
=
NULL
;
taosArrayPush
(
colCtxs
,
&
colCtx
);
}
...
...
@@ -2273,17 +2273,17 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter
int32_t
ctxSize
=
(
int32_t
)
taosArrayGetSize
(
colCtxs
);
SFilterColCtx
*
pctx
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
ctxSize
;
++
i
)
{
pctx
=
taosArrayGet
(
colCtxs
,
i
);
colInfo
=
&
(
*
gRes1
)
->
colInfo
[
pctx
->
colIdx
];
filterFreeColInfo
(
colInfo
);
FILTER_PUSH_CTX
((
*
gRes1
)
->
colInfo
[
pctx
->
colIdx
],
pctx
->
ctx
);
}
taosArrayDestroy
(
colCtxs
);
return
TSDB_CODE_SUCCESS
;
_return:
...
...
@@ -2310,7 +2310,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR
taosSort
(
gRes
,
*
gResNum
,
POINTER_BYTES
,
filterCompareGroupCtx
);
int32_t
pEnd
=
0
,
cStart
=
0
,
cEnd
=
0
;
uint32_t
pColNum
=
0
,
cColNum
=
0
;
uint32_t
pColNum
=
0
,
cColNum
=
0
;
int32_t
movedNum
=
0
;
bool
all
=
false
;
...
...
@@ -2336,7 +2336,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR
if
(
n
<
((
*
gResNum
)
-
1
))
{
memmove
(
&
gRes
[
n
],
&
gRes
[
n
+
1
],
(
*
gResNum
-
n
-
1
)
*
POINTER_BYTES
);
}
--
cEnd
;
--
(
*
gResNum
);
++
movedNum
;
...
...
@@ -2352,12 +2352,12 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR
filterMergeTwoGroups
(
info
,
&
gRes
[
m
],
&
gRes
[
n
],
&
all
);
FLT_CHK_JMP
(
all
);
if
(
gRes
[
n
]
==
NULL
)
{
if
(
n
<
((
*
gResNum
)
-
1
))
{
memmove
(
&
gRes
[
n
],
&
gRes
[
n
+
1
],
(
*
gResNum
-
n
-
1
)
*
POINTER_BYTES
);
}
--
cEnd
;
--
(
*
gResNum
);
++
movedNum
;
...
...
@@ -2374,13 +2374,13 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR
if
(
i
>=
(
*
gResNum
))
{
break
;
}
cStart
=
i
;
cColNum
=
gRes
[
i
]
->
colNum
;
cColNum
=
gRes
[
i
]
->
colNum
;
}
return
TSDB_CODE_SUCCESS
;
_return:
FILTER_SET_FLAG
(
info
->
status
,
FI_STATUS_ALL
);
...
...
@@ -2411,11 +2411,11 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum
qDebug
(
"no need rewrite"
);
return
TSDB_CODE_SUCCESS
;
}
SFilterInfo
oinfo
=
*
info
;
FILTER_SET_FLAG
(
oinfo
.
status
,
FI_STATUS_CLONED
);
SArray
*
group
=
taosArrayInit
(
FILTER_DEFAULT_GROUP_SIZE
,
sizeof
(
SFilterGroup
));
SFilterGroupCtx
*
res
=
NULL
;
SFilterColInfo
*
colInfo
=
NULL
;
...
...
@@ -2423,7 +2423,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum
uint32_t
uidx
=
0
;
memset
(
info
,
0
,
sizeof
(
*
info
));
info
->
colRangeNum
=
oinfo
.
colRangeNum
;
info
->
colRange
=
oinfo
.
colRange
;
oinfo
.
colRangeNum
=
0
;
...
...
@@ -2439,25 +2439,25 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum
optr
=
(
res
->
colNum
>
1
)
?
LOGIC_COND_TYPE_AND
:
LOGIC_COND_TYPE_OR
;
SFilterGroup
ng
=
{
0
};
for
(
uint32_t
m
=
0
;
m
<
res
->
colNum
;
++
m
)
{
colInfo
=
&
res
->
colInfo
[
res
->
colIdx
[
m
]];
if
(
FILTER_NO_MERGE_DATA_TYPE
(
colInfo
->
dataType
))
{
assert
(
colInfo
->
type
==
RANGE_TYPE_UNIT
);
int32_t
usize
=
(
int32_t
)
taosArrayGetSize
((
SArray
*
)
colInfo
->
info
);
for
(
int32_t
n
=
0
;
n
<
usize
;
++
n
)
{
SFilterUnit
*
u
=
taosArrayGetP
((
SArray
*
)
colInfo
->
info
,
n
);
filterAddUnitFromUnit
(
info
,
&
oinfo
,
u
,
&
uidx
);
filterAddUnitToGroup
(
&
ng
,
uidx
);
}
continue
;
}
assert
(
colInfo
->
type
==
RANGE_TYPE_MR_CTX
);
filterAddGroupUnitFromCtx
(
info
,
&
oinfo
,
colInfo
->
info
,
res
->
colIdx
[
m
],
&
ng
,
optr
,
group
);
}
...
...
@@ -2498,7 +2498,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_
}
assert
(
idxNum
[
i
]
==
gResNum
);
if
(
idxs
==
NULL
)
{
idxs
=
taosMemoryCalloc
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
,
sizeof
(
*
idxs
));
}
...
...
@@ -2537,7 +2537,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_
if
(
all
)
{
filterFreeRangeCtx
(
info
->
colRange
[
m
]);
info
->
colRange
[
m
]
=
NULL
;
if
(
m
<
(
info
->
colRangeNum
-
1
))
{
memmove
(
&
info
->
colRange
[
m
],
&
info
->
colRange
[
m
+
1
],
(
info
->
colRangeNum
-
m
-
1
)
*
POINTER_BYTES
);
memmove
(
&
idxs
[
m
],
&
idxs
[
m
+
1
],
(
info
->
colRangeNum
-
m
-
1
)
*
sizeof
(
*
idxs
));
...
...
@@ -2546,10 +2546,10 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_
--
info
->
colRangeNum
;
--
m
;
FLT_CHK_JMP
(
info
->
colRangeNum
<=
0
);
FLT_CHK_JMP
(
info
->
colRangeNum
<=
0
);
}
++
n
;
++
n
;
break
;
}
}
...
...
@@ -2589,7 +2589,7 @@ int32_t filterGenerateComInfo(SFilterInfo *info) {
info
->
cunits
[
i
].
optr
=
FILTER_UNIT_OPTR
(
unit
);
info
->
cunits
[
i
].
colData
=
NULL
;
info
->
cunits
[
i
].
colId
=
FILTER_UNIT_COL_ID
(
info
,
unit
);
if
(
unit
->
right
.
type
==
FLD_TYPE_VALUE
)
{
info
->
cunits
[
i
].
valData
=
FILTER_UNIT_VAL_DATA
(
info
,
unit
);
}
else
{
...
...
@@ -2600,11 +2600,11 @@ int32_t filterGenerateComInfo(SFilterInfo *info) {
}
else
{
info
->
cunits
[
i
].
valData2
=
info
->
cunits
[
i
].
valData
;
}
info
->
cunits
[
i
].
dataSize
=
FILTER_UNIT_COL_SIZE
(
info
,
unit
);
info
->
cunits
[
i
].
dataType
=
FILTER_UNIT_DATA_TYPE
(
unit
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2624,7 +2624,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
int32_t
rmUnit
=
0
;
memset
(
info
->
blkUnitRes
,
0
,
sizeof
(
*
info
->
blkUnitRes
)
*
info
->
unitNum
);
for
(
uint32_t
k
=
0
;
k
<
info
->
unitNum
;
++
k
)
{
int32_t
index
=
-
1
;
SFilterComUnit
*
cunit
=
&
info
->
cunits
[
k
];
...
...
@@ -2663,7 +2663,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
rmUnit
=
1
;
continue
;
}
info
->
blkUnitRes
[
k
]
=
-
1
;
rmUnit
=
1
;
continue
;
...
...
@@ -2684,7 +2684,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
if
(
cunit
->
dataType
==
TSDB_DATA_TYPE_FLOAT
)
{
minv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
min
));
maxv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
max
));
minVal
=
&
minv
;
maxVal
=
&
maxv
;
}
else
{
...
...
@@ -2708,7 +2708,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
if
(
minRes
&&
maxRes
)
{
continue
;
}
info
->
blkUnitRes
[
k
]
=
-
1
;
rmUnit
=
1
;
}
...
...
@@ -2727,10 +2727,10 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
info
->
blkUnitRes
[
k
]
=
-
1
;
rmUnit
=
1
;
}
continue
;
}
info
->
blkUnitRes
[
k
]
=
-
1
;
rmUnit
=
1
;
}
...
...
@@ -2744,17 +2744,17 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
}
info
->
blkGroupNum
=
info
->
groupNum
;
uint32_t
*
unitNum
=
info
->
blkUnits
;
uint32_t
*
unitIdx
=
unitNum
+
1
;
int32_t
all
=
0
,
empty
=
0
;
for
(
uint32_t
g
=
0
;
g
<
info
->
groupNum
;
++
g
)
{
SFilterGroup
*
group
=
&
info
->
groups
[
g
];
*
unitNum
=
group
->
unitNum
;
all
=
0
;
all
=
0
;
empty
=
0
;
for
(
uint32_t
u
=
0
;
u
<
group
->
unitNum
;
++
u
)
{
uint32_t
uidx
=
group
->
unitIdxs
[
u
];
if
(
info
->
blkUnitRes
[
uidx
]
==
1
)
{
...
...
@@ -2773,14 +2773,14 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
if
(
*
unitNum
==
0
)
{
--
info
->
blkGroupNum
;
assert
(
empty
||
all
);
if
(
empty
)
{
FILTER_SET_FLAG
(
info
->
blkFlag
,
FI_STATUS_BLK_EMPTY
);
}
else
{
FILTER_SET_FLAG
(
info
->
blkFlag
,
FI_STATUS_BLK_ALL
);
goto
_return
;
}
continue
;
}
...
...
@@ -2808,18 +2808,18 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
if
(
*
p
==
NULL
)
{
*
p
=
taosMemoryCalloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
//FILTER_UNIT_CLR_F(info);
unitIdx
=
info
->
blkUnits
;
for
(
uint32_t
g
=
0
;
g
<
info
->
blkGroupNum
;
++
g
)
{
uint32_t
unitNum
=
*
(
unitIdx
++
);
for
(
uint32_t
u
=
0
;
u
<
unitNum
;
++
u
)
{
SFilterComUnit
*
cunit
=
&
info
->
cunits
[
*
(
unitIdx
+
u
)];
void
*
colData
=
colDataGetData
((
SColumnInfoData
*
)
cunit
->
colData
,
i
);
//if (FILTER_UNIT_GET_F(info, uidx)) {
// p[i] = FILTER_UNIT_GET_R(info, uidx);
//} else {
...
...
@@ -2837,7 +2837,7 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
}
else
{
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
colData
,
cunit
->
valData
);
}
//FILTER_UNIT_SET_R(info, uidx, p[i]);
//FILTER_UNIT_SET_F(info, uidx);
}
...
...
@@ -2856,7 +2856,7 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
if
((
*
p
)[
i
]
==
0
)
{
all
=
false
;
}
}
}
return
all
;
...
...
@@ -2865,11 +2865,11 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
int32_t
filterExecuteBasedOnStatis
(
SFilterInfo
*
info
,
int32_t
numOfRows
,
int8_t
**
p
,
SColumnDataAgg
*
statis
,
int16_t
numOfCols
,
bool
*
all
)
{
if
(
statis
&&
numOfRows
>=
FILTER_RM_UNIT_MIN_ROWS
)
{
if
(
statis
&&
numOfRows
>=
FILTER_RM_UNIT_MIN_ROWS
)
{
info
->
blkFlag
=
0
;
filterRmUnitByRange
(
info
,
statis
,
numOfCols
,
numOfRows
);
if
(
info
->
blkFlag
)
{
if
(
FILTER_GET_FLAG
(
info
->
blkFlag
,
FI_STATUS_BLK_ALL
))
{
*
all
=
true
;
...
...
@@ -2880,7 +2880,7 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t*
}
assert
(
info
->
unitNum
>
1
);
*
all
=
filterExecuteBasedOnStatisImpl
(
info
,
numOfRows
,
p
,
statis
,
numOfCols
);
goto
_return
;
...
...
@@ -2891,7 +2891,7 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t*
_return:
info
->
blkFlag
=
0
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2913,7 +2913,7 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows,
if
(
*
p
==
NULL
)
{
*
p
=
taosMemoryCalloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
uint32_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
colDataGetData
((
SColumnInfoData
*
)
info
->
cunits
[
uidx
].
colData
,
i
);
...
...
@@ -2921,7 +2921,7 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows,
if
((
*
p
)[
i
]
==
0
)
{
all
=
false
;
}
}
}
return
all
;
...
...
@@ -2937,7 +2937,7 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows
if
(
*
p
==
NULL
)
{
*
p
=
taosMemoryCalloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
uint32_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
colDataGetData
((
SColumnInfoData
*
)
info
->
cunits
[
uidx
].
colData
,
i
);
...
...
@@ -2967,8 +2967,8 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnD
if
(
*
p
==
NULL
)
{
*
p
=
taosMemoryCalloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
void
*
colData
=
colDataGetData
((
SColumnInfoData
*
)
info
->
cunits
[
0
].
colData
,
i
);
SColumnInfoData
*
pData
=
info
->
cunits
[
0
].
colData
;
if
(
colData
==
NULL
||
colDataIsNull_s
(
pData
,
i
))
{
...
...
@@ -2977,7 +2977,7 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnD
}
(
*
p
)[
i
]
=
(
*
rfunc
)(
colData
,
colData
,
valData
,
valData2
,
func
);
if
((
*
p
)[
i
]
==
0
)
{
all
=
false
;
}
...
...
@@ -2993,11 +2993,11 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa
if
(
filterExecuteBasedOnStatis
(
info
,
numOfRows
,
p
,
statis
,
numOfCols
,
&
all
)
==
0
)
{
return
all
;
}
if
(
*
p
==
NULL
)
{
*
p
=
taosMemoryCalloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
uint32_t
uidx
=
info
->
groups
[
0
].
unitIdxs
[
0
];
void
*
colData
=
colDataGetData
((
SColumnInfoData
*
)
info
->
cunits
[
uidx
].
colData
,
i
);
...
...
@@ -3042,17 +3042,17 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg
if
(
*
p
==
NULL
)
{
*
p
=
taosMemoryCalloc
(
numOfRows
,
sizeof
(
int8_t
));
}
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
//FILTER_UNIT_CLR_F(info);
for
(
uint32_t
g
=
0
;
g
<
info
->
groupNum
;
++
g
)
{
SFilterGroup
*
group
=
&
info
->
groups
[
g
];
for
(
uint32_t
u
=
0
;
u
<
group
->
unitNum
;
++
u
)
{
uint32_t
uidx
=
group
->
unitIdxs
[
u
];
SFilterComUnit
*
cunit
=
&
info
->
cunits
[
uidx
];
void
*
colData
=
colDataGetData
((
SColumnInfoData
*
)(
cunit
->
colData
),
i
);
//if (FILTER_UNIT_GET_F(info, uidx)) {
// p[i] = FILTER_UNIT_GET_R(info, uidx);
//} else {
...
...
@@ -3082,7 +3082,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
colData
,
cunit
->
valData
);
}
}
//FILTER_UNIT_SET_R(info, uidx, p[i]);
//FILTER_UNIT_SET_F(info, uidx);
}
...
...
@@ -3099,7 +3099,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg
if
((
*
p
)[
i
]
==
0
)
{
all
=
false
;
}
}
}
return
all
;
...
...
@@ -3133,11 +3133,11 @@ int32_t filterSetExecFunc(SFilterInfo *info) {
if
(
info
->
cunits
[
0
].
rfunc
>=
0
)
{
info
->
func
=
filterExecuteImplRange
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
info
->
func
=
filterExecuteImplMisc
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -3145,7 +3145,7 @@ int32_t filterSetExecFunc(SFilterInfo *info) {
int32_t
filterPreprocess
(
SFilterInfo
*
info
)
{
SFilterGroupCtx
**
gRes
=
taosMemoryCalloc
(
info
->
groupNum
,
sizeof
(
SFilterGroupCtx
*
));
int32_t
gResNum
=
0
;
filterMergeGroupUnits
(
info
,
gRes
,
&
gResNum
);
filterMergeGroups
(
info
,
gRes
,
&
gResNum
);
...
...
@@ -3155,11 +3155,11 @@ int32_t filterPreprocess(SFilterInfo *info) {
goto
_return
;
}
if
(
FILTER_GET_FLAG
(
info
->
status
,
FI_STATUS_EMPTY
))
{
fltInfo
(
"Final - FilterInfo: [EMPTY]"
);
goto
_return
;
}
}
filterGenerateColRange
(
info
,
gRes
,
gResNum
);
...
...
@@ -3180,7 +3180,7 @@ _return:
}
taosMemoryFreeClear
(
gRes
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -3208,7 +3208,7 @@ int32_t fltSetColFieldDataImpl(SFilterInfo *info, void *param, filer_get_col_fro
int32_t
fltInitFromNode
(
SNode
*
tree
,
SFilterInfo
*
info
,
uint32_t
options
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SArray
*
group
=
taosArrayInit
(
FILTER_DEFAULT_GROUP_SIZE
,
sizeof
(
SFilterGroup
));
filterInitUnitsFields
(
info
);
...
...
@@ -3226,13 +3226,13 @@ int32_t fltInitFromNode(SNode* tree, SFilterInfo *info, uint32_t options) {
filterDumpInfoToString
(
info
,
"Before preprocess"
,
0
);
FLT_ERR_JRET
(
filterPreprocess
(
info
));
FLT_CHK_JMP
(
FILTER_GET_FLAG
(
info
->
status
,
FI_STATUS_ALL
));
if
(
FILTER_GET_FLAG
(
info
->
status
,
FI_STATUS_EMPTY
))
{
return
code
;
}
}
}
info
->
unitRes
=
taosMemoryMalloc
(
info
->
unitNum
*
sizeof
(
*
info
->
unitRes
));
info
->
unitFlags
=
taosMemoryMalloc
(
info
->
unitNum
*
sizeof
(
*
info
->
unitFlags
));
...
...
@@ -3253,10 +3253,10 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t
if
(
FILTER_ALL_RES
(
info
))
{
return
true
;
}
bool
ret
=
true
;
void
*
minVal
,
*
maxVal
;
for
(
uint32_t
k
=
0
;
k
<
info
->
colRangeNum
;
++
k
)
{
int32_t
index
=
-
1
;
SFilterRangeCtx
*
ctx
=
info
->
colRange
[
k
];
...
...
@@ -3306,7 +3306,7 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t
if
(
ctx
->
type
==
TSDB_DATA_TYPE_FLOAT
)
{
minv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
min
));
maxv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
max
));
minVal
=
&
minv
;
maxVal
=
&
maxv
;
}
else
{
...
...
@@ -3321,7 +3321,7 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t
}
r
=
r
->
next
;
}
if
(
!
ret
)
{
return
ret
;
}
...
...
@@ -3357,10 +3357,10 @@ int32_t filterGetTimeRangeImpl(SFilterInfo *info, STimeWindow *win, bool *
SFilterUnit
*
unit
=
&
info
->
units
[
uidx
];
uint8_t
raOptr
=
FILTER_UNIT_OPTR
(
unit
);
filterAddRangeOptr
(
cur
,
raOptr
,
LOGIC_COND_TYPE_AND
,
&
empty
,
NULL
);
FLT_CHK_JMP
(
empty
);
if
(
FILTER_NO_MERGE_OPTR
(
raOptr
))
{
continue
;
}
...
...
@@ -3393,10 +3393,10 @@ int32_t filterGetTimeRangeImpl(SFilterInfo *info, STimeWindow *win, bool *
*
isStrict
=
false
;
qDebug
(
"more than one time range, num:%d"
,
num
);
}
SFilterRange
tra
;
filterGetRangeRes
(
prev
,
&
tra
);
win
->
skey
=
tra
.
s
;
win
->
skey
=
tra
.
s
;
win
->
ekey
=
tra
.
e
;
if
(
FILTER_GET_FLAG
(
tra
.
sflag
,
RANGE_FLG_EXCLUDE
))
{
win
->
skey
++
;
...
...
@@ -3428,7 +3428,7 @@ _return:
int32_t
filterGetTimeRange
(
SNode
*
pNode
,
STimeWindow
*
win
,
bool
*
isStrict
)
{
SFilterInfo
*
info
=
NULL
;
int32_t
code
=
0
;
*
isStrict
=
true
;
FLT_ERR_RET
(
filterInitFromNode
(
pNode
,
&
info
,
FLT_OPTION_NO_REWRITE
|
FLT_OPTION_TIMESTAMP
));
...
...
@@ -3453,7 +3453,7 @@ int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar
if
(
FILTER_EMPTY_RES
(
info
)
||
FILTER_ALL_RES
(
info
))
{
return
TSDB_CODE_SUCCESS
;
}
for
(
uint32_t
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_COLUMN
].
num
;
++
i
)
{
SFilterField
*
fi
=
&
info
->
fields
[
FLD_TYPE_COLUMN
].
fields
[
i
];
int32_t
type
=
FILTER_GET_COL_FIELD_TYPE
(
fi
);
...
...
@@ -3485,7 +3485,7 @@ int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar
}
fi
->
data
=
nfi
.
data
;
*
gotNchar
=
true
;
}
}
...
...
@@ -3536,11 +3536,11 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
stat
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
if
((
QUERY_NODE_OPERATOR
!=
nodeType
(
cell
->
pNode
))
&&
(
QUERY_NODE_LOGIC_CONDITION
!=
nodeType
(
cell
->
pNode
)))
{
stat
->
scalarMode
=
true
;
}
cell
=
cell
->
pNext
;
}
...
...
@@ -3553,11 +3553,11 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
if
(
!
FILTER_GET_FLAG
(
stat
->
info
->
options
,
FLT_OPTION_TIMESTAMP
))
{
return
DEAL_RES_CONTINUE
;
}
if
(
TSDB_DATA_TYPE_BINARY
!=
valueNode
->
node
.
resType
.
type
&&
TSDB_DATA_TYPE_NCHAR
!=
valueNode
->
node
.
resType
.
type
)
{
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -3568,7 +3568,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
stat
->
code
=
code
;
return
DEAL_RES_ERROR
;
}
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -3586,7 +3586,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
stat
->
precision
=
colNode
->
node
.
resType
.
precision
;
return
DEAL_RES_CONTINUE
;
}
if
(
QUERY_NODE_NODE_LIST
==
nodeType
(
*
pNode
))
{
SNodeListNode
*
listNode
=
(
SNodeListNode
*
)
*
pNode
;
if
(
QUERY_NODE_VALUE
!=
nodeType
(
listNode
->
pNodeList
->
pHead
->
pNode
))
{
...
...
@@ -3624,7 +3624,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
if
(
FILTER_GET_FLAG
(
stat
->
info
->
options
,
FLT_OPTION_TIMESTAMP
)
&&
if
(
FILTER_GET_FLAG
(
stat
->
info
->
options
,
FLT_OPTION_TIMESTAMP
)
&&
(
node
->
opType
>=
OP_TYPE_NOT_EQUAL
)
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
...
...
@@ -3636,7 +3636,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
stat
->
code
=
TSDB_CODE_QRY_APP_ERROR
;
return
DEAL_RES_ERROR
;
}
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
node
->
pLeft
))
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
...
...
@@ -3656,7 +3656,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
if
((
QUERY_NODE_COLUMN
!=
nodeType
(
node
->
pRight
))
&&
(
QUERY_NODE_VALUE
!=
nodeType
(
node
->
pRight
))
&&
(
QUERY_NODE_NODE_LIST
!=
nodeType
(
node
->
pRight
)))
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
}
if
(
nodeType
(
node
->
pLeft
)
==
nodeType
(
node
->
pRight
))
{
stat
->
scalarMode
=
true
;
...
...
@@ -3699,7 +3699,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
if
(
OP_TYPE_IN
!=
node
->
opType
)
{
SColumnNode
*
refNode
=
(
SColumnNode
*
)
node
->
pLeft
;
SValueNode
*
valueNode
=
(
SValueNode
*
)
node
->
pRight
;
if
(
FILTER_GET_FLAG
(
stat
->
info
->
options
,
FLT_OPTION_TIMESTAMP
)
if
(
FILTER_GET_FLAG
(
stat
->
info
->
options
,
FLT_OPTION_TIMESTAMP
)
&&
TSDB_DATA_TYPE_UBIGINT
==
valueNode
->
node
.
resType
.
type
&&
valueNode
->
datum
.
u
<=
INT64_MAX
)
{
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BIGINT
;
}
...
...
@@ -3720,12 +3720,12 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
}
return
DEAL_RES_CONTINUE
;
}
}
fltError
(
"invalid node type for filter, type:%d"
,
nodeType
(
*
pNode
));
stat
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
...
...
@@ -3738,7 +3738,7 @@ int32_t fltReviseNodes(SFilterInfo *pInfo, SNode** pNode, SFltTreeStat *pStat) {
int32_t
nodeNum
=
taosArrayGetSize
(
pStat
->
nodeList
);
for
(
int32_t
i
=
0
;
i
<
nodeNum
;
++
i
)
{
SValueNode
*
valueNode
=
*
(
SValueNode
**
)
taosArrayGet
(
pStat
->
nodeList
,
i
);
FLT_ERR_JRET
(
sclConvertToTsValueNode
(
pStat
->
precision
,
valueNode
));
}
...
...
@@ -3757,7 +3757,7 @@ int32_t fltOptimizeNodes(SFilterInfo *pInfo, SNode** pNode, SFltTreeStat *pStat)
int32_t
fltGetDataFromColId
(
void
*
param
,
int32_t
id
,
void
**
data
)
{
int32_t
numOfCols
=
((
SFilterColumnParam
*
)
param
)
->
numOfCols
;
SArray
*
pDataBlock
=
((
SFilterColumnParam
*
)
param
)
->
pDataBlock
;
for
(
int32_t
j
=
0
;
j
<
numOfCols
;
++
j
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pDataBlock
,
j
);
if
(
id
==
pColInfo
->
info
.
colId
)
{
...
...
@@ -3776,7 +3776,7 @@ int32_t fltGetDataFromSlotId(void *param, int32_t id, void **data) {
fltError
(
"invalid slot id, id:%d, numOfCols:%d, arraySize:%d"
,
id
,
numOfCols
,
(
int32_t
)
taosArrayGetSize
(
pDataBlock
));
return
TSDB_CODE_QRY_APP_ERROR
;
}
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pDataBlock
,
id
);
*
data
=
pColInfo
;
...
...
@@ -3802,7 +3802,7 @@ int32_t filterSetDataFromColId(SFilterInfo *info, void *param) {
int32_t
filterInitFromNode
(
SNode
*
pNode
,
SFilterInfo
**
pInfo
,
uint32_t
options
)
{
int32_t
code
=
0
;
SFilterInfo
*
info
=
NULL
;
if
(
pNode
==
NULL
||
pInfo
==
NULL
)
{
fltError
(
"invalid param"
);
FLT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
...
...
@@ -3822,7 +3822,7 @@ int32_t filterInitFromNode(SNode* pNode, SFilterInfo **pInfo, uint32_t options)
SFltTreeStat
stat
=
{
0
};
stat
.
precision
=
-
1
;
stat
.
info
=
info
;
FLT_ERR_JRET
(
fltReviseNodes
(
info
,
&
pNode
,
&
stat
));
info
->
scalarMode
=
stat
.
scalarMode
;
...
...
@@ -3834,11 +3834,11 @@ int32_t filterInitFromNode(SNode* pNode, SFilterInfo **pInfo, uint32_t options)
info
->
sclCtx
.
node
=
pNode
;
FLT_ERR_JRET
(
fltOptimizeNodes
(
info
,
&
info
->
sclCtx
.
node
,
&
stat
));
}
return
code
;
_return:
filterFreeInfo
(
*
pInfo
);
*
pInfo
=
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录