ClickHouse/src/Storages/MergeTree/IMergeTreeDataPartWriter.cpp

66 lines
1.9 KiB
C++
Raw Normal View History

2020-04-14 01:27:27 +00:00
#include <Storages/MergeTree/IMergeTreeDataPartWriter.h>
namespace DB
{
2020-12-14 07:28:42 +00:00
2020-12-10 08:57:52 +00:00
Block getBlockAndPermute(const Block & block, const Names & names, const IColumn::Permutation * permutation)
{
Block result;
for (size_t i = 0, size = names.size(); i < size; ++i)
{
const auto & name = names[i];
result.insert(i, block.getByName(name));
/// Reorder primary key columns in advance and add them to `primary_key_columns`.
if (permutation)
{
auto & column = result.getByPosition(i);
column.column = column.column->permute(*permutation, 0);
}
}
return result;
}
2020-12-14 14:27:39 +00:00
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;
}
2020-04-14 01:27:27 +00:00
IMergeTreeDataPartWriter::IMergeTreeDataPartWriter(
const MergeTreeData::DataPartPtr & data_part_,
2020-04-14 19:47:19 +00:00
const NamesAndTypesList & columns_list_,
2020-06-26 11:30:23 +00:00
const StorageMetadataPtr & metadata_snapshot_,
2020-12-10 09:22:43 +00:00
const MergeTreeWriterSettings & settings_,
const MergeTreeIndexGranularity & index_granularity_)
: data_part(data_part_)
, storage(data_part_->storage)
2020-06-26 11:30:23 +00:00
, metadata_snapshot(metadata_snapshot_)
2020-04-14 19:47:19 +00:00
, columns_list(columns_list_)
2020-05-14 20:08:15 +00:00
, settings(settings_)
2020-04-14 01:27:27 +00:00
, index_granularity(index_granularity_)
2020-12-18 20:32:52 +00:00
, with_final_mark(storage.getSettings()->write_final_mark && settings.can_use_adaptive_granularity)
{
}
2020-04-14 01:27:27 +00:00
Columns IMergeTreeDataPartWriter::releaseIndexColumns()
{
return Columns(
std::make_move_iterator(index_columns.begin()),
std::make_move_iterator(index_columns.end()));
}
IMergeTreeDataPartWriter::~IMergeTreeDataPartWriter() = default;
}