mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
47 lines
1.5 KiB
C++
47 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <Backups/IBackupEntry.h>
|
|
#include <base/defines.h>
|
|
#include <mutex>
|
|
|
|
namespace DB
|
|
{
|
|
class TemporaryFileOnDisk;
|
|
class IDisk;
|
|
using DiskPtr = std::shared_ptr<IDisk>;
|
|
|
|
/// Represents a file prepared to be included in a backup, assuming that until this backup entry is destroyed the file won't be changed.
|
|
class BackupEntryFromImmutableFile : public IBackupEntry
|
|
{
|
|
public:
|
|
|
|
/// The constructor is allowed to not set `file_size_` or `checksum_`, in that case it will be calculated from the data.
|
|
BackupEntryFromImmutableFile(
|
|
const DiskPtr & disk_,
|
|
const String & file_path_,
|
|
const std::optional<UInt64> & file_size_ = {},
|
|
const std::optional<UInt128> & checksum_ = {},
|
|
const std::shared_ptr<TemporaryFileOnDisk> & temporary_file_ = {});
|
|
|
|
~BackupEntryFromImmutableFile() override;
|
|
|
|
UInt64 getSize() const override;
|
|
std::optional<UInt128> getChecksum() const override { return checksum; }
|
|
std::unique_ptr<SeekableReadBuffer> getReadBuffer() const override;
|
|
|
|
String getFilePath() const override;
|
|
DataSourceDescription getDataSourceDescription() const override;
|
|
|
|
DiskPtr tryGetDiskIfExists() const override { return disk; }
|
|
|
|
private:
|
|
const DiskPtr disk;
|
|
const String file_path;
|
|
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;
|
|
};
|
|
|
|
}
|