forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPort.cpp
More file actions
48 lines (37 loc) · 1.51 KB
/
Copy pathPort.cpp
File metadata and controls
48 lines (37 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <Processors/Port.h>
#include <Processors/IProcessor.h>
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
void connect(OutputPort & output, InputPort & input, bool reconnect)
{
if (!reconnect && input.state)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Port is already connected, (header: [{}])", input.header->dumpStructure());
if (!reconnect && output.state)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Port is already connected, (header: [{}])", output.header->dumpStructure());
auto out_name = output.processor ? output.getProcessor().getName() : "null";
auto in_name = input.processor ? input.getProcessor().getName() : "null";
assertCompatibleHeader(output.getHeader(), input.getHeader(), fmt::format("function connect between {} and {}", out_name, in_name));
input.output_port = &output;
output.input_port = &input;
input.state = std::make_shared<Port::State>();
output.state = input.state;
}
void disconnect(OutputPort & output, InputPort & input)
{
if (output.input_port != &input || input.output_port != &output)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot disconnect ports that are not connected to each other");
/// Disconnect from pipeline edges
input.update_info = nullptr;
output.update_info = nullptr;
/// Disconnect from each other
input.output_port = nullptr;
output.input_port = nullptr;
/// Reset shared State on both sides
input.state.reset();
output.state.reset();
}
}