Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
ca1d3891
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,发现更多精彩内容 >>
提交
ca1d3891
编写于
11月 30, 2018
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't log to stderr within RE2 library [#CLICKHOUSE-2]
上级
cee0d48c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
18 deletion
+25
-18
dbms/src/Common/ErrorCodes.cpp
dbms/src/Common/ErrorCodes.cpp
+1
-0
dbms/src/Common/OptimizedRegularExpression.cpp
dbms/src/Common/OptimizedRegularExpression.cpp
+21
-13
dbms/src/Common/OptimizedRegularExpression.h
dbms/src/Common/OptimizedRegularExpression.h
+3
-5
未找到文件。
dbms/src/Common/ErrorCodes.cpp
浏览文件 @
ca1d3891
...
...
@@ -401,6 +401,7 @@ namespace ErrorCodes
extern
const
int
CANNOT_LINK
=
424
;
extern
const
int
SYSTEM_ERROR
=
425
;
extern
const
int
NULL_POINTER_DEREFERENCE
=
426
;
extern
const
int
CANNOT_COMPILE_REGEXP
=
427
;
extern
const
int
KEEPER_EXCEPTION
=
999
;
extern
const
int
POCO_EXCEPTION
=
1000
;
...
...
dbms/src/Common/OptimizedRegularExpression.
inl.h
→
dbms/src/Common/OptimizedRegularExpression.
cpp
浏览文件 @
ca1d3891
#include <iostream>
#include <Poco/Exception.h>
#include <Common/Exception.h>
#include <Common/OptimizedRegularExpression.h>
...
...
@@ -9,6 +6,15 @@
#define MAX_SUBPATTERNS 5
namespace
DB
{
namespace
ErrorCodes
{
extern
const
int
CANNOT_COMPILE_REGEXP
;
}
}
template
<
bool
thread_safe
>
void
OptimizedRegularExpressionImpl
<
thread_safe
>::
analyze
(
const
std
::
string
&
regexp
,
...
...
@@ -254,11 +260,11 @@ OptimizedRegularExpressionImpl<thread_safe>::OptimizedRegularExpressionImpl(cons
/// Just three following options are supported
if
(
options
&
(
~
(
RE_CASELESS
|
RE_NO_CAPTURE
|
RE_DOT_NL
)))
throw
Poco
::
Exception
(
"OptimizedRegularExpression: Unsupported option."
);
throw
DB
::
Exception
(
"OptimizedRegularExpression: Unsupported option."
,
DB
::
ErrorCodes
::
CANNOT_COMPILE_REGEXP
);
is_case_insensitive
=
options
&
RE_CASELESS
;
bool
is_no_capture
=
options
&
RE_NO_CAPTURE
;
bool
is_dot_nl
=
options
&
RE_DOT_NL
;
is_case_insensitive
=
options
&
RE_CASELESS
;
bool
is_no_capture
=
options
&
RE_NO_CAPTURE
;
bool
is_dot_nl
=
options
&
RE_DOT_NL
;
number_of_subpatterns
=
0
;
if
(
!
is_trivial
)
...
...
@@ -266,6 +272,9 @@ OptimizedRegularExpressionImpl<thread_safe>::OptimizedRegularExpressionImpl(cons
/// Compile the re2 regular expression.
typename
RegexType
::
Options
regexp_options
;
/// Never write error messages to stderr. It's ignorant to do it from library code.
regexp_options
.
set_log_errors
(
false
);
if
(
is_case_insensitive
)
regexp_options
.
set_case_sensitive
(
false
);
...
...
@@ -274,13 +283,13 @@ OptimizedRegularExpressionImpl<thread_safe>::OptimizedRegularExpressionImpl(cons
re2
=
std
::
make_unique
<
RegexType
>
(
regexp_
,
regexp_options
);
if
(
!
re2
->
ok
())
throw
Poco
::
Exception
(
"OptimizedRegularExpression: cannot compile re2: "
+
regexp_
+
", error: "
+
re2
->
error
()
);
throw
DB
::
Exception
(
"OptimizedRegularExpression: cannot compile re2: "
+
regexp_
+
", error: "
+
re2
->
error
()
+
". Look at https://github.com/google/re2/wiki/Syntax for reference."
,
DB
::
ErrorCodes
::
CANNOT_COMPILE_REGEXP
);
if
(
!
is_no_capture
)
{
number_of_subpatterns
=
re2
->
NumberOfCapturingGroups
();
if
(
number_of_subpatterns
>
MAX_SUBPATTERNS
)
throw
Poco
::
Exception
(
"OptimizedRegularExpression: too many subpatterns in regexp: "
+
regexp_
);
throw
DB
::
Exception
(
"OptimizedRegularExpression: too many subpatterns in regexp: "
+
regexp_
,
DB
::
ErrorCodes
::
CANNOT_COMPILE_REGEXP
);
}
}
}
...
...
@@ -432,6 +441,5 @@ unsigned OptimizedRegularExpressionImpl<thread_safe>::match(const char * subject
}
}
#undef MIN_LENGTH_FOR_STRSTR
#undef MAX_SUBPATTERNS
template
class
OptimizedRegularExpressionImpl
<
true
>;
template
class
OptimizedRegularExpressionImpl
<
false
>;
dbms/src/Common/OptimizedRegularExpression.h
浏览文件 @
ca1d3891
...
...
@@ -45,9 +45,9 @@ class OptimizedRegularExpressionImpl
public:
enum
Options
{
RE_CASELESS
=
0x00000001
,
RE_NO_CAPTURE
=
0x00000010
,
RE_DOT_NL
=
0x00000100
RE_CASELESS
=
0x00000001
,
RE_NO_CAPTURE
=
0x00000010
,
RE_DOT_NL
=
0x00000100
};
using
Match
=
OptimizedRegularExpressionDetails
::
Match
;
...
...
@@ -106,5 +106,3 @@ private:
};
using
OptimizedRegularExpression
=
OptimizedRegularExpressionImpl
<
true
>
;
#include "OptimizedRegularExpression.inl.h"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录