aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Processors/QueryPlan/ReadFromPreparedSource.h
blob: 2606f5010099a168be1ee6d2d49016f8b348c184 (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
#pragma once

#include <Interpreters/Context.h>
#include <Processors/QueryPlan/ISourceStep.h>
#include <QueryPipeline/Pipe.h>

namespace DB
{

/// Create source from prepared pipe.
class ReadFromPreparedSource : public ISourceStep
{
public:
    explicit ReadFromPreparedSource(
        Pipe pipe_, ContextPtr context_ = nullptr, Context::QualifiedProjectionName qualified_projection_name_ = {});

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

    void initializePipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &) override;

protected:
    Pipe pipe;
    ContextPtr context;
    Context::QualifiedProjectionName qualified_projection_name;
};

class ReadFromStorageStep : public ReadFromPreparedSource
{
public:
    ReadFromStorageStep(Pipe pipe_, String storage_name, std::shared_ptr<const StorageLimitsList> storage_limits_)
        : ReadFromPreparedSource(std::move(pipe_)), storage_limits(std::move(storage_limits_))
    {
        setStepDescription(storage_name);

        for (const auto & processor : pipe.getProcessors())
            processor->setStorageLimits(storage_limits);
    }

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

private:
    std::shared_ptr<const StorageLimitsList> storage_limits;
};

}