Fix writer compact

This commit is contained in:
alesapin 2020-12-14 17:27:39 +03:00
parent 35d2a689dd
commit 34d1ad1aca
3 changed files with 18 additions and 15 deletions

View File

@ -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_,

View File

@ -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

View File

@ -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();