mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
SummingSortedBlockInputStream: use a separate structure for MapDescription
This commit is contained in:
parent
39a5ae97c9
commit
41b0bea84c
@ -180,6 +180,7 @@ Block SummingSortedBlockInputStream::readImpl()
|
||||
auto tuple = std::make_shared<ColumnTuple>();
|
||||
auto & tuple_columns = tuple->getColumns();
|
||||
auto desc = AggregateDescription{};
|
||||
auto map_desc = MapDescription{};
|
||||
|
||||
column_num_it = map.second.begin();
|
||||
for (; column_num_it != map.second.end(); ++column_num_it)
|
||||
@ -198,14 +199,14 @@ Block SummingSortedBlockInputStream::readImpl()
|
||||
|| nested_type.getName() == "Float64")
|
||||
break;
|
||||
|
||||
desc.key_col_nums.push_back(*column_num_it);
|
||||
map_desc.key_col_nums.push_back(*column_num_it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!nested_type.behavesAsNumber())
|
||||
break;
|
||||
|
||||
desc.val_col_nums.push_back(*column_num_it);
|
||||
map_desc.val_col_nums.push_back(*column_num_it);
|
||||
}
|
||||
|
||||
// Add column to function arguments
|
||||
@ -217,7 +218,7 @@ Block SummingSortedBlockInputStream::readImpl()
|
||||
if (column_num_it != map.second.end())
|
||||
continue;
|
||||
|
||||
if (desc.key_col_nums.size() == 1)
|
||||
if (map_desc.key_col_nums.size() == 1)
|
||||
{
|
||||
// Create summation for all value columns in the map
|
||||
desc.merged_column = static_cast<ColumnPtr>(tuple);
|
||||
@ -229,11 +230,11 @@ Block SummingSortedBlockInputStream::readImpl()
|
||||
else
|
||||
{
|
||||
// Fall back to legacy mergeMaps for composite keys
|
||||
for (auto i : desc.key_col_nums)
|
||||
for (auto i : map_desc.key_col_nums)
|
||||
column_numbers_not_to_aggregate.push_back(i);
|
||||
for (auto i : desc.val_col_nums)
|
||||
for (auto i : map_desc.val_col_nums)
|
||||
column_numbers_not_to_aggregate.push_back(i);
|
||||
maps_to_sum.emplace_back(std::move(desc));
|
||||
maps_to_sum.emplace_back(std::move(map_desc));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -335,7 +336,7 @@ void SummingSortedBlockInputStream::merge(ColumnPlainPtrs & merged_columns, std:
|
||||
}
|
||||
|
||||
template <typename TSortCursor>
|
||||
bool SummingSortedBlockInputStream::mergeMap(const AggregateDescription & desc, Row & row, TSortCursor & cursor)
|
||||
bool SummingSortedBlockInputStream::mergeMap(const MapDescription & desc, Row & row, TSortCursor & cursor)
|
||||
{
|
||||
/// Strongly non-optimal.
|
||||
|
||||
|
@ -77,9 +77,6 @@ private:
|
||||
ColumnPtr merged_column;
|
||||
std::vector<char> state;
|
||||
bool created = false;
|
||||
/* Compatibility with the mergeMap */
|
||||
std::vector<size_t> key_col_nums;
|
||||
std::vector<size_t> val_col_nums;
|
||||
|
||||
/// Explicitly destroy aggregation state if the stream is terminated
|
||||
~AggregateDescription()
|
||||
@ -89,8 +86,15 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
/// Stores numbers of key-columns and value-columns.
|
||||
struct MapDescription
|
||||
{
|
||||
std::vector<size_t> key_col_nums;
|
||||
std::vector<size_t> val_col_nums;
|
||||
};
|
||||
|
||||
std::vector<AggregateDescription> columns_to_aggregate;
|
||||
std::vector<AggregateDescription> maps_to_sum;
|
||||
std::vector<MapDescription> maps_to_sum;
|
||||
|
||||
RowRef current_key; /// The current primary key.
|
||||
RowRef next_key; /// The primary key of the next row.
|
||||
@ -110,7 +114,7 @@ private:
|
||||
void insertCurrentRow(ColumnPlainPtrs & merged_columns);
|
||||
|
||||
template <typename TSortCursor>
|
||||
bool mergeMap(const AggregateDescription & map, Row & row, TSortCursor & cursor);
|
||||
bool mergeMap(const MapDescription & map, Row & row, TSortCursor & cursor);
|
||||
|
||||
/** Add the row under the cursor to the `row`.
|
||||
* Returns false if the result is zero.
|
||||
|
Loading…
Reference in New Issue
Block a user