ClickHouse/dbms/src/Processors/ISource.cpp
2019-02-21 19:05:37 +03:00

48 lines
779 B
C++

#include <Processors/ISource.h>
namespace DB
{
ISource::ISource(Block header)
: IProcessor({}, {std::move(header)}), output(outputs.front())
{
}
ISource::Status ISource::prepare()
{
if (finished)
{
output.finish();
return Status::Finished;
}
/// Check can output.
if (output.isFinished())
return Status::Finished;
if (!output.canPush())
return Status::PortFull;
if (!has_input)
return Status::Ready;
output.push(std::move(current_chunk));
has_input = false;
/// Now, we pushed to output, and it must be full.
return Status::PortFull;
}
void ISource::work()
{
current_chunk = generate();
if (!current_chunk)
finished = true;
else
has_input = true;
}
}