MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / parseRemoteDescription

Function parseRemoteDescription

src/Common/parseRemoteDescription.cpp:55–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54
55std::vector<String> parseRemoteDescription(
56 const String & description, size_t l, size_t r, char separator, size_t max_addresses, const String & func_name)
57{
58 std::vector<String> res;
59 std::vector<String> cur;
60
61 /// An empty substring means a set of an empty string
62 if (l >= r)
63 {
64 res.push_back("");
65 return res;
66 }
67
68 for (size_t i = l; i < r; ++i)
69 {
70 /// Either the numeric interval (8..10) or equivalent expression in brackets
71 if (description[i] == '{')
72 {
73 ssize_t cnt = 1;
74 ssize_t last_dot = -1; /// The rightmost pair of points, remember the index of the right of the two
75 size_t m = 0;
76 std::vector<String> buffer;
77 bool have_splitter = false;
78
79 /// Look for the corresponding closing bracket
80 for (m = i + 1; m < r; ++m)
81 {
82 if (description[m] == '{')
83 ++cnt;
84 if (description[m] == '}')
85 --cnt;
86 if (description[m] == '.' && description[m-1] == '.')
87 last_dot = m;
88 if (description[m] == separator)
89 have_splitter = true;
90 if (cnt == 0)
91 break;
92 }
93 if (cnt != 0)
94 throw Exception(ErrorCodes::BAD_ARGUMENTS, "Table function '{}': incorrect brace sequence in first argument", func_name);
95 /// The presence of a dot - numeric interval
96 if (last_dot != -1)
97 {
98 size_t left = 0;
99 size_t right = 0;
100 if (description[last_dot - 1] != '.')
101 throw Exception(
102 ErrorCodes::BAD_ARGUMENTS,
103 "Table function '{}': incorrect argument in braces (only one dot): {}",
104 func_name,
105 description.substr(i, m - i + 1));
106 if (!parseNumber(description, i + 1, last_dot - 1, left))
107 throw Exception(
108 ErrorCodes::BAD_ARGUMENTS,
109 "Table function '{}': "
110 "incorrect argument in braces (Incorrect left number): {}",
111 func_name,
112 description.substr(i, m - i + 1));

Callers 6

getSampleURIFunction · 0.85
getFailoverOptionsFunction · 0.85
ImplMethod · 0.85
parseArgumentsMethod · 0.85

Calls 9

ExceptionClass · 0.70
parseNumberFunction · 0.70
appendFunction · 0.70
push_backMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected