ClickHouse/src/Functions/countSubstringsCaseInsensitiveUTF8.cpp
Azat Khuzhin 838596c7a4 Implement countSubstrings()
Function to count number of substring occurrences in the string:
- in case of needle is multi char - counts non-intersecting substrings
- the code is based on position helpers.

The following new functions is available:
- countSubstrings()
- countSubstringsCaseInsensitive()
- countSubstringsCaseInsensitiveUTF8()

v0: substringCount()

v2:
- add substringCountCaseInsensitiveUTF8
- improve tests
- fix coding style issues
- fix multichar needle

v3: rename to countSubstrings (by analogy with countEqual())
2020-11-26 22:58:16 +03:00

25 lines
583 B
C++

#include "FunctionsStringSearch.h"
#include "FunctionFactory.h"
#include "CountSubstringsImpl.h"
namespace DB
{
namespace
{
struct NameCountSubstringsCaseInsensitiveUTF8
{
static constexpr auto name = "countSubstringsCaseInsensitiveUTF8";
};
using FunctionCountSubstringsCaseInsensitiveUTF8 = FunctionsStringSearch<CountSubstringsImpl<PositionCaseInsensitiveUTF8>, NameCountSubstringsCaseInsensitiveUTF8>;
}
void registerFunctionCountSubstringsCaseInsensitiveUTF8(FunctionFactory & factory)
{
factory.registerFunction<FunctionCountSubstringsCaseInsensitiveUTF8>();
}
}