1 | #include <Functions/FunctionFactory.h> |
---|---|
2 | #include <Functions/FunctionStringToString.h> |
3 | #include "firstSignificantSubdomain.h" |
4 | |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | struct CutToFirstSignificantSubdomain |
10 | { |
11 | static size_t getReserveLengthForElement() { return 15; } |
12 | |
13 | static void execute(const Pos data, const size_t size, Pos & res_data, size_t & res_size) |
14 | { |
15 | res_data = data; |
16 | res_size = 0; |
17 | |
18 | Pos tmp_data; |
19 | size_t tmp_length; |
20 | Pos domain_end; |
21 | ExtractFirstSignificantSubdomain::execute(data, size, tmp_data, tmp_length, &domain_end); |
22 | |
23 | if (tmp_length == 0) |
24 | return; |
25 | |
26 | res_data = tmp_data; |
27 | res_size = domain_end - tmp_data; |
28 | } |
29 | }; |
30 | |
31 | struct NameCutToFirstSignificantSubdomain { static constexpr auto name = "cutToFirstSignificantSubdomain"; }; |
32 | using FunctionCutToFirstSignificantSubdomain = FunctionStringToString<ExtractSubstringImpl<CutToFirstSignificantSubdomain>, NameCutToFirstSignificantSubdomain>; |
33 | |
34 | void registerFunctionCutToFirstSignificantSubdomain(FunctionFactory & factory) |
35 | { |
36 | factory.registerFunction<FunctionCutToFirstSignificantSubdomain>(); |
37 | } |
38 | |
39 | } |
40 |