2018-05-23 20:19:33 +00:00
|
|
|
#include <Processors/Port.h>
|
2019-04-11 15:31:23 +00:00
|
|
|
#include <Processors/IProcessor.h>
|
2018-05-23 20:19:33 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-02-25 18:10:48 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int LOGICAL_ERROR;
|
|
|
|
}
|
2018-05-23 20:19:33 +00:00
|
|
|
|
|
|
|
void connect(OutputPort & output, InputPort & input)
|
|
|
|
{
|
|
|
|
if (input.state || output.state)
|
2019-02-05 13:01:40 +00:00
|
|
|
throw Exception("Port is already connected", ErrorCodes::LOGICAL_ERROR);
|
2018-05-23 20:19:33 +00:00
|
|
|
|
2019-04-11 15:31:23 +00:00
|
|
|
auto out_name = output.getProcessor().getName();
|
|
|
|
auto in_name = input.getProcessor().getName();
|
|
|
|
|
|
|
|
assertBlocksHaveEqualStructure(input.getHeader(), output.getHeader(), " function connect between " + out_name + " and " + in_name);
|
2019-04-11 14:44:20 +00:00
|
|
|
|
2018-05-23 20:19:33 +00:00
|
|
|
input.output_port = &output;
|
|
|
|
output.input_port = &input;
|
|
|
|
input.state = std::make_shared<Port::State>();
|
|
|
|
output.state = input.state;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|