Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c00ff3ff
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看板
提交
c00ff3ff
编写于
8月 05, 2021
作者:
W
wpan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improve performance
上级
d86f582a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
143 addition
and
28 deletion
+143
-28
src/query/inc/qFilter.h
src/query/inc/qFilter.h
+5
-5
src/query/src/qFilter.c
src/query/src/qFilter.c
+103
-20
src/util/inc/tcompare.h
src/util/inc/tcompare.h
+32
-0
src/util/src/tcompare.c
src/util/src/tcompare.c
+3
-3
未找到文件。
src/query/inc/qFilter.h
浏览文件 @
c00ff3ff
...
...
@@ -181,7 +181,7 @@ typedef struct SFilterColCtx {
}
SFilterColCtx
;
typedef
struct
SFilterCompare
{
int32
_t
type
;
uint8
_t
type
;
uint8_t
optr
;
uint8_t
optr2
;
}
SFilterCompare
;
...
...
@@ -194,14 +194,14 @@ typedef struct SFilterUnit {
}
SFilterUnit
;
typedef
struct
SFilterComUnit
{
__compar_fn_t
func
;
rangeCompFunc
rfunc
;
void
*
colData
;
void
*
valData
;
void
*
valData2
;
int32_t
dataType
;
uint16_t
dataSize
;
uint16_t
optr
;
uint8_t
dataType
;
uint8_t
optr
;
int8_t
func
;
int8_t
rfunc
;
}
SFilterComUnit
;
typedef
struct
SFilterPCtx
{
...
...
src/query/src/qFilter.c
浏览文件 @
c00ff3ff
...
...
@@ -114,41 +114,123 @@ rangeCompFunc filterGetRangeCompFunc(char sflag, char eflag) {
return
filterRangeCompii
;
}
rangeCompFunc
filterGetRangeCompFuncFromOptrs
(
uint8_t
optr
,
uint8_t
optr2
)
{
rangeCompFunc
gRangeCompare
[]
=
{
filterRangeCompee
,
filterRangeCompei
,
filterRangeCompie
,
filterRangeCompii
,
filterRangeCompGe
,
filterRangeCompGi
,
filterRangeCompLe
,
filterRangeCompLi
};
int8_t
filterGetRangeCompFuncFromOptrs
(
uint8_t
optr
,
uint8_t
optr2
)
{
if
(
optr2
)
{
assert
(
optr2
==
TSDB_RELATION_LESS
||
optr2
==
TSDB_RELATION_LESS_EQUAL
);
if
(
optr
==
TSDB_RELATION_GREATER
)
{
if
(
optr2
==
TSDB_RELATION_LESS
)
{
return
filterRangeCompee
;
return
0
;
}
return
filterRangeCompei
;
return
1
;
}
if
(
optr2
==
TSDB_RELATION_LESS
)
{
return
filterRangeCompie
;
return
2
;
}
return
filterRangeCompii
;
return
3
;
}
else
{
switch
(
optr
)
{
case
TSDB_RELATION_GREATER
:
return
filterRangeCompGe
;
return
4
;
case
TSDB_RELATION_GREATER_EQUAL
:
return
filterRangeCompGi
;
return
5
;
case
TSDB_RELATION_LESS
:
return
filterRangeCompLe
;
return
6
;
case
TSDB_RELATION_LESS_EQUAL
:
return
filterRangeCompLi
;
return
7
;
default:
break
;
}
}
return
NULL
;
return
-
1
;
}
__compar_fn_t
gDataCompare
[]
=
{
compareInt32Val
,
compareInt8Val
,
compareInt16Val
,
compareInt64Val
,
compareFloatVal
,
compareDoubleVal
,
compareLenPrefixedStr
,
compareStrPatternComp
,
compareFindItemInSet
,
compareWStrPatternComp
,
compareLenPrefixedWStr
,
compareUint8Val
,
compareUint16Val
,
compareUint32Val
,
compareUint64Val
,
setCompareBytes1
,
setCompareBytes2
,
setCompareBytes4
,
setCompareBytes8
};
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
))
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
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
:
return
17
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
18
;
default:
assert
(
0
);
}
}
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
comparFn
=
1
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
comparFn
=
2
;
break
;
case
TSDB_DATA_TYPE_INT
:
comparFn
=
0
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
comparFn
=
3
;
break
;
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_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
7
;
}
else
if
(
optr
==
TSDB_RELATION_IN
)
{
comparFn
=
8
;
}
else
{
/* normal relational comparFn */
comparFn
=
6
;
}
break
;
}
case
TSDB_DATA_TYPE_NCHAR
:
{
if
(
optr
==
TSDB_RELATION_LIKE
)
{
comparFn
=
9
;
}
else
if
(
optr
==
TSDB_RELATION_IN
)
{
comparFn
=
8
;
}
else
{
comparFn
=
10
;
}
break
;
}
case
TSDB_DATA_TYPE_UTINYINT
:
comparFn
=
11
;
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
comparFn
=
12
;
break
;
case
TSDB_DATA_TYPE_UINT
:
comparFn
=
13
;
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
comparFn
=
14
;
break
;
default:
comparFn
=
0
;
break
;
}
return
comparFn
;
}
static
FORCE_INLINE
int32_t
filterCompareGroupCtx
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
SFilterGroupCtx
*
left
=
*
((
SFilterGroupCtx
**
)
pLeft
),
*
right
=
*
((
SFilterGroupCtx
**
)
pRight
);
if
(
left
->
colNum
>
right
->
colNum
)
return
1
;
...
...
@@ -1392,6 +1474,7 @@ _return:
return
code
;
}
#if 0
int32_t filterInitUnitFunc(SFilterInfo *info) {
for (uint16_t i = 0; i < info->unitNum; ++i) {
SFilterUnit* unit = &info->units[i];
...
...
@@ -1401,7 +1484,7 @@ int32_t filterInitUnitFunc(SFilterInfo *info) {
return TSDB_CODE_SUCCESS;
}
#endif
void
filterDumpInfoToString
(
SFilterInfo
*
info
,
const
char
*
msg
,
int32_t
options
)
{
...
...
@@ -2406,7 +2489,7 @@ int32_t filterGenerateComInfo(SFilterInfo *info) {
for
(
uint16_t
i
=
0
;
i
<
info
->
unitNum
;
++
i
)
{
SFilterUnit
*
unit
=
&
info
->
units
[
i
];
info
->
cunits
[
i
].
func
=
getComparFunc
(
FILTER_UNIT_DATA_TYPE
(
unit
),
unit
->
compare
.
optr
);
info
->
cunits
[
i
].
func
=
filterGetCompFuncIdx
(
FILTER_UNIT_DATA_TYPE
(
unit
),
unit
->
compare
.
optr
);
info
->
cunits
[
i
].
rfunc
=
filterGetRangeCompFuncFromOptrs
(
unit
->
compare
.
optr
,
unit
->
compare
.
optr2
);
info
->
cunits
[
i
].
optr
=
FILTER_UNIT_OPTR
(
unit
);
info
->
cunits
[
i
].
colData
=
NULL
;
...
...
@@ -2500,10 +2583,10 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t* p) {
bool
all
=
true
;
uint16_t
dataSize
=
info
->
cunits
[
0
].
dataSize
;
char
*
colData
=
(
char
*
)
info
->
cunits
[
0
].
colData
;
rangeCompFunc
rfunc
=
info
->
cunits
[
0
].
rfunc
;
rangeCompFunc
rfunc
=
gRangeCompare
[
info
->
cunits
[
0
].
rfunc
]
;
void
*
valData
=
info
->
cunits
[
0
].
valData
;
void
*
valData2
=
info
->
cunits
[
0
].
valData2
;
__compar_fn_t
func
=
info
->
cunits
[
0
].
func
;
__compar_fn_t
func
=
gDataCompare
[
info
->
cunits
[
0
].
func
]
;
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
if
(
isNull
(
colData
,
info
->
cunits
[
0
].
dataType
))
{
...
...
@@ -2536,7 +2619,7 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t* p) {
continue
;
}
p
[
i
]
=
filterDoCompare
(
info
->
cunits
[
uidx
].
func
,
info
->
cunits
[
uidx
].
optr
,
colData
,
info
->
cunits
[
uidx
].
valData
);
p
[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
]
,
info
->
cunits
[
uidx
].
optr
,
colData
,
info
->
cunits
[
uidx
].
valData
);
if
(
p
[
i
]
==
0
)
{
all
=
false
;
...
...
@@ -2573,10 +2656,10 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t* p) {
p
[
i
]
=
1
;
}
else
if
(
optr
==
TSDB_RELATION_ISNULL
)
{
p
[
i
]
=
0
;
}
else
if
(
cunit
->
rfunc
)
{
p
[
i
]
=
(
*
cunit
->
rfunc
)(
colData
,
colData
,
cunit
->
valData
,
cunit
->
valData2
,
cunit
->
func
);
}
else
if
(
cunit
->
rfunc
>=
0
)
{
p
[
i
]
=
(
*
gRangeCompare
[
cunit
->
rfunc
])(
colData
,
colData
,
cunit
->
valData
,
cunit
->
valData2
,
gDataCompare
[
cunit
->
func
]
);
}
else
{
p
[
i
]
=
filterDoCompare
(
cunit
->
func
,
cunit
->
optr
,
colData
,
cunit
->
valData
);
p
[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
]
,
cunit
->
optr
,
colData
,
cunit
->
valData
);
}
//FILTER_UNIT_SET_R(info, uidx, p[i]);
...
...
@@ -2631,7 +2714,7 @@ int32_t filterSetExecFunc(SFilterInfo *info) {
return
TSDB_CODE_SUCCESS
;
}
if
(
info
->
cunits
[
0
].
rfunc
)
{
if
(
info
->
cunits
[
0
].
rfunc
>=
0
)
{
info
->
func
=
filterExecuteImplRange
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2746,7 +2829,7 @@ int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t option
return
code
;
}
ERR_JRET
(
filterInitUnitFunc
(
info
));
//
ERR_JRET(filterInitUnitFunc(info));
}
info
->
unitRes
=
malloc
(
info
->
unitNum
*
sizeof
(
*
info
->
unitRes
));
...
...
src/util/inc/tcompare.h
浏览文件 @
c00ff3ff
...
...
@@ -53,6 +53,38 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr);
int32_t
taosArrayCompareString
(
const
void
*
a
,
const
void
*
b
);
int32_t
setCompareBytes1
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
setCompareBytes2
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
setCompareBytes4
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
setCompareBytes8
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareInt32Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareInt64Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareInt16Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareInt8Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareUint32Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareUint64Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareUint16Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareUint8Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareFloatVal
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareDoubleVal
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareLenPrefixedStr
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareLenPrefixedWStr
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareStrPatternComp
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareFindItemInSet
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareWStrPatternComp
(
const
void
*
pLeft
,
const
void
*
pRight
);
#ifdef __cplusplus
}
#endif
...
...
src/util/src/tcompare.c
浏览文件 @
c00ff3ff
...
...
@@ -278,7 +278,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
return
(
str
[
j
]
==
0
||
j
>=
size
)
?
TSDB_PATTERN_MATCH
:
TSDB_PATTERN_NOMATCH
;
}
static
int32_t
compareStrPatternComp
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
int32_t
compareStrPatternComp
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
SPatternCompareInfo
pInfo
=
{
'%'
,
'_'
};
char
pattern
[
128
]
=
{
0
};
...
...
@@ -306,11 +306,11 @@ int32_t taosArrayCompareString(const void* a, const void* b) {
// const SArray* arr = (const SArray*) pRight;
// return taosArraySearchString(arr, pLeft, taosArrayCompareString, TD_EQ) == NULL ? 0 : 1;
//}
static
int32_t
compareFindItemInSet
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
int32_t
compareFindItemInSet
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
return
NULL
!=
taosHashGet
((
SHashObj
*
)
pRight
,
varDataVal
(
pLeft
),
varDataLen
(
pLeft
))
?
1
:
0
;
}
static
int32_t
compareWStrPatternComp
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
int32_t
compareWStrPatternComp
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
SPatternCompareInfo
pInfo
=
{
'%'
,
'_'
};
wchar_t
pattern
[
128
]
=
{
0
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录