blob: e91909cb50b64bf236f5990f7df05f1d357d4892 (
plain) (
blame)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#pragma once
#include <Processors/IProcessor.h>
#include <IO/Operators.h>
namespace DB
{
/** Print pipeline in "dot" format for GraphViz.
* You can render it with:
* dot -T png < pipeline.dot > pipeline.png
*/
template <typename Processors, typename Statuses>
void printPipeline(const Processors & processors, const Statuses & statuses, WriteBuffer & out)
{
out << "digraph\n{\n";
out << " rankdir=\"LR\";\n";
out << " { node [shape = rect]\n";
auto get_proc_id = [](const IProcessor & proc) -> UInt64
{
return reinterpret_cast<std::uintptr_t>(&proc);
};
auto statuses_iter = statuses.begin();
/// Nodes // TODO quoting and escaping
for (const auto & processor : processors)
{
const auto & description = processor->getDescription();
out << " n" << get_proc_id(*processor) << "[label=\"" << processor->getName() << (description.empty() ? "" : ":") << description;
if (statuses_iter != statuses.end())
{
out << " (" << IProcessor::statusToName(*statuses_iter) << ")";
++statuses_iter;
}
out << "\"];\n";
}
out << " }\n";
/// Edges
for (const auto & processor : processors)
{
for (const auto & port : processor->getOutputs())
{
if (!port.isConnected())
continue;
const IProcessor & curr = *processor;
const IProcessor & next = port.getInputPort().getProcessor();
out << " n" << get_proc_id(curr) << " -> n" << get_proc_id(next) << ";\n";
}
}
out << "}\n";
}
template <typename Processors>
void printPipeline(const Processors & processors, WriteBuffer & out)
{
printPipeline(processors, std::vector<IProcessor::Status>(), out);
}
/// Prints pipeline in compact representation.
/// Group processors by it's name, QueryPlanStep and QueryPlanStepGroup.
/// If QueryPlanStep wasn't set for processor, representation may be not correct.
/// If with_header is set, prints block header for each edge.
void printPipelineCompact(const Processors & processors, WriteBuffer & out, bool with_header);
}
|