aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Backups/IBackupEntriesLazyBatch.h
blob: 36f9805ff30fba4b50a1a9f82ab05de832a061ff (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
#pragma once

#include <Backups/IBackupEntry.h>
#include <mutex>

namespace DB
{

/// Helper class designed to generate multiple backup entries from one source.
class IBackupEntriesLazyBatch : public std::enable_shared_from_this<IBackupEntriesLazyBatch>
{
public:
    BackupEntries getBackupEntries();
    virtual ~IBackupEntriesLazyBatch();

protected:
    virtual size_t getSize() const = 0;
    virtual const String & getName(size_t i) const = 0;
    virtual BackupEntries generate() = 0;

private:
    void generateIfNecessary();

    class BackupEntryFromBatch;
    std::mutex mutex;
    BackupEntries entries;
    bool generated = false;
};

}