2020-06-05 15:38:03 +00:00
|
|
|
#include <Processors/QueryPlan/IQueryPlanStep.h>
|
2020-06-25 09:39:17 +00:00
|
|
|
#include <Processors/IProcessor.h>
|
|
|
|
#include <IO/Operators.h>
|
2020-06-05 15:38:03 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int LOGICAL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
const DataStream & IQueryPlanStep::getOutputStream() const
|
|
|
|
{
|
|
|
|
if (!hasOutputStream())
|
|
|
|
throw Exception("QueryPlanStep " + getName() + " does not have output stream.", ErrorCodes::LOGICAL_ERROR);
|
|
|
|
|
|
|
|
return *output_stream;
|
|
|
|
}
|
|
|
|
|
2020-06-25 09:39:17 +00:00
|
|
|
static void doDescribeProcessor(const IProcessor & processor, size_t count, IQueryPlanStep::FormatSettings & settings)
|
|
|
|
{
|
|
|
|
settings.out << String(settings.offset, settings.ident_char) << processor.getName();
|
|
|
|
if (count > 1)
|
|
|
|
settings.out << " x " << std::to_string(count);
|
|
|
|
|
|
|
|
size_t num_inputs = processor.getInputs().size();
|
|
|
|
size_t num_outputs = processor.getOutputs().size();
|
|
|
|
if (num_inputs != 1 || num_outputs != 1)
|
|
|
|
settings.out << " " << std::to_string(num_inputs) << " -> " << std::to_string(num_outputs);
|
|
|
|
|
|
|
|
settings.out << '\n';
|
|
|
|
settings.offset += settings.ident;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IQueryPlanStep::describePipeline(const Processors & processors, FormatSettings & settings)
|
|
|
|
{
|
|
|
|
const IProcessor * prev = nullptr;
|
|
|
|
size_t count = 0;
|
|
|
|
|
|
|
|
for (auto it = processors.rbegin(); it != processors.rend(); ++it)
|
|
|
|
{
|
|
|
|
if (prev && prev->getName() != (*it)->getName())
|
|
|
|
{
|
|
|
|
doDescribeProcessor(*prev, count, settings);
|
|
|
|
count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
++count;
|
|
|
|
prev = it->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prev)
|
|
|
|
doDescribeProcessor(*prev, count, settings);
|
|
|
|
}
|
|
|
|
|
2020-06-05 15:38:03 +00:00
|
|
|
}
|