ClickHouse/src/Processors/ISink.cpp
2020-10-14 21:05:20 +08:00

40 lines
583 B
C++

#include <Processors/ISink.h>
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;
}
}