ClickHouse/src/Storages/MergeTree/IMergeTreeDataPartWriter.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
2.0 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_,
2022-04-12 18:59:49 +00:00
DataPartStorageBuilderPtr data_part_storage_builder_,
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_)
2022-04-12 18:59:49 +00:00
, data_part_storage_builder(std::move(data_part_storage_builder_))
, 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_)
2021-10-20 14:12:07 +00:00
, with_final_mark(settings.can_use_adaptive_granularity)
2020-12-18 20:32:52 +00:00
{
}
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;
}