MCPcopy Create free account
hub / github.com/ByConity/ByConity / readImpl

Method readImpl

src/Formats/MySQLBlockInputStream.cpp:217–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215
216
217Block MySQLBlockInputStream::readImpl()
218{
219 auto row = connection->result.fetch();
220 if (!row)
221 {
222 if (settings->auto_close)
223 connection->entry.disconnect();
224
225 return {};
226 }
227
228 MutableColumns columns(description.sample_block.columns());
229 for (const auto i : collections::range(0, columns.size()))
230 columns[i] = description.sample_block.getByPosition(i).column->cloneEmpty();
231
232 size_t num_rows = 0;
233 size_t read_bytes_size = 0;
234
235 while (row)
236 {
237 for (size_t index = 0; index < position_mapping.size(); ++index)
238 {
239 const auto value = row[position_mapping[index]];
240 const auto & sample = description.sample_block.getByPosition(index);
241
242 bool is_type_nullable = description.types[index].second;
243
244 if (!value.isNull())
245 {
246 if (is_type_nullable)
247 {
248 ColumnNullable & column_nullable = assert_cast<ColumnNullable &>(*columns[index]);
249 const auto & data_type = assert_cast<const DataTypeNullable &>(*sample.type);
250 insertValue(*data_type.getNestedType(), column_nullable.getNestedColumn(), description.types[index].first, value, read_bytes_size);
251 column_nullable.getNullMapData().emplace_back(false);
252 }
253 else
254 {
255 insertValue(*sample.type, *columns[index], description.types[index].first, value, read_bytes_size);
256 }
257 }
258 else
259 {
260 insertDefaultValue(*columns[index], *sample.column);
261
262 if (is_type_nullable)
263 {
264 ColumnNullable & column_nullable = assert_cast<ColumnNullable &>(*columns[index]);
265 column_nullable.getNullMapData().back() = true;
266 }
267 }
268 }
269
270 ++num_rows;
271 if (num_rows == settings->max_read_mysql_row_nums || (settings->max_read_mysql_bytes_size && read_bytes_size >= settings->max_read_mysql_bytes_size))
272 break;
273
274 row = connection->result.fetch();

Callers

nothing calls this directly

Calls 12

rangeFunction · 0.85
columnsMethod · 0.80
getNestedTypeMethod · 0.80
cloneWithColumnsMethod · 0.80
insertValueFunction · 0.70
insertDefaultValueFunction · 0.70
fetchMethod · 0.45
disconnectMethod · 0.45
sizeMethod · 0.45
cloneEmptyMethod · 0.45
isNullMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected