1#pragma once
2
3#include <Core/Types.h>
4#include <Core/Row.h>
5#include <IO/WriteBuffer.h>
6
7namespace DB
8{
9
10class Block;
11class MergeTreeData;
12struct FormatSettings;
13struct MergeTreeDataPartChecksums;
14
15/// This class represents a partition value of a single part and encapsulates its loading/storing logic.
16struct MergeTreePartition
17{
18 Row value;
19
20public:
21 MergeTreePartition() = default;
22
23 explicit MergeTreePartition(Row value_) : value(std::move(value_)) {}
24
25 /// For month-based partitioning.
26 explicit MergeTreePartition(UInt32 yyyymm) : value(1, yyyymm) {}
27
28 String getID(const MergeTreeData & storage) const;
29 String getID(const Block & partition_key_sample) const;
30
31 void serializeText(const MergeTreeData & storage, WriteBuffer & out, const FormatSettings & format_settings) const;
32
33 void load(const MergeTreeData & storage, const String & part_path);
34 void store(const MergeTreeData & storage, const String & part_path, MergeTreeDataPartChecksums & checksums) const;
35 void store(const Block & partition_key_sample, const String & part_path, MergeTreeDataPartChecksums & checksums) const;
36
37 void assign(const MergeTreePartition & other) { value.assign(other.value); }
38};
39
40}
41