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

Method generate

src/Storages/StorageFile.cpp:358–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356 }
357
358 Chunk generate() override
359 {
360 while (!finished_generate)
361 {
362 /// Open file lazily on first read. This is needed to avoid too many open files from different streams.
363 if (!reader)
364 {
365 if (!storage->use_table_fd)
366 {
367 auto current_file = files_info->next_file_to_read.fetch_add(1);
368 if (current_file >= files_info->files.size())
369 return {};
370
371 current_path = files_info->files[current_file];
372
373 /// Special case for distributed format. Defaults are not needed here.
374 if (storage->format_name == "Distributed")
375 {
376 pipeline = std::make_unique<QueryPipeline>();
377 pipeline->init(Pipe(StorageDistributedDirectoryMonitor::createSourceFromFile(current_path)));
378 reader = std::make_unique<PullingPipelineExecutor>(*pipeline);
379 continue;
380 }
381 }
382
383 std::unique_ptr<ReadBuffer> nested_buffer;
384 CompressionMethod method;
385
386 if (storage->use_table_fd)
387 {
388 nested_buffer = std::make_unique<ReadBufferFromFileDescriptor>(storage->table_fd);
389 method = chooseCompressionMethod("", storage->compression_method);
390 }
391 else
392 {
393 nested_buffer = std::make_unique<ReadBufferFromFile>(current_path, context->getSettingsRef().max_read_buffer_size);
394 method = chooseCompressionMethod(current_path, storage->compression_method);
395 }
396
397 /// For clickhouse-local add progress callback to display progress bar.
398 if (context->getApplicationType() == Context::ApplicationType::LOCAL)
399 {
400 auto & in = static_cast<ReadBufferFromFileDescriptor &>(*nested_buffer);
401 in.setProgressCallback(context);
402 }
403
404 read_buf = wrapReadBufferWithCompressionMethod(std::move(nested_buffer), method);
405
406 auto get_block_for_format = [&]() -> Block
407 {
408 if (storage->isColumnOriented())
409 return storage_snapshot->getSampleBlockForColumns(columns_description.getNamesOfPhysical());
410 return storage_snapshot->metadata->getSampleBlock();
411 };
412
413 auto format = FormatFactory::instance().getInput(
414 storage->format_name, *read_buf, get_block_for_format(), context, max_block_size, storage->format_settings);
415 format->setQueryInfo(query_info, context);

Callers

nothing calls this directly

Calls 15

chooseCompressionMethodFunction · 0.85
getApplicationTypeMethod · 0.80
isColumnOrientedMethod · 0.80
getNamesOfPhysicalMethod · 0.80
hasDefaultsMethod · 0.80
createColumnConstMethod · 0.80
PipeClass · 0.70
DataTypeStringClass · 0.50
sizeMethod · 0.45
initMethod · 0.45
setProgressCallbackMethod · 0.45

Tested by

no test coverage detected