mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Fix writer compact
This commit is contained in:
parent
35d2a689dd
commit
34d1ad1aca
@ -22,6 +22,21 @@ Block getBlockAndPermute(const Block & block, const Names & names, const IColumn
|
||||
return result;
|
||||
}
|
||||
|
||||
Block permuteBlockIfNeeded(const Block & block, const IColumn::Permutation * permutation)
|
||||
{
|
||||
Block result;
|
||||
for (size_t i = 0; i < block.columns(); ++i)
|
||||
{
|
||||
result.insert(i, block.getByPosition(i));
|
||||
if (permutation)
|
||||
{
|
||||
auto & column = result.getByPosition(i);
|
||||
column.column = column.column->permute(*permutation, 0);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
IMergeTreeDataPartWriter::IMergeTreeDataPartWriter(
|
||||
const MergeTreeData::DataPartPtr & data_part_,
|
||||
const NamesAndTypesList & columns_list_,
|
||||
|
@ -15,6 +15,8 @@ namespace DB
|
||||
|
||||
Block getBlockAndPermute(const Block & block, const Names & names, const IColumn::Permutation * permutation);
|
||||
|
||||
Block permuteBlockIfNeeded(const Block & block, const IColumn::Permutation * permutation);
|
||||
|
||||
/// Writes data part to disk in different formats.
|
||||
/// Calculates and serializes primary and skip indices if needed.
|
||||
class IMergeTreeDataPartWriter : private boost::noncopyable
|
||||
|
@ -127,21 +127,7 @@ void MergeTreeDataPartWriterCompact::write(const Block & block, const IColumn::P
|
||||
fillIndexGranularity(index_granularity_for_block, block.rows());
|
||||
}
|
||||
|
||||
Block result_block;
|
||||
|
||||
if (permutation)
|
||||
{
|
||||
for (const auto & it : columns_list)
|
||||
{
|
||||
auto column = block.getByName(it.name);
|
||||
column.column = column.column->permute(*permutation, 0);
|
||||
result_block.insert(column);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result_block = block;
|
||||
}
|
||||
Block result_block = permuteBlockIfNeeded(block, permutation);
|
||||
|
||||
if (!header)
|
||||
header = result_block.cloneEmpty();
|
||||
|
Loading…
Reference in New Issue
Block a user