Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
adminstrot
TDengine
提交
03063121
TDengine
项目概览
adminstrot
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
03063121
编写于
8月 11, 2021
作者:
W
wpan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improve performance
上级
7b67e43c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
174 addition
and
6 deletion
+174
-6
src/query/inc/qFilter.h
src/query/inc/qFilter.h
+14
-1
src/query/src/qFilter.c
src/query/src/qFilter.c
+160
-5
未找到文件。
src/query/inc/qFilter.h
浏览文件 @
03063121
...
...
@@ -35,6 +35,8 @@ extern "C" {
#define MAX_NUM_STR_SIZE 40
#define FILTER_RM_UNIT_MIN_ROWS 1024
enum
{
FLD_TYPE_COLUMN
=
1
,
FLD_TYPE_VALUE
=
2
,
...
...
@@ -70,6 +72,12 @@ enum {
FI_STATUS_CLONED
=
8
,
};
enum
{
FI_STATUS_BLK_ALL
=
1
,
FI_STATUS_BLK_EMPTY
=
2
,
FI_STATUS_BLK_ACTIVE
=
4
,
};
enum
{
RANGE_TYPE_UNIT
=
1
,
RANGE_TYPE_VAR_HASH
=
2
,
...
...
@@ -197,6 +205,7 @@ typedef struct SFilterComUnit {
void
*
colData
;
void
*
valData
;
void
*
valData2
;
uint16_t
colId
;
uint16_t
dataSize
;
uint8_t
dataType
;
uint8_t
optr
;
...
...
@@ -224,7 +233,11 @@ typedef struct SFilterInfo {
uint8_t
*
unitRes
;
// result
uint8_t
*
unitFlags
;
// got result
SFilterRangeCtx
**
colRange
;
filter_exec_func
func
;
filter_exec_func
func
;
uint8_t
blkFlag
;
uint16_t
blkGroupNum
;
uint16_t
*
blkUnits
;
int8_t
*
blkUnitRes
;
SFilterPCtx
pctx
;
}
SFilterInfo
;
...
...
src/query/src/qFilter.c
浏览文件 @
03063121
...
...
@@ -157,7 +157,7 @@ __compar_fn_t gDataCompare[] = {compareInt32Val, compareInt8Val, compareInt16Val
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
;
...
...
@@ -2540,6 +2540,153 @@ int32_t filterUpdateComUnits(SFilterInfo *info) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
filterRmUnitByRange
(
SFilterInfo
*
info
,
SDataStatis
*
pDataStatis
,
int32_t
numOfCols
,
int32_t
numOfRows
)
{
int32_t
rmUnit
=
0
;
memset
(
info
->
blkUnitRes
,
0
,
sizeof
(
*
info
->
blkUnitRes
)
*
info
->
unitNum
);
for
(
int32_t
k
=
0
;
k
<
info
->
unitNum
;
++
k
)
{
int32_t
index
=
-
1
;
SFilterComUnit
*
cunit
=
&
info
->
cunits
[
k
];
if
(
FILTER_NO_MERGE_DATA_TYPE
(
cunit
->
dataType
))
{
continue
;
}
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
if
(
pDataStatis
[
i
].
colId
==
cunit
->
colId
)
{
index
=
i
;
break
;
}
}
if
(
index
==
-
1
)
{
continue
;
}
if
(
pDataStatis
[
index
].
numOfNull
<=
0
)
{
if
(
cunit
->
optr
==
TSDB_RELATION_ISNULL
)
{
info
->
blkUnitRes
[
k
]
=
-
1
;
rmUnit
=
1
;
continue
;
}
if
(
cunit
->
optr
==
TSDB_RELATION_NOTNULL
)
{
info
->
blkUnitRes
[
k
]
=
1
;
rmUnit
=
1
;
continue
;
}
}
else
{
if
(
pDataStatis
[
index
].
numOfNull
==
numOfRows
)
{
if
(
cunit
->
optr
==
TSDB_RELATION_ISNULL
)
{
info
->
blkUnitRes
[
k
]
=
1
;
rmUnit
=
1
;
continue
;
}
info
->
blkUnitRes
[
k
]
=
-
1
;
rmUnit
=
1
;
continue
;
}
}
if
(
cunit
->
optr
==
TSDB_RELATION_ISNULL
||
cunit
->
optr
==
TSDB_RELATION_NOTNULL
)
{
continue
;
}
SDataStatis
*
pDataBlockst
=
&
pDataStatis
[
index
];
void
*
minVal
,
*
maxVal
;
if
(
cunit
->
dataType
==
TSDB_DATA_TYPE_FLOAT
)
{
float
minv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
min
));
float
maxv
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
max
));
minVal
=
&
minv
;
maxVal
=
&
maxv
;
}
else
{
minVal
=
&
pDataBlockst
->
min
;
maxVal
=
&
pDataBlockst
->
max
;
}
bool
minRes
=
false
,
maxRes
=
false
;
if
(
cunit
->
rfunc
>=
0
)
{
minRes
=
(
*
gRangeCompare
[
cunit
->
rfunc
])(
minVal
,
minVal
,
cunit
->
valData
,
cunit
->
valData2
,
gDataCompare
[
cunit
->
func
]);
maxRes
=
(
*
gRangeCompare
[
cunit
->
rfunc
])(
maxVal
,
maxVal
,
cunit
->
valData
,
cunit
->
valData2
,
gDataCompare
[
cunit
->
func
]);
}
else
{
minRes
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
minVal
,
cunit
->
valData
);
maxRes
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
maxVal
,
cunit
->
valData
);
}
if
(
minRes
&&
maxRes
)
{
info
->
blkUnitRes
[
k
]
=
1
;
rmUnit
=
1
;
}
else
if
((
!
minRes
)
&&
(
!
maxRes
))
{
info
->
blkUnitRes
[
k
]
=
-
1
;
rmUnit
=
1
;
}
}
CHK_RET
(
rmUnit
==
0
,
TSDB_CODE_SUCCESS
);
info
->
blkGroupNum
=
info
->
groupNum
;
uint16_t
*
unitNum
=
info
->
blkUnits
;
uint16_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
;
empty
=
0
;
for
(
uint32_t
u
=
0
;
u
<
group
->
unitNum
;
++
u
)
{
uint16_t
uidx
=
group
->
unitIdxs
[
u
];
if
(
info
->
blkUnitRes
[
u
]
==
1
)
{
--
(
*
unitNum
);
all
=
1
;
continue
;
}
else
if
(
info
->
blkUnitRes
[
u
]
==
-
1
)
{
*
unitNum
=
0
;
empty
=
1
;
break
;
}
*
(
unitIdx
++
)
=
uidx
;
}
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
;
}
unitNum
=
unitIdx
;
++
unitIdx
;
}
if
(
info
->
blkGroupNum
)
{
FILTER_CLR_FLAG
(
info
->
blkFlag
,
FI_STATUS_BLK_EMPTY
);
FILTER_SET_FLAG
(
info
->
blkFlag
,
FI_STATUS_BLK_ACTIVE
);
}
_return:
qDebug
(
"Block Filter Result:%s"
,
FILTER_GET_FLAG
(
info
->
blkFlag
,
FI_STATUS_BLK_EMPTY
)
?
"EMPTY"
:
(
FILTER_GET_FLAG
(
info
->
blkFlag
,
FI_STATUS_BLK_ALL
)
?
"ALL"
:
"FILTER"
));
return
TSDB_CODE_SUCCESS
;
}
static
FORCE_INLINE
bool
filterExecuteImplAll
(
void
*
info
,
int32_t
numOfRows
,
int8_t
*
p
)
{
return
true
;
...
...
@@ -2880,16 +3027,17 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num
// no statistics data, load the true data block
if
(
index
==
-
1
)
{
return
true
;
break
;
}
// not support pre-filter operation on binary/nchar data type
if
(
FILTER_NO_MERGE_DATA_TYPE
(
ctx
->
type
))
{
return
true
;
break
;
}
if
((
pDataStatis
[
index
].
numOfNull
<=
0
)
&&
(
ctx
->
isnull
&&
!
ctx
->
notnull
&&
!
ctx
->
isrange
))
{
return
false
;
ret
=
false
;
break
;
}
// all data in current column are NULL, no need to check its boundary value
...
...
@@ -2897,7 +3045,8 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num
// if isNULL query exists, load the null data column
if
((
ctx
->
notnull
||
ctx
->
isrange
)
&&
(
!
ctx
->
isnull
))
{
return
false
;
ret
=
false
;
break
;
}
continue
;
...
...
@@ -2929,6 +3078,12 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num
CHK_RET
(
!
ret
,
ret
);
}
info
->
blkFlag
=
0
;
if
(
ret
&&
numOfRows
>=
FILTER_RM_UNIT_MIN_ROWS
)
{
filterRmUnitByRange
(
info
,
pDataStatis
,
numOfCols
,
numOfRows
);
}
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录