mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 21:51:57 +00:00
b6e01cd47e
* split ColumnAggregateFunction.h * format * Allow use re2_st without cmake * use std type in find_first_symbols.h * fix ArrayEvaluator.h * include fixes * split ColumnConstAggregateFunction.h * fix StorageMaterializedView.h * split AddingDefaultBlockOutputStream.h * move CSVRowInputStream::updateDiagnosticInfo to .cpp * split ParserEnumElement.h * format * split DB/Parsers/ParserUseQuery.h * clean
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#pragma once
|
|
#include <DB/Common/OptimizedRegularExpression.h>
|
|
#include <DB/Functions/ObjectPool.h>
|
|
#include <DB/Functions/likePatternToRegexp.h>
|
|
#include <DB/Common/ProfileEvents.h>
|
|
|
|
|
|
namespace ProfileEvents
|
|
{
|
|
extern const Event RegexpCreated;
|
|
}
|
|
|
|
|
|
namespace DB {
|
|
|
|
|
|
namespace Regexps
|
|
{
|
|
using Regexp = OptimizedRegularExpressionImpl<false>;
|
|
using Pool = ObjectPoolMap<Regexp, String>;
|
|
|
|
template <bool like>
|
|
inline Regexp createRegexp(const std::string & pattern, int flags) { return {pattern, flags}; }
|
|
|
|
template <>
|
|
inline Regexp createRegexp<true>(const std::string & pattern, int flags) { return {likePatternToRegexp(pattern), flags}; }
|
|
|
|
template <bool like, bool no_capture>
|
|
inline Pool::Pointer get(const std::string & pattern)
|
|
{
|
|
/// C++11 has thread-safe function-local statics on most modern compilers.
|
|
static Pool known_regexps; /// Разные переменные для разных параметров шаблона.
|
|
|
|
return known_regexps.get(pattern, [&pattern]
|
|
{
|
|
int flags = OptimizedRegularExpression::RE_DOT_NL;
|
|
if (no_capture)
|
|
flags |= OptimizedRegularExpression::RE_NO_CAPTURE;
|
|
|
|
ProfileEvents::increment(ProfileEvents::RegexpCreated);
|
|
return new Regexp{createRegexp<like>(pattern, flags)};
|
|
});
|
|
}
|
|
}
|
|
|
|
}
|