Cosmetics: Pull out settings variable

This commit is contained in:
Robert Schulze 2022-06-24 15:20:03 +02:00
parent bb7c627964
commit 2ebfd01c2e
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
2 changed files with 10 additions and 10 deletions

View File

@ -36,12 +36,12 @@ public:
static constexpr auto name = Impl::name; static constexpr auto name = Impl::name;
static FunctionPtr create(ContextPtr context) static FunctionPtr create(ContextPtr context)
{ {
if (Impl::is_using_hyperscan && !context->getSettingsRef().allow_hyperscan) const auto & settings = context->getSettingsRef();
throw Exception(
"Hyperscan functions are disabled, because setting 'allow_hyperscan' is set to 0", ErrorCodes::FUNCTION_NOT_ALLOWED);
return std::make_shared<FunctionsMultiStringFuzzySearch>( if (Impl::is_using_hyperscan && !settings.allow_hyperscan)
context->getSettingsRef().max_hyperscan_regexp_length, context->getSettingsRef().max_hyperscan_regexp_total_length); throw Exception("Hyperscan functions are disabled, because setting 'allow_hyperscan' is set to 0", ErrorCodes::FUNCTION_NOT_ALLOWED);
return std::make_shared<FunctionsMultiStringFuzzySearch>(settings.max_hyperscan_regexp_length, settings.max_hyperscan_regexp_total_length);
} }
FunctionsMultiStringFuzzySearch(size_t max_hyperscan_regexp_length_, size_t max_hyperscan_regexp_total_length_) FunctionsMultiStringFuzzySearch(size_t max_hyperscan_regexp_length_, size_t max_hyperscan_regexp_total_length_)

View File

@ -49,12 +49,12 @@ public:
static constexpr auto name = Impl::name; static constexpr auto name = Impl::name;
static FunctionPtr create(ContextPtr context) static FunctionPtr create(ContextPtr context)
{ {
if (Impl::is_using_hyperscan && !context->getSettingsRef().allow_hyperscan) const auto & settings = context->getSettingsRef();
throw Exception(
"Hyperscan functions are disabled, because setting 'allow_hyperscan' is set to 0", ErrorCodes::FUNCTION_NOT_ALLOWED);
return std::make_shared<FunctionsMultiStringSearch>( if (Impl::is_using_hyperscan && !settings.allow_hyperscan)
context->getSettingsRef().max_hyperscan_regexp_length, context->getSettingsRef().max_hyperscan_regexp_total_length); throw Exception("Hyperscan functions are disabled, because setting 'allow_hyperscan' is set to 0", ErrorCodes::FUNCTION_NOT_ALLOWED);
return std::make_shared<FunctionsMultiStringSearch>(settings.max_hyperscan_regexp_length, settings.max_hyperscan_regexp_total_length);
} }
FunctionsMultiStringSearch(size_t max_hyperscan_regexp_length_, size_t max_hyperscan_regexp_total_length_) FunctionsMultiStringSearch(size_t max_hyperscan_regexp_length_, size_t max_hyperscan_regexp_total_length_)