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

Method formatVector

src/Functions/formatQuery.cpp:98–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97private:
98 void formatVector(
99 const ColumnString::Chars & data,
100 const ColumnString::Offsets & offsets,
101 ColumnString::Chars & res_data,
102 ColumnString::Offsets & res_offsets,
103 ColumnUInt8::MutablePtr & res_null_map,
104 size_t input_rows_count) const
105 {
106 res_offsets.resize(input_rows_count);
107 res_data.resize(data.size());
108
109 size_t prev_offset = 0;
110 size_t res_data_size = 0;
111
112 for (size_t i = 0; i < input_rows_count; ++i)
113 {
114 const char * begin = reinterpret_cast<const char *>(&data[prev_offset]);
115 const char * end = begin + offsets[i] - prev_offset;
116
117 ParserQuery parser(end, false, implicit_select);
118 ASTPtr ast;
119 WriteBufferFromOwnString buf;
120
121 try
122 {
123 ast = parseQuery(parser, begin, end, /*query_description*/ {}, max_query_size, max_parser_depth, max_parser_backtracks);
124 }
125 catch (...)
126 {
127 if (error_handling == ErrorHandling::Null)
128 {
129 const size_t res_data_new_size = res_data_size + 1;
130 if (res_data_new_size > res_data.size())
131 res_data.resize(2 * res_data_new_size);
132
133 res_offsets[i] = res_data_size;
134 prev_offset = offsets[i];
135
136 res_null_map->getData()[i] = 1;
137
138 continue;
139 }
140
141 throw;
142 }
143
144 IAST::FormatSettings settings(output_formatting == OutputFormatting::SingleLine);
145 settings.show_secrets = true;
146 settings.print_pretty_type_names = print_pretty_type_names;
147 ast->format(buf, settings);
148
149 auto formatted = buf.stringView();
150
151 const size_t res_data_new_size = res_data_size + formatted.size();
152 if (res_data_new_size > res_data.size())
153 res_data.resize(2 * res_data_new_size);
154
155 memcpy(&res_data[res_data_size], formatted.data(), formatted.size());

Callers

nothing calls this directly

Calls 8

parseQueryFunction · 0.85
memcpyFunction · 0.85
resizeMethod · 0.45
sizeMethod · 0.45
getDataMethod · 0.45
formatMethod · 0.45
stringViewMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected