Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
7d332ab7
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,发现更多精彩内容 >>
提交
7d332ab7
编写于
5月 06, 2020
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor improvements
上级
c6876cca
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
11 deletion
+10
-11
src/Functions/FunctionsStringRegex.cpp
src/Functions/FunctionsStringRegex.cpp
+10
-11
未找到文件。
src/Functions/FunctionsStringRegex.cpp
浏览文件 @
7d332ab7
...
...
@@ -7,8 +7,6 @@
#include <Functions/FunctionFactory.h>
#include <Functions/Regexps.h>
#include <IO/WriteHelpers.h>
#include <re2/re2.h>
#include <re2/stringpiece.h>
#include <Poco/UTF8String.h>
#include <Common/Volnitsky.h>
#include <algorithm>
...
...
@@ -29,6 +27,7 @@
#if USE_RE2_ST
# include <re2_st/re2.h>
#else
# include <re2/re2.h>
# define re2_st re2
#endif
...
...
@@ -1113,7 +1112,7 @@ public:
return
std
::
make_shared
<
DataTypeArray
>
(
std
::
make_shared
<
DataTypeArray
>
(
std
::
make_shared
<
DataTypeString
>
()));
}
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
,
size_t
/*input_rows_count*/
)
override
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
,
size_t
input_rows_count
)
override
{
const
ColumnPtr
column_haystack
=
block
.
getByPosition
(
arguments
[
0
]).
column
;
const
ColumnPtr
column_needle
=
block
.
getByPosition
(
arguments
[
1
]).
column
;
...
...
@@ -1123,33 +1122,33 @@ public:
if
(
needle
.
size
==
0
)
throw
Exception
(
getName
()
+
" length of 'needle' argument must be greater than 0."
,
ErrorCodes
::
ARGUMENT_OUT_OF_BOUND
);
re2
::
RE2
re
{
re2
::
StringPiece
(
needle
.
data
,
needle
.
size
)};
re2
_st
::
RE2
re
{
re2_st
::
StringPiece
(
needle
.
data
,
needle
.
size
)};
if
(
!
re
.
ok
())
throw
Exception
(
getName
()
+
" invalid regular expression: "
+
re
.
error
(),
ErrorCodes
::
CANNOT_COMPILE_REGEXP
);
const
size_t
groups_count
=
re
.
NumberOfCapturingGroups
();
std
::
vector
<
re2
::
StringPiece
>
all_matches
;
std
::
vector
<
re2
_st
::
StringPiece
>
all_matches
;
// number of times RE matched on each row of haystack column.
std
::
vector
<
size_t
>
number_of_matches_per_row
;
// we expect RE to match multiple times on each row, `* 8` is arbitrary to reduce number of re-allocations.
all_matches
.
reserve
(
column_haystack
->
size
()
*
groups_count
*
8
);
number_of_matches_per_row
.
reserve
(
column_haystack
->
size
()
);
all_matches
.
reserve
(
input_rows_count
*
groups_count
*
8
);
number_of_matches_per_row
.
reserve
(
input_rows_count
);
// including 0-group, which is the whole RE
std
::
vector
<
re2
::
StringPiece
>
matched_groups
(
groups_count
+
1
);
std
::
vector
<
re2
_st
::
StringPiece
>
matched_groups
(
groups_count
+
1
);
for
(
size_t
i
=
0
;
i
<
column_haystack
->
size
()
;
++
i
)
for
(
size_t
i
=
0
;
i
<
input_rows_count
;
++
i
)
{
size_t
matches_per_row
=
0
;
const
auto
&
current_row
=
column_haystack
->
getDataAt
(
i
);
const
auto
haystack
=
re2
::
StringPiece
(
current_row
.
data
,
current_row
.
size
);
const
auto
haystack
=
re2
_st
::
StringPiece
(
current_row
.
data
,
current_row
.
size
);
// Extract all non-intersecting matches from haystack except group #0.
size_t
start_pos
=
0
;
while
(
start_pos
<
haystack
.
size
()
&&
re
.
Match
(
haystack
,
start_pos
,
haystack
.
size
(),
re2
::
RE2
::
UNANCHORED
,
re2
_st
::
RE2
::
UNANCHORED
,
matched_groups
.
data
(),
matched_groups
.
size
()))
{
// +1 is to exclude group #0 which is whole re match.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录