| 1 | #include <Processors/ISink.h> |
|---|---|
| 2 | |
| 3 | |
| 4 | namespace DB |
| 5 | { |
| 6 | |
| 7 | ISink::ISink(Block header) |
| 8 | : IProcessor({std::move(header)}, {}), input(inputs.front()) |
| 9 | { |
| 10 | } |
| 11 | |
| 12 | ISink::Status ISink::prepare() |
| 13 | { |
| 14 | if (has_input) |
| 15 | return Status::Ready; |
| 16 | |
| 17 | if (input.isFinished()) |
| 18 | return Status::Finished; |
| 19 | |
| 20 | input.setNeeded(); |
| 21 | if (!input.hasData()) |
| 22 | return Status::NeedData; |
| 23 | |
| 24 | current_chunk = input.pull(); |
| 25 | has_input = true; |
| 26 | return Status::Ready; |
| 27 | } |
| 28 | |
| 29 | void ISink::work() |
| 30 | { |
| 31 | consume(std::move(current_chunk)); |
| 32 | has_input = false; |
| 33 | } |
| 34 | |
| 35 | } |
| 36 | |
| 37 |