mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Remove the 'temporary_file_' argument from BackupEntryFromImmutableFile's constructor.
This commit is contained in:
parent
bc880db5d9
commit
cc50fcc60a
@ -10,9 +10,8 @@ BackupEntryFromAppendOnlyFile::BackupEntryFromAppendOnlyFile(
|
||||
const String & file_path_,
|
||||
const ReadSettings & settings_,
|
||||
const std::optional<UInt64> & file_size_,
|
||||
const std::optional<UInt128> & checksum_,
|
||||
const std::shared_ptr<TemporaryFileOnDisk> & temporary_file_)
|
||||
: BackupEntryFromImmutableFile(disk_, file_path_, settings_, file_size_, checksum_, temporary_file_)
|
||||
const std::optional<UInt128> & checksum_)
|
||||
: BackupEntryFromImmutableFile(disk_, file_path_, settings_, file_size_, checksum_)
|
||||
, limit(BackupEntryFromImmutableFile::getSize())
|
||||
{
|
||||
}
|
||||
|
@ -18,8 +18,7 @@ public:
|
||||
const String & file_path_,
|
||||
const ReadSettings & settings_,
|
||||
const std::optional<UInt64> & file_size_ = {},
|
||||
const std::optional<UInt128> & checksum_ = {},
|
||||
const std::shared_ptr<TemporaryFileOnDisk> & temporary_file_ = {});
|
||||
const std::optional<UInt128> & checksum_ = {});
|
||||
|
||||
UInt64 getSize() const override { return limit; }
|
||||
std::unique_ptr<SeekableReadBuffer> getReadBuffer() const override;
|
||||
|
@ -13,14 +13,12 @@ BackupEntryFromImmutableFile::BackupEntryFromImmutableFile(
|
||||
const String & file_path_,
|
||||
const ReadSettings & settings_,
|
||||
const std::optional<UInt64> & file_size_,
|
||||
const std::optional<UInt128> & checksum_,
|
||||
const std::shared_ptr<TemporaryFileOnDisk> & temporary_file_)
|
||||
const std::optional<UInt128> & checksum_)
|
||||
: disk(disk_)
|
||||
, file_path(file_path_)
|
||||
, settings(settings_)
|
||||
, file_size(file_size_)
|
||||
, checksum(checksum_)
|
||||
, temporary_file_on_disk(temporary_file_)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
namespace DB
|
||||
{
|
||||
class TemporaryFileOnDisk;
|
||||
class IDisk;
|
||||
using DiskPtr = std::shared_ptr<IDisk>;
|
||||
|
||||
@ -22,8 +21,7 @@ public:
|
||||
const String & file_path_,
|
||||
const ReadSettings & settings_,
|
||||
const std::optional<UInt64> & file_size_ = {},
|
||||
const std::optional<UInt128> & checksum_ = {},
|
||||
const std::shared_ptr<TemporaryFileOnDisk> & temporary_file_ = {});
|
||||
const std::optional<UInt128> & checksum_ = {});
|
||||
|
||||
~BackupEntryFromImmutableFile() override;
|
||||
|
||||
@ -43,7 +41,6 @@ private:
|
||||
mutable std::optional<UInt64> file_size TSA_GUARDED_BY(get_file_size_mutex);
|
||||
mutable std::mutex get_file_size_mutex;
|
||||
const std::optional<UInt128> checksum;
|
||||
const std::shared_ptr<TemporaryFileOnDisk> temporary_file_on_disk;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -27,11 +27,17 @@ private:
|
||||
T custom_value;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
BackupEntryPtr wrapBackupEntryWith(BackupEntryPtr && backup_entry, const T & custom_value)
|
||||
{
|
||||
return std::make_shared<BackupEntryWrappedWith<T>>(std::move(backup_entry), custom_value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void wrapBackupEntriesWith(std::vector<std::pair<String, BackupEntryPtr>> & backup_entries, const T & custom_value)
|
||||
{
|
||||
for (auto & [_, backup_entry] : backup_entries)
|
||||
backup_entry = std::make_shared<BackupEntryWrappedWith<T>>(std::move(backup_entry), custom_value);
|
||||
backup_entry = wrapBackupEntryWith(std::move(backup_entry), custom_value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <Storages/MergeTree/localBackup.h>
|
||||
#include <Backups/BackupEntryFromSmallFile.h>
|
||||
#include <Backups/BackupEntryFromImmutableFile.h>
|
||||
#include <Backups/BackupEntryWrappedWith.h>
|
||||
#include <Disks/SingleDiskVolume.h>
|
||||
#include <Storages/MergeTree/IMergeTreeDataPart.h>
|
||||
|
||||
@ -392,9 +393,12 @@ void DataPartStorageOnDiskBase::backup(
|
||||
file_hash = {it->second.file_hash.first, it->second.file_hash.second};
|
||||
}
|
||||
|
||||
backup_entries.emplace_back(
|
||||
filepath_in_backup,
|
||||
std::make_unique<BackupEntryFromImmutableFile>(disk, filepath_on_disk, read_settings, file_size, file_hash, temp_dir_owner));
|
||||
BackupEntryPtr backup_entry = std::make_unique<BackupEntryFromImmutableFile>(disk, filepath_on_disk, read_settings, file_size, file_hash);
|
||||
|
||||
if (temp_dir_owner)
|
||||
backup_entry = wrapBackupEntryWith(std::move(backup_entry), temp_dir_owner);
|
||||
|
||||
backup_entries.emplace_back(filepath_in_backup, std::move(backup_entry));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <Backups/BackupEntriesCollector.h>
|
||||
#include <Backups/BackupEntryFromAppendOnlyFile.h>
|
||||
#include <Backups/BackupEntryFromSmallFile.h>
|
||||
#include <Backups/BackupEntryWrappedWith.h>
|
||||
#include <Backups/IBackup.h>
|
||||
#include <Backups/RestorerFromBackup.h>
|
||||
#include <Disks/TemporaryFileOnDisk.h>
|
||||
@ -951,10 +952,10 @@ void StorageLog::backupData(BackupEntriesCollector & backup_entries_collector, c
|
||||
String data_file_name = fileName(data_file.path);
|
||||
String hardlink_file_path = temp_dir / data_file_name;
|
||||
disk->createHardLink(data_file.path, hardlink_file_path);
|
||||
backup_entries_collector.addBackupEntry(
|
||||
data_path_in_backup_fs / data_file_name,
|
||||
std::make_unique<BackupEntryFromAppendOnlyFile>(
|
||||
disk, hardlink_file_path, read_settings, file_checker.getFileSize(data_file.path), std::nullopt, temp_dir_owner));
|
||||
BackupEntryPtr backup_entry = std::make_unique<BackupEntryFromAppendOnlyFile>(
|
||||
disk, hardlink_file_path, read_settings, file_checker.getFileSize(data_file.path));
|
||||
backup_entry = wrapBackupEntryWith(std::move(backup_entry), temp_dir_owner);
|
||||
backup_entries_collector.addBackupEntry(data_path_in_backup_fs / data_file_name, std::move(backup_entry));
|
||||
}
|
||||
|
||||
/// __marks.mrk
|
||||
@ -964,10 +965,10 @@ void StorageLog::backupData(BackupEntriesCollector & backup_entries_collector, c
|
||||
String marks_file_name = fileName(marks_file_path);
|
||||
String hardlink_file_path = temp_dir / marks_file_name;
|
||||
disk->createHardLink(marks_file_path, hardlink_file_path);
|
||||
backup_entries_collector.addBackupEntry(
|
||||
data_path_in_backup_fs / marks_file_name,
|
||||
std::make_unique<BackupEntryFromAppendOnlyFile>(
|
||||
disk, hardlink_file_path, read_settings, file_checker.getFileSize(marks_file_path), std::nullopt, temp_dir_owner));
|
||||
BackupEntryPtr backup_entry = std::make_unique<BackupEntryFromAppendOnlyFile>(
|
||||
disk, hardlink_file_path, read_settings, file_checker.getFileSize(marks_file_path));
|
||||
backup_entry = wrapBackupEntryWith(std::move(backup_entry), temp_dir_owner);
|
||||
backup_entries_collector.addBackupEntry(data_path_in_backup_fs / marks_file_name, std::move(backup_entry));
|
||||
}
|
||||
|
||||
/// sizes.json
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <Backups/BackupEntriesCollector.h>
|
||||
#include <Backups/BackupEntryFromAppendOnlyFile.h>
|
||||
#include <Backups/BackupEntryFromSmallFile.h>
|
||||
#include <Backups/BackupEntryWrappedWith.h>
|
||||
#include <Backups/IBackup.h>
|
||||
#include <Backups/RestorerFromBackup.h>
|
||||
#include <Disks/TemporaryFileOnDisk.h>
|
||||
@ -551,10 +552,10 @@ void StorageStripeLog::backupData(BackupEntriesCollector & backup_entries_collec
|
||||
String data_file_name = fileName(data_file_path);
|
||||
String hardlink_file_path = temp_dir / data_file_name;
|
||||
disk->createHardLink(data_file_path, hardlink_file_path);
|
||||
backup_entries_collector.addBackupEntry(
|
||||
data_path_in_backup_fs / data_file_name,
|
||||
std::make_unique<BackupEntryFromAppendOnlyFile>(
|
||||
disk, hardlink_file_path, read_settings, file_checker.getFileSize(data_file_path), std::nullopt, temp_dir_owner));
|
||||
BackupEntryPtr backup_entry = std::make_unique<BackupEntryFromAppendOnlyFile>(
|
||||
disk, hardlink_file_path, read_settings, file_checker.getFileSize(data_file_path));
|
||||
backup_entry = wrapBackupEntryWith(std::move(backup_entry), temp_dir_owner);
|
||||
backup_entries_collector.addBackupEntry(data_path_in_backup_fs / data_file_name, std::move(backup_entry));
|
||||
}
|
||||
|
||||
/// index.mrk
|
||||
@ -563,10 +564,10 @@ void StorageStripeLog::backupData(BackupEntriesCollector & backup_entries_collec
|
||||
String index_file_name = fileName(index_file_path);
|
||||
String hardlink_file_path = temp_dir / index_file_name;
|
||||
disk->createHardLink(index_file_path, hardlink_file_path);
|
||||
backup_entries_collector.addBackupEntry(
|
||||
data_path_in_backup_fs / index_file_name,
|
||||
std::make_unique<BackupEntryFromAppendOnlyFile>(
|
||||
disk, hardlink_file_path, read_settings, file_checker.getFileSize(index_file_path), std::nullopt, temp_dir_owner));
|
||||
BackupEntryPtr backup_entry = std::make_unique<BackupEntryFromAppendOnlyFile>(
|
||||
disk, hardlink_file_path, read_settings, file_checker.getFileSize(index_file_path));
|
||||
backup_entry = wrapBackupEntryWith(std::move(backup_entry), temp_dir_owner);
|
||||
backup_entries_collector.addBackupEntry(data_path_in_backup_fs / index_file_name, std::move(backup_entry));
|
||||
}
|
||||
|
||||
/// sizes.json
|
||||
|
Loading…
Reference in New Issue
Block a user