forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMergeTreePartExportManifest.h
More file actions
91 lines (73 loc) · 3.07 KB
/
MergeTreePartExportManifest.h
File metadata and controls
91 lines (73 loc) · 3.07 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#pragma once
#include <Interpreters/StorageID.h>
#include <Storages/MergeTree/IMergeTreeDataPart.h>
#include <Storages/StorageSnapshot.h>
#include <QueryPipeline/QueryPipeline.h>
#include <optional>
#include <Core/Settings.h>
#include <Storages/IStorage.h>
namespace DB
{
class Exception;
class ExportPartTask;
struct MergeTreePartExportManifest
{
using FileAlreadyExistsPolicy = MergeTreePartExportFileAlreadyExistsPolicy;
using DataPartPtr = std::shared_ptr<const IMergeTreeDataPart>;
struct CompletionCallbackResult
{
private:
CompletionCallbackResult(bool success_, const std::vector<String> & relative_paths_in_destination_storage_, std::optional<Exception> exception_)
: success(success_), relative_paths_in_destination_storage(relative_paths_in_destination_storage_), exception(std::move(exception_)) {}
public:
static CompletionCallbackResult createSuccess(const std::vector<String> & relative_paths_in_destination_storage_)
{
return CompletionCallbackResult(true, relative_paths_in_destination_storage_, std::nullopt);
}
static CompletionCallbackResult createFailure(Exception exception_)
{
return CompletionCallbackResult(false, {}, std::move(exception_));
}
bool success = false;
std::vector<String> relative_paths_in_destination_storage;
std::optional<Exception> exception;
};
MergeTreePartExportManifest(
const StoragePtr destination_storage_ptr_,
const DataPartPtr & data_part_,
const String & transaction_id_,
FileAlreadyExistsPolicy file_already_exists_policy_,
const Settings & settings_,
const StorageMetadataPtr & metadata_snapshot_,
std::function<void(CompletionCallbackResult)> completion_callback_ = {})
: destination_storage_ptr(destination_storage_ptr_),
data_part(data_part_),
transaction_id(transaction_id_),
file_already_exists_policy(file_already_exists_policy_),
settings(settings_),
metadata_snapshot(metadata_snapshot_),
completion_callback(completion_callback_),
create_time(time(nullptr)) {}
StoragePtr destination_storage_ptr;
DataPartPtr data_part;
/// Used for killing the export.
String transaction_id;
FileAlreadyExistsPolicy file_already_exists_policy;
Settings settings;
/// Metadata snapshot captured at the time of query validation to prevent race conditions with mutations
/// Otherwise the export could fail if the schema changes between validation and execution
StorageMetadataPtr metadata_snapshot;
std::function<void(CompletionCallbackResult)> completion_callback;
time_t create_time;
mutable bool in_progress = false;
mutable std::shared_ptr<ExportPartTask> task = nullptr;
bool operator<(const MergeTreePartExportManifest & rhs) const
{
return data_part->name < rhs.data_part->name;
}
bool operator==(const MergeTreePartExportManifest & rhs) const
{
return data_part->name == rhs.data_part->name;
}
};
}