Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
f80fb09b
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f80fb09b
编写于
3月 31, 2019
作者:
D
Danila Kutenin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Hyperscan better usage of scratch space and error handling
上级
11997ed7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
7 deletion
+29
-7
dbms/src/Common/ErrorCodes.cpp
dbms/src/Common/ErrorCodes.cpp
+1
-0
dbms/src/Functions/FunctionsStringRegex.cpp
dbms/src/Functions/FunctionsStringRegex.cpp
+7
-4
dbms/src/Functions/Regexps.h
dbms/src/Functions/Regexps.h
+21
-3
未找到文件。
dbms/src/Common/ErrorCodes.cpp
浏览文件 @
f80fb09b
...
...
@@ -421,6 +421,7 @@ namespace ErrorCodes
extern
const
int
UNKNOWN_PROTOBUF_FORMAT
=
444
;
extern
const
int
CANNOT_MPROTECT
=
445
;
extern
const
int
FUNCTION_NOT_ALLOWED
=
446
;
extern
const
int
HYPERSCAN_CANNOT_SCAN_TEXT
=
447
;
extern
const
int
KEEPER_EXCEPTION
=
999
;
extern
const
int
POCO_EXCEPTION
=
1000
;
...
...
dbms/src/Functions/FunctionsStringRegex.cpp
浏览文件 @
f80fb09b
...
...
@@ -40,6 +40,7 @@ namespace ErrorCodes
extern
const
int
ILLEGAL_COLUMN
;
extern
const
int
TOO_MANY_BYTES
;
extern
const
int
NOT_IMPLEMENTED
;
extern
const
int
HYPERSCAN_CANNOT_SCAN_TEXT
;
}
/// Is the LIKE expression reduced to finding a substring in a string?
...
...
@@ -289,10 +290,10 @@ struct MultiMatchAnyImpl
#if USE_HYPERSCAN
const
auto
&
hyperscan_regex
=
MultiRegexps
::
get
<
FindAnyIndex
,
MultiSearchDistance
>
(
needles
,
edit_distance
);
hs_scratch_t
*
scratch
=
nullptr
;
hs_error_t
err
=
hs_
alloc_scratch
(
hyperscan_regex
->
get
(),
&
scratch
);
hs_error_t
err
=
hs_
clone_scratch
(
hyperscan_regex
->
getScratch
(),
&
scratch
);
if
(
err
!=
HS_SUCCESS
)
throw
Exception
(
"Could not
allocat
e scratch space for hyperscan"
,
ErrorCodes
::
CANNOT_ALLOCATE_MEMORY
);
throw
Exception
(
"Could not
clon
e scratch space for hyperscan"
,
ErrorCodes
::
CANNOT_ALLOCATE_MEMORY
);
MultiRegexps
::
ScratchPtr
smart_scratch
(
scratch
);
...
...
@@ -316,14 +317,16 @@ struct MultiMatchAnyImpl
if
(
length
>
std
::
numeric_limits
<
UInt32
>::
max
())
throw
Exception
(
"Too long string to search"
,
ErrorCodes
::
TOO_MANY_BYTES
);
res
[
i
]
=
0
;
hs_scan
(
hyperscan_regex
->
get
(),
err
=
hs_scan
(
hyperscan_regex
->
get
DB
(),
reinterpret_cast
<
const
char
*>
(
haystack_data
.
data
())
+
offset
,
length
,
0
,
smart_scratch
.
get
(),
on_match
,
&
res
[
i
]);
if
(
err
!=
HS_SUCCESS
)
throw
Exception
(
"Failed to scan with hyperscan"
,
ErrorCodes
::
HYPERSCAN_CANNOT_SCAN_TEXT
);
offset
=
haystack_offsets
[
i
];
}
#else
...
...
dbms/src/Functions/Regexps.h
浏览文件 @
f80fb09b
...
...
@@ -84,8 +84,20 @@ namespace MultiRegexps
};
using
CompilerError
=
std
::
unique_ptr
<
hs_compile_error_t
,
HyperscanDeleter
<
decltype
(
&
hs_free_compile_error
),
&
hs_free_compile_error
>>
;
using
ScratchPtr
=
std
::
unique_ptr
<
hs_scratch_t
,
DB
::
MultiRegexps
::
HyperscanDeleter
<
decltype
(
&
hs_free_scratch
),
&
hs_free_scratch
>>
;
using
Regexps
=
std
::
unique_ptr
<
hs_database_t
,
HyperscanDeleter
<
decltype
(
&
hs_free_database
),
&
hs_free_database
>>
;
using
ScratchPtr
=
std
::
unique_ptr
<
hs_scratch_t
,
HyperscanDeleter
<
decltype
(
&
hs_free_scratch
),
&
hs_free_scratch
>>
;
using
DataBasePtr
=
std
::
unique_ptr
<
hs_database_t
,
HyperscanDeleter
<
decltype
(
&
hs_free_database
),
&
hs_free_database
>>
;
class
Regexps
{
public:
Regexps
(
hs_database_t
*
db_
,
hs_scratch_t
*
scratch_
)
:
db
{
db_
},
scratch
{
scratch_
}
{}
hs_database_t
*
getDB
()
const
{
return
db
.
get
();
};
hs_scratch_t
*
getScratch
()
const
{
return
scratch
.
get
();
};
private:
DataBasePtr
db
;
ScratchPtr
scratch
;
};
using
Pool
=
ObjectPoolMap
<
Regexps
,
std
::
pair
<
std
::
vector
<
String
>
,
std
::
optional
<
UInt32
>>>
;
...
...
@@ -183,7 +195,13 @@ namespace MultiRegexps
ProfileEvents
::
increment
(
ProfileEvents
::
RegexpCreated
);
return
new
Regexps
{
db
};
hs_scratch_t
*
scratch
=
nullptr
;
err
=
hs_alloc_scratch
(
db
,
&
scratch
);
if
(
err
!=
HS_SUCCESS
)
throw
Exception
(
"Could not allocate scratch space for hyperscan"
,
ErrorCodes
::
CANNOT_ALLOCATE_MEMORY
);
return
new
Regexps
{
db
,
scratch
};
});
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录