From 3332ed968275b7dd4a9ea167ab36d95c8779d671 Mon Sep 17 00:00:00 2001 From: Andrey Mironov Date: Fri, 5 Dec 2014 16:31:48 +0300 Subject: [PATCH] dbms: add pathFull function. [#METR-13679] --- dbms/include/DB/Functions/FunctionsURL.h | 23 +++++++++++++++++++++++ dbms/src/Functions/FunctionsURL.cpp | 1 + 2 files changed, 24 insertions(+) diff --git a/dbms/include/DB/Functions/FunctionsURL.h b/dbms/include/DB/Functions/FunctionsURL.h index ead631304e1..357b5d904a8 100644 --- a/dbms/include/DB/Functions/FunctionsURL.h +++ b/dbms/include/DB/Functions/FunctionsURL.h @@ -265,6 +265,27 @@ struct ExtractPath } }; +struct ExtractPathFull +{ + static size_t getReserveLengthForElement() { return 30; } + + static void execute(const Pos data, const size_t size, Pos & res_data, size_t & res_size) + { + res_data = data; + res_size = 0; + + Pos pos = data; + Pos end = pos + size; + + if (nullptr != (pos = strchr(data, '/')) && pos[1] == '/' && nullptr != (pos = strchr(pos + 2, '/'))) + { + /// no leading slash + res_data = pos + 1; + res_size = end - res_data; + } + } +}; + template struct ExtractQueryString { @@ -941,6 +962,7 @@ struct NameDomainWithoutWWW { static constexpr auto name = "domainWithoutWWW" struct NameFirstSignificantSubdomain { static constexpr auto name = "firstSignificantSubdomain"; }; struct NameTopLevelDomain { static constexpr auto name = "topLevelDomain"; }; struct NamePath { static constexpr auto name = "path"; }; +struct NamePathFull { static constexpr auto name = "pathFull"; }; struct NameQueryString { static constexpr auto name = "queryString"; }; struct NameFragment { static constexpr auto name = "fragment"; }; struct NameQueryStringAndFragment { static constexpr auto name = "queryStringAndFragment"; }; @@ -961,6 +983,7 @@ typedef FunctionStringToString >, Na typedef FunctionStringToString, NameFirstSignificantSubdomain> FunctionFirstSignificantSubdomain; typedef FunctionStringToString, NameTopLevelDomain> FunctionTopLevelDomain; typedef FunctionStringToString, NamePath> FunctionPath; +typedef FunctionStringToString, NamePathFull> FunctionPathFull; typedef FunctionStringToString >, NameQueryString> FunctionQueryString; typedef FunctionStringToString >, NameFragment> FunctionFragment; typedef FunctionStringToString >, NameQueryStringAndFragment> FunctionQueryStringAndFragment; diff --git a/dbms/src/Functions/FunctionsURL.cpp b/dbms/src/Functions/FunctionsURL.cpp index 67cdd59784a..abb640256c3 100644 --- a/dbms/src/Functions/FunctionsURL.cpp +++ b/dbms/src/Functions/FunctionsURL.cpp @@ -12,6 +12,7 @@ void registerFunctionsURL(FunctionFactory & factory) factory.registerFunction(); factory.registerFunction(); factory.registerFunction(); + factory.registerFunction(); factory.registerFunction(); factory.registerFunction(); factory.registerFunction();