aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Backups/IBackupEntry.h
blob: 1b72b4358ba900f6bbc6b6a3fd24bc8288d25bbb (plain) (blame)
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
#pragma once

#include <Core/Types.h>
#include <memory>
#include <optional>
#include <vector>
#include <Disks/DiskType.h>
#include <Disks/IDisk.h>

namespace DB
{
class SeekableReadBuffer;

/// A backup entry represents some data which should be written to the backup or has been read from the backup.
class IBackupEntry
{
public:
    virtual ~IBackupEntry() = default;

    /// Returns the size of the data.
    virtual UInt64 getSize() const = 0;

    /// Returns the checksum of the data.
    virtual UInt128 getChecksum(const ReadSettings & read_settings) const = 0;

    /// Returns a partial checksum, i.e. the checksum calculated for a prefix part of the data.
    /// Can return nullopt if the partial checksum is too difficult to calculate.
    virtual std::optional<UInt128> getPartialChecksum(size_t /* prefix_length */, const ReadSettings &) const { return {}; }

    /// Returns a read buffer for reading the data.
    virtual std::unique_ptr<SeekableReadBuffer> getReadBuffer(const ReadSettings & read_settings) const = 0;

    /// Returns true if the data returned by getReadBuffer() is encrypted by an encrypted disk.
    virtual bool isEncryptedByDisk() const { return false; }

    /// Returns information about disk and file if this backup entry is generated from a file.
    virtual bool isFromFile() const { return false; }
    virtual bool isFromImmutableFile() const { return false; }
    virtual String getFilePath() const { return ""; }
    virtual DiskPtr getDisk() const { return nullptr; }

    virtual DataSourceDescription getDataSourceDescription() const = 0;
};

using BackupEntryPtr = std::shared_ptr<const IBackupEntry>;
using BackupEntries = std::vector<std::pair<String, BackupEntryPtr>>;

}