1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include <Storages/MergeTree/IMergeTreeDataPartWriter.h>
namespace DB
{
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;
}
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 MergeTreeMutableDataPartPtr & data_part_,
const NamesAndTypesList & columns_list_,
const StorageMetadataPtr & metadata_snapshot_,
const MergeTreeWriterSettings & settings_,
const MergeTreeIndexGranularity & index_granularity_)
: data_part(data_part_)
, storage(data_part_->storage)
, metadata_snapshot(metadata_snapshot_)
, columns_list(columns_list_)
, settings(settings_)
, index_granularity(index_granularity_)
, with_final_mark(settings.can_use_adaptive_granularity)
{
}
Columns IMergeTreeDataPartWriter::releaseIndexColumns()
{
return Columns(
std::make_move_iterator(index_columns.begin()),
std::make_move_iterator(index_columns.end()));
}
IMergeTreeDataPartWriter::~IMergeTreeDataPartWriter() = default;
}
|