#include namespace DB { ISink::ISink(Block header) : IProcessor({std::move(header)}, {}), input(inputs.front()) { } ISink::Status ISink::prepare() { if (has_input) return Status::Ready; if (input.isFinished()) { onFinish(); return Status::Finished; } input.setNeeded(); if (!input.hasData()) return Status::NeedData; current_chunk = input.pull(true); has_input = true; return Status::Ready; } void ISink::work() { consume(std::move(current_chunk)); has_input = false; } }