aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Storages/FileLog/FileLogSource.h
blob: 51d69d23b5787b7eebf563d28be94597355a77fe (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
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once

#include <Processors/ISource.h>
#include <Storages/FileLog/ReadBufferFromFileLog.h>
#include <Storages/FileLog/StorageFileLog.h>

namespace Poco
{
    class Logger;
}
namespace DB
{
class FileLogSource : public ISource
{
public:
    FileLogSource(
        StorageFileLog & storage_,
        const StorageSnapshotPtr & storage_snapshot_,
        const ContextPtr & context_,
        const Names & columns,
        size_t max_block_size_,
        size_t poll_time_out_,
        size_t stream_number_,
        size_t max_streams_number_);

    String getName() const override { return "FileLog"; }

    bool noRecords() { return !buffer || buffer->noRecords(); }

    void onFinish();

    virtual ~FileLogSource() override;

protected:
    Chunk generate() override;

private:
    StorageFileLog & storage;
    StorageSnapshotPtr storage_snapshot;
    ContextPtr context;
    Names column_names;
    UInt64 max_block_size;

    size_t poll_time_out;

    size_t stream_number;
    size_t max_streams_number;

    std::unique_ptr<ReadBufferFromFileLog> buffer;

    Block non_virtual_header;
    Block virtual_header;

    /// The start pos and end pos of files responsible by this stream,
    /// does not include end.
    size_t start;
    size_t end;
};

}