2022-06-24 13:24:17 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-06-28 07:51:36 +00:00
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
2022-06-24 13:24:17 +00:00
|
|
|
|
2023-02-08 13:07:27 +00:00
|
|
|
#include <re2_st/re2.h>
|
|
|
|
|
2022-06-24 13:24:17 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
void checkHyperscanRegexp(const std::vector<std::string_view> & regexps, size_t max_hyperscan_regexp_length, size_t max_hyperscan_regexp_total_length);
|
|
|
|
|
2023-02-08 13:07:27 +00:00
|
|
|
/// Regexp evaluation with hyperscan can be slow for certain patterns due to NFA state explosion. Try to identify such patterns on a
|
|
|
|
/// best-effort basis.
|
|
|
|
|
|
|
|
class SlowWithHyperscanChecker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SlowWithHyperscanChecker();
|
|
|
|
bool isSlow(std::string_view regexp);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool isSlowOneRepeat(std::string_view regexp);
|
|
|
|
bool isSlowTwoRepeats(std::string_view regexp);
|
|
|
|
re2_st::RE2 searcher_one_repeat;
|
|
|
|
re2_st::RE2 searcher_two_repeats;
|
|
|
|
};
|
|
|
|
|
2022-06-24 13:24:17 +00:00
|
|
|
}
|