rm prepareBlockAndFill

This commit is contained in:
Nikita Taranov 2022-07-14 01:46:18 +02:00
parent ae5baf2906
commit 433657e978
2 changed files with 30 additions and 51 deletions

View File

@ -2053,21 +2053,6 @@ Aggregator::OutputBlockColumns Aggregator::prepareOutputBlockColumns(Arenas & ag
}; };
} }
template <typename Filler>
Block Aggregator::prepareBlockAndFill(
AggregatedDataVariants & data_variants,
bool final,
size_t rows,
Filler && filler) const
{
auto && out_cols = prepareOutputBlockColumns(data_variants.aggregates_pools, final, rows);
auto && [key_columns, raw_key_columns, aggregate_columns, final_aggregate_columns, aggregate_columns_data] = out_cols;
filler(key_columns, aggregate_columns_data, final_aggregate_columns, final);
return finalizeBlock(std::move(out_cols), final, rows);
}
Block Aggregator::finalizeBlock(OutputBlockColumns && out_cols, bool final, size_t rows) const Block Aggregator::finalizeBlock(OutputBlockColumns && out_cols, bool final, size_t rows) const
{ {
auto && [key_columns, raw_key_columns, aggregate_columns, final_aggregate_columns, aggregate_columns_data] = out_cols; auto && [key_columns, raw_key_columns, aggregate_columns, final_aggregate_columns, aggregate_columns_data] = out_cols;
@ -2156,39 +2141,34 @@ void Aggregator::createStatesAndFillKeyColumnsWithSingleKey(
Block Aggregator::prepareBlockAndFillWithoutKey(AggregatedDataVariants & data_variants, bool final, bool is_overflows) const Block Aggregator::prepareBlockAndFillWithoutKey(AggregatedDataVariants & data_variants, bool final, bool is_overflows) const
{ {
size_t rows = 1; size_t rows = 1;
auto && out_cols = prepareOutputBlockColumns(data_variants.aggregates_pools, final, rows);
auto && [key_columns, raw_key_columns, aggregate_columns, final_aggregate_columns, aggregate_columns_data] = out_cols;
auto filler = [&data_variants, this]( if (data_variants.type == AggregatedDataVariants::Type::without_key || params.overflow_row)
MutableColumns & key_columns,
AggregateColumnsData & aggregate_columns,
MutableColumns & final_aggregate_columns,
bool final_)
{ {
if (data_variants.type == AggregatedDataVariants::Type::without_key || params.overflow_row) AggregatedDataWithoutKey & data = data_variants.without_key;
if (!data)
throw Exception("Wrong data variant passed.", ErrorCodes::LOGICAL_ERROR);
if (!final)
{ {
AggregatedDataWithoutKey & data = data_variants.without_key; for (size_t i = 0; i < params.aggregates_size; ++i)
aggregate_columns_data[i]->push_back(data + offsets_of_aggregate_states[i]);
if (!data) data = nullptr;
throw Exception("Wrong data variant passed.", ErrorCodes::LOGICAL_ERROR); }
else
if (!final_) {
{ /// Always single-thread. It's safe to pass current arena from 'aggregates_pool'.
for (size_t i = 0; i < params.aggregates_size; ++i) insertAggregatesIntoColumns(data, final_aggregate_columns, data_variants.aggregates_pool);
aggregate_columns[i]->push_back(data + offsets_of_aggregate_states[i]);
data = nullptr;
}
else
{
/// Always single-thread. It's safe to pass current arena from 'aggregates_pool'.
insertAggregatesIntoColumns(data, final_aggregate_columns, data_variants.aggregates_pool);
}
if (params.overflow_row)
for (size_t i = 0; i < params.keys_size; ++i)
key_columns[i]->insertDefault();
} }
};
Block block = prepareBlockAndFill(data_variants, final, rows, filler); if (params.overflow_row)
for (size_t i = 0; i < params.keys_size; ++i)
key_columns[i]->insertDefault();
}
Block block = finalizeBlock(std::move(out_cols), final, rows);
if (is_overflows) if (is_overflows)
block.info.is_overflows = true; block.info.is_overflows = true;
@ -3105,9 +3085,15 @@ Block Aggregator::mergeBlocks(BlocksList & blocks, bool final)
Block block; Block block;
if (result.type == AggregatedDataVariants::Type::without_key || is_overflows) if (result.type == AggregatedDataVariants::Type::without_key || is_overflows)
{
block = prepareBlockAndFillWithoutKey(result, final, is_overflows); block = prepareBlockAndFillWithoutKey(result, final, is_overflows);
}
else else
block = prepareBlockAndFillSingleLevel</* return_single_block */ true>(result, final); {
// Used during memory efficient merging in SortingAggregatedTransform (expects single chunk for each bucket_id).
constexpr bool return_single_block = true;
block = prepareBlockAndFillSingleLevel<return_single_block>(result, final);
}
/// NOTE: two-level data is not possible here - chooseAggregationMethod chooses only among single-level methods. /// NOTE: two-level data is not possible here - chooseAggregationMethod chooses only among single-level methods.
if (!final) if (!final)

View File

@ -1309,13 +1309,6 @@ private:
OutputBlockColumns prepareOutputBlockColumns(Arenas & aggregates_pools, bool final, size_t rows) const; OutputBlockColumns prepareOutputBlockColumns(Arenas & aggregates_pools, bool final, size_t rows) const;
Block finalizeBlock(OutputBlockColumns && out_cols, bool final, size_t rows) const; Block finalizeBlock(OutputBlockColumns && out_cols, bool final, size_t rows) const;
template <typename Filler>
Block prepareBlockAndFill(
AggregatedDataVariants & data_variants,
bool final,
size_t rows,
Filler && filler) const;
template <typename Method> template <typename Method>
Block convertOneBucketToBlock( Block convertOneBucketToBlock(
AggregatedDataVariants & data_variants, AggregatedDataVariants & data_variants,