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

Method generate

src/Storages/ObjectStorage/StorageObjectStorageSource.cpp:378–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376}
377
378Chunk StorageObjectStorageSource::generate()
379{
380 lazyInitialize();
381
382 while (true)
383 {
384 if (isCancelled() || !reader)
385 {
386 if (reader)
387 reader->cancel();
388 break;
389 }
390
391 Chunk chunk;
392 if (reader->pull(chunk))
393 {
394 UInt64 num_rows = chunk.getNumRows();
395 total_rows_in_file += num_rows;
396
397 size_t chunk_size = 0;
398 if (const auto * input_format = reader.getInputFormat())
399 chunk_size = input_format->getApproxBytesReadForChunk();
400
401 progress(num_rows, chunk_size ? chunk_size : chunk.bytes());
402
403 const auto & object_info = reader.getObjectInfo();
404 const auto & filename = object_info->getFileName();
405 std::string full_path = object_info->getPath();
406
407 const auto reading_path = configuration->getPathForRead().path;
408
409 if (!full_path.starts_with(reading_path))
410 full_path = fs::path(reading_path) / object_info->getPath();
411
412 auto object_metadata = object_info->getObjectMetadata();
413
414 chassert(object_metadata);
415
416 const auto path = getUniqueStoragePathIdentifier(*configuration, *object_info, false);
417
418 /// The order is important, hive partition columns must be added before virtual columns
419 /// because they are part of the schema
420 if (!read_from_format_info.hive_partition_columns_to_read_from_file_path.empty())
421 {
422 HivePartitioningUtils::addPartitionColumnsToChunk(
423 chunk,
424 read_from_format_info.hive_partition_columns_to_read_from_file_path,
425 path,
426 format_settings,
427 read_context);
428 }
429
430 const String * iceberg_metadata_file_path = nullptr;
431#if USE_AVRO
432 if (const auto * iceberg_info = dynamic_cast<const IcebergDataObjectInfo *>(object_info.get()))
433 iceberg_metadata_file_path = &iceberg_info->info.data_object_file_path_key.serialize();
434#endif
435

Callers

nothing calls this directly

Calls 15

isCancelledFunction · 0.85
getPathForReadMethod · 0.80
hasColumnsMethod · 0.80
tryLogCurrentExceptionFunction · 0.50
getLoggerFunction · 0.50
cancelMethod · 0.45
pullMethod · 0.45
getNumRowsMethod · 0.45

Tested by

no test coverage detected