Better exception safety for ISource and MergingAggregatedTransform.

This commit is contained in:
Nikolai Kochetov 2019-05-14 12:50:04 +03:00
parent 4453327344
commit 4ef3ff7270
2 changed files with 9 additions and 2 deletions

View File

@ -43,7 +43,7 @@ ISource::Status ISource::prepare()
void ISource::work()
{
/// try
try
{
current_chunk = generate();
if (!std::get<Chunk>(current_chunk))
@ -51,7 +51,11 @@ void ISource::work()
else
has_input = true;
}
// catch (Exception &)
catch (...)
{
finished = true;
throw;
}
// {
// current_chunk = std::current_exception();
// has_input = true;

View File

@ -45,6 +45,9 @@ Chunk MergingAggregatedTransform::generate()
LOG_TRACE(log, "Read " << total_input_blocks << " blocks of partially aggregated data, total " << total_input_rows
<< " rows.");
/// Exception safety. Make iterator valid in case any method below throws.
next_block = blocks.begin();
/// TODO: this operation can be made async. Add async for IAccumulatingTransform.
params->aggregator.mergeBlocks(std::move(bucket_to_blocks), data_variants, max_threads);
blocks = params->aggregator.convertToBlocks(data_variants, params->final, max_threads);