diff --git a/src/Interpreters/Squashing.cpp b/src/Interpreters/Squashing.cpp index 526af3db2e4..8f0964403b1 100644 --- a/src/Interpreters/Squashing.cpp +++ b/src/Interpreters/Squashing.cpp @@ -147,47 +147,35 @@ Block ApplySquashing::addImpl(Chunk && input_chunk) return Block(); const auto *info = getInfoFromChunk(input_chunk); - append(info->chunks); + for (auto & chunk : info->chunks) + append(chunk); Block to_return; std::swap(to_return, accumulated_block); return to_return; } -void ApplySquashing::append(const std::vector & input_chunks) +void ApplySquashing::append(Chunk & input_chunk) { - std::vector mutable_columns; - size_t rows = 0; - for (const Chunk & chunk : input_chunks) - rows += chunk.getNumRows(); - - // add here resize of mutable_column - for (const auto & input_chunk : input_chunks) + if (input_chunk.getNumColumns() == 0) + return; + if (!accumulated_block) { - if (!accumulated_block) + for (size_t i = 0; i < input_chunk.getNumColumns(); ++ i) { - for (size_t i = 0; i < input_chunks[0].getNumColumns(); ++ i) - { - ColumnWithTypeAndName col = ColumnWithTypeAndName(input_chunks[0].getColumns()[i], header.getDataTypes()[i], header.getNames()[i]); - mutable_columns.push_back(IColumn::mutate(col.column)); - accumulated_block.insert(col); - } + ColumnWithTypeAndName col = ColumnWithTypeAndName(input_chunk.getColumns()[i], header.getDataTypes()[i], header.getNames()[i]); + accumulated_block.insert(accumulated_block.columns(), col); } + return; + } - if (input_chunk.getNumColumns() == 0) - continue; + for (size_t i = 0, size = accumulated_block.columns(); i < size; ++i) + { + const auto source_column = input_chunk.getColumns()[i]; - for (auto & column : mutable_columns) - column->reserve(rows); - - for (size_t i = 0, size = accumulated_block.columns(); i < size; ++i) - { - const auto source_column = input_chunk.getColumns()[i]; - - mutable_columns[i] = IColumn::mutate(std::move(accumulated_block.getByPosition(i).column)); - mutable_columns[i]->insertRangeFrom(*source_column, 0, source_column->size()); - accumulated_block.getByPosition(i).column = mutable_columns[i]->cloneFinalized(); - } + auto mutable_column = IColumn::mutate(std::move(accumulated_block.getByPosition(i).column)); + mutable_column->insertRangeFrom(*source_column, 0, source_column->size()); + accumulated_block.getByPosition(i).column = std::move(mutable_column); } } diff --git a/src/Interpreters/Squashing.h b/src/Interpreters/Squashing.h index a68b581d40a..8273ae8cc8e 100644 --- a/src/Interpreters/Squashing.h +++ b/src/Interpreters/Squashing.h @@ -70,7 +70,7 @@ private: const ChunksToSquash * getInfoFromChunk(const Chunk & chunk); - void append(const std::vector & input_chunk); + void append(Chunk & input_chunk); bool isEnoughSize(const Block & block); bool isEnoughSize(size_t rows, size_t bytes) const; diff --git a/src/Processors/Transforms/PlanSquashingTransform.cpp b/src/Processors/Transforms/PlanSquashingTransform.cpp index f4106204462..51781b03853 100644 --- a/src/Processors/Transforms/PlanSquashingTransform.cpp +++ b/src/Processors/Transforms/PlanSquashingTransform.cpp @@ -1,6 +1,5 @@ #include #include -#include "Common/logger_useful.h" #include namespace DB diff --git a/src/Storages/ProjectionsDescription.cpp b/src/Storages/ProjectionsDescription.cpp index 45add4332ff..070245ba1b4 100644 --- a/src/Storages/ProjectionsDescription.cpp +++ b/src/Storages/ProjectionsDescription.cpp @@ -318,7 +318,7 @@ Block ProjectionDescription::calculate(const Block & block, ContextPtr context) } else { - builder.addTransform(std::make_shared(builder.getHeader(), block.rows(), 0)); + builder.addTransform(std::make_shared(builder.getHeader(), block.rows(), 0)); } auto pipeline = QueryPipelineBuilder::getPipeline(std::move(builder));