max_threads limit

This commit is contained in:
Nikita Mikhaylov 2019-10-29 02:43:22 +03:00
parent 2bd79325d7
commit c5085b86aa

View File

@ -1,3 +1,4 @@
#include <algorithm>
#include <Common/config.h>
#include <Common/Exception.h>
#include <Interpreters/Context.h>
@ -124,7 +125,10 @@ BlockInputStreamPtr FormatFactory::getInput(
row_input_format_params.max_execution_time = settings.max_execution_time;
row_input_format_params.timeout_overflow_mode = settings.timeout_overflow_mode;
size_t max_threads_to_use = settings.max_threads_for_parallel_parsing;
//The number of threads for parallel parsing must be less or equal settings.max_threads.
const size_t global_max_threads = settings.max_threads;
const size_t max_threads_for_parallel_parsing = settings.max_threads_for_parallel_parsing;
const size_t max_threads_to_use = max_threads_for_parallel_parsing == 0 ? global_max_threads : std::min(max_threads_for_parallel_parsing, global_max_threads);
auto params = ParallelParsingBlockInputStream::InputCreatorParams{sample, context, row_input_format_params, format_settings};
ParallelParsingBlockInputStream::Builder builder{buf, input_getter, params, file_segmentation_engine, max_threads_to_use, settings.min_chunk_size_for_parallel_parsing};