| 1 | #pragma once | 
|---|---|
| 2 | |
| 3 | #include <Poco/Logger.h> | 
| 4 | #include <DataStreams/IBlockInputStream.h> | 
| 5 | #include <Interpreters/SubqueryForSet.h> | 
| 6 | |
| 7 | |
| 8 | namespace Poco { class Logger; } | 
| 9 | |
| 10 | namespace DB | 
| 11 | { | 
| 12 | |
| 13 | /** Returns the data from the stream of blocks without changes, but | 
| 14 | * in the `readPrefix` function or before reading the first block | 
| 15 | * initializes all the passed sets. | 
| 16 | */ | 
| 17 | class CreatingSetsBlockInputStream : public IBlockInputStream | 
| 18 | { | 
| 19 | public: | 
| 20 | CreatingSetsBlockInputStream( | 
| 21 | const BlockInputStreamPtr & input, | 
| 22 | const SubqueriesForSets & subqueries_for_sets_, | 
| 23 | const Context & context_); | 
| 24 | |
| 25 | String getName() const override { return "CreatingSets"; } | 
| 26 | |
| 27 | Block getHeader() const override { return children.back()->getHeader(); } | 
| 28 | |
| 29 | /// Takes `totals` only from the main source, not from subquery sources. | 
| 30 | Block getTotals() override; | 
| 31 | |
| 32 | protected: | 
| 33 | Block readImpl() override; | 
| 34 | void readPrefixImpl() override; | 
| 35 | |
| 36 | private: | 
| 37 | SubqueriesForSets subqueries_for_sets; | 
| 38 | const Context & context; | 
| 39 | bool created = false; | 
| 40 | |
| 41 | SizeLimits network_transfer_limits; | 
| 42 | |
| 43 | size_t rows_to_transfer = 0; | 
| 44 | size_t bytes_to_transfer = 0; | 
| 45 | |
| 46 | using Logger = Poco::Logger; | 
| 47 | Logger * log = &Logger::get( "CreatingSetsBlockInputStream"); | 
| 48 | |
| 49 | void createAll(); | 
| 50 | void createOne(SubqueryForSet & subquery); | 
| 51 | }; | 
| 52 | |
| 53 | } | 
| 54 | 
