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
66
67
68
69
|
#pragma once
#include <Storages/MergeTree/MergeTreeIndexGranularityInfo.h>
#include <Storages/MergeTree/MergeTreePartInfo.h>
#include <Storages/MergeTree/MergeTreeDataPartType.h>
#include <optional>
namespace DB
{
class IDataPartStorage;
class IMergeTreeDataPart;
class IVolume;
class IDisk;
class MergeTreeData;
using MutableDataPartStoragePtr = std::shared_ptr<IDataPartStorage>;
using VolumePtr = std::shared_ptr<IVolume>;
/// Class that helps to create a data part with different variations of arguments.
class MergeTreeDataPartBuilder
{
public:
MergeTreeDataPartBuilder(const MergeTreeData & data_, String name_, VolumePtr volume_, String root_path_, String part_dir_);
MergeTreeDataPartBuilder(const MergeTreeData & data_, String name_, MutableDataPartStoragePtr part_storage_);
std::shared_ptr<IMergeTreeDataPart> build();
using Self = MergeTreeDataPartBuilder;
Self & withPartInfo(MergeTreePartInfo part_info_);
Self & withParentPart(const IMergeTreeDataPart * parent_part_);
Self & withPartType(MergeTreeDataPartType part_type_);
Self & withPartStorageType(MergeTreeDataPartStorageType storage_type_);
Self & withPartFormat(MergeTreeDataPartFormat format_);
Self & withPartFormatFromDisk();
Self & withBytesAndRows(size_t bytes_uncompressed, size_t rows_count);
Self & withBytesAndRowsOnDisk(size_t bytes_uncompressed, size_t rows_count);
using PartStorageAndMarkType = std::pair<MutableDataPartStoragePtr, std::optional<MarkType>>;
static PartStorageAndMarkType getPartStorageAndMarkType(
const VolumePtr & volume_,
const String & root_path_,
const String & part_dir_);
private:
Self & withPartFormatFromVolume();
Self & withPartFormatFromStorage();
static MutableDataPartStoragePtr getPartStorageByType(
MergeTreeDataPartStorageType storage_type_,
const VolumePtr & volume_,
const String & root_path_,
const String & part_dir_);
const MergeTreeData & data;
const String name;
const VolumePtr volume;
const String root_path;
const String part_dir;
std::optional<MergeTreePartInfo> part_info;
std::optional<MergeTreeDataPartType> part_type;
MutableDataPartStoragePtr part_storage;
const IMergeTreeDataPart * parent_part = nullptr;
};
}
|