aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Disks/IO/ThreadPoolRemoteFSReader.h
blob: 506d77a64efafda32da70fca5c4a5d95c8281167 (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
#pragma once

#include <IO/AsynchronousReader.h>
#include <IO/ReadBuffer.h>
#include <Common/ThreadPool_fwd.h>
#include <Interpreters/threadPoolCallbackRunner.h>

namespace DB
{

struct AsyncReadCounters;

class ThreadPoolRemoteFSReader : public IAsynchronousReader
{
public:
    ThreadPoolRemoteFSReader(size_t pool_size, size_t queue_size_);

    std::future<IAsynchronousReader::Result> submit(Request request) override;

    void wait() override;

private:
    std::unique_ptr<ThreadPool> pool;
};

class RemoteFSFileDescriptor : public IAsynchronousReader::IFileDescriptor
{
public:
    explicit RemoteFSFileDescriptor(
        ReadBuffer & reader_,
        std::shared_ptr<AsyncReadCounters> async_read_counters_)
        : reader(reader_)
        , async_read_counters(async_read_counters_) {}

    IAsynchronousReader::Result readInto(char * data, size_t size, size_t offset, size_t ignore = 0);

    std::shared_ptr<AsyncReadCounters> getReadCounters() const { return async_read_counters; }

private:
    ReadBuffer & reader;
    std::shared_ptr<AsyncReadCounters> async_read_counters;
};

}