Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fc1fe39e
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fc1fe39e
编写于
10月 12, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-6129<feature> optimize json filter logic
上级
4972b0f4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
7 addition
and
49 deletion
+7
-49
src/query/src/qFilter.c
src/query/src/qFilter.c
+7
-49
未找到文件。
src/query/src/qFilter.c
浏览文件 @
fc1fe39e
...
...
@@ -44,12 +44,7 @@ static FORCE_INLINE int32_t filterFieldColDescCompare(const void *desc1, const v
const
SSchema
*
sch1
=
desc1
;
const
SSchema
*
sch2
=
desc2
;
if
(
IS_JSON_DATA_TYPE
(
sch1
->
type
)
&&
IS_JSON_DATA_TYPE
(
sch2
->
type
)){
return
!
(
strcmp
(
sch1
->
name
,
sch2
->
name
)
==
0
&&
sch1
->
colId
==
sch2
->
colId
);
}
else
{
return
sch1
->
colId
!=
sch2
->
colId
;
}
return
!
(
strcmp
(
sch1
->
name
,
sch2
->
name
)
==
0
&&
sch1
->
colId
==
sch2
->
colId
);
}
static
FORCE_INLINE
int32_t
filterFieldValDescCompare
(
const
void
*
desc1
,
const
void
*
desc2
)
{
...
...
@@ -1161,7 +1156,6 @@ _return:
int32_t
filterAddGroupUnitFromNode
(
SFilterInfo
*
info
,
tExprNode
*
tree
,
SArray
*
group
)
{
int32_t
type
=
-
1
;
tExprNode
*
pLeft
=
tree
->
_node
.
pLeft
;
if
(
pLeft
->
nodeType
==
TSQL_NODE_EXPR
&&
pLeft
->
_node
.
optr
==
TSDB_RELATION_ARROW
){
// json tag -> operation
assert
(
info
->
pTable
!=
NULL
);
...
...
@@ -1172,8 +1166,11 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
void
*
data
=
getJsonTagValue
(
info
->
pTable
,
schema
->
name
,
strlen
(
schema
->
name
),
schema
->
type
,
&
schema
->
colId
);
if
(
data
==
NULL
)
return
TSDB_CODE_QRY_JSON_KEY_NOT_EXIST
;
type
=
*
(
char
*
)
data
;
// if exist json tag-> operation get type so that can set data if (tree->_node.optr == TSDB_RELATION_IN_IN) the next
assert
(
type
>
TSDB_DATA_TYPE_NULL
&&
type
<
TSDB_DATA_TYPE_JSON_BINARY
);
schema
->
type
=
*
(
char
*
)
data
;
// if exist json tag-> operation get type so that can set data if (tree->_node.optr == TSDB_RELATION_IN_IN) the next and set value in filterInitValFieldData
assert
(
schema
->
type
>
TSDB_DATA_TYPE_NULL
&&
schema
->
type
<
TSDB_DATA_TYPE_JSON_BINARY
);
if
((
tree
->
_node
.
optr
==
TSDB_RELATION_MATCH
||
tree
->
_node
.
optr
==
TSDB_RELATION_NMATCH
)
&&
schema
->
type
!=
TSDB_DATA_TYPE_BINARY
)
return
TSDB_CODE_QRY_JSON_KEY_NOT_STR_ERROR
;
pLeft
=
pLeft
->
_node
.
pLeft
;
// -> operation use left as input
}
else
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_QUESTION
){
...
...
@@ -1186,7 +1183,7 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
SFilterFieldId
left
=
{
0
},
right
=
{
0
};
filterAddFieldFromNode
(
info
,
pLeft
,
&
left
);
tVariant
*
var
=
tree
->
_node
.
pRight
->
pVal
;
if
(
type
==
-
1
)
type
=
FILTER_GET_COL_FIELD_TYPE
(
FILTER_GET_FIELD
(
info
,
left
));
uint8_t
type
=
FILTER_GET_COL_FIELD_TYPE
(
FILTER_GET_FIELD
(
info
,
left
));
int32_t
len
=
0
;
uint16_t
uidx
=
0
;
...
...
@@ -3187,40 +3184,6 @@ int32_t filterSetJsonColFieldData(SFilterInfo *info, void *param, filer_get_col_
return
TSDB_CODE_SUCCESS
;
}
// convert json type for next compare and so on
int
filterJsonTypeConvert
(
SFilterInfo
*
info
)
{
for
(
int
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_COLUMN
].
num
;
i
++
)
{
SSchema
*
schema
=
info
->
fields
[
FLD_TYPE_COLUMN
].
fields
[
i
].
desc
;
if
(
IS_JSON_DATA_TYPE
(
schema
->
type
)){
if
(
schema
->
colId
!=
0
){
// schema->colId != 0 means not ? operation
void
*
data
=
getJsonTagValue
(
info
->
pTable
,
schema
->
name
,
strlen
(
schema
->
name
),
schema
->
type
,
NULL
);
if
(
data
==
NULL
)
return
TSDB_CODE_QRY_JSON_KEY_NOT_EXIST
;
int8_t
type
=
*
(
char
*
)
data
;
assert
(
type
>
TSDB_DATA_TYPE_NULL
&&
type
<
TSDB_DATA_TYPE_JSON_BINARY
);
schema
->
type
=
type
;
}
else
{
schema
->
type
=
TSDB_DATA_TYPE_BINARY
;
}
}
}
for
(
int
i
=
0
;
i
<
info
->
unitNum
;
i
++
){
if
(
IS_JSON_DATA_TYPE
(
info
->
units
[
i
].
compare
.
type
)){
SFilterField
*
colLeft
=
FILTER_UNIT_LEFT_FIELD
(
info
,
&
info
->
units
[
i
]);
info
->
units
[
i
].
compare
.
type
=
FILTER_GET_COL_FIELD_TYPE
(
colLeft
);
if
((
info
->
units
[
i
].
compare
.
optr
==
TSDB_RELATION_MATCH
||
info
->
units
[
i
].
compare
.
optr
==
TSDB_RELATION_NMATCH
)
&&
info
->
units
[
i
].
compare
.
type
!=
TSDB_DATA_TYPE_BINARY
)
return
TSDB_CODE_QRY_JSON_KEY_NOT_STR_ERROR
;
// SFilterField *colRight = FILTER_UNIT_RIGHT_FIELD(info, &info->units[i]);
// tVariant* var = colRight->desc;
// if(!tVariantTypeMatch(var, info->units[i].compare.type))
// return TSDB_CODE_QRY_JSON_KEY_TYPE_ERROR;
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
filterInitFromTree
(
tExprNode
*
tree
,
void
**
pinfo
,
uint32_t
options
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SFilterInfo
*
info
=
NULL
;
...
...
@@ -3242,11 +3205,6 @@ int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options) {
code
=
filterTreeToGroup
(
tree
,
info
,
group
);
ERR_JRET
(
code
);
if
(
info
->
pTable
){
//code = filterJsonTypeConvert(info); // convert json type to other type to prepare for th next defination of compare function
ERR_JRET
(
code
);
}
filterConvertGroupFromArray
(
info
,
group
);
ERR_JRET
(
filterInitValFieldData
(
info
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录