18 #include <boost/lexical_cast.hpp>
27 using namespace impala;
35 int new_indent_level,
int* node_idx,
36 vector<vector<string> >* result) {
37 DCHECK_LT(*node_idx, exec_summary.nodes.size());
38 const TPlanNodeExecSummary& node = exec_summary.nodes[*node_idx];
39 const TExecStats& est_stats = node.estimated_stats;
44 #define COMPUTE_MAX_SUM_STATS(NAME)\
45 agg_stats.NAME += node.exec_stats[i].NAME;\
46 max_stats.NAME = std::max(max_stats.NAME, node.exec_stats[i].NAME)
49 for (
int i = 0; i < node.exec_stats.size(); ++i) {
54 #undef COMPUTE_MAX_SUM_STATS
56 int64_t avg_time = node.exec_stats.size() == 0 ? 0 :
57 agg_stats.latency_ns / node.exec_stats.size();
60 stringstream label_ss;
61 if (indent_level != 0) {
63 for (
int i = 0; i < indent_level - 1; ++i) {
66 label_ss << (new_indent_level ?
"--" :
" ");
69 label_ss << node.label;
72 row.push_back(label_ss.str());
73 row.push_back(lexical_cast<string>(node.exec_stats.size()));
77 node.is_broadcast ? max_stats.cardinality : agg_stats.cardinality,
84 result->push_back(row);
86 map<int, int>::const_iterator child_fragment_idx_it =
87 exec_summary.exch_to_sender_map.find(*node_idx);
88 if (child_fragment_idx_it != exec_summary.exch_to_sender_map.end()) {
89 DCHECK_EQ(node.num_children, 0);
90 int child_fragment_id = child_fragment_idx_it->second;
91 PrintExecSummary(exec_summary, indent_level,
false, &child_fragment_id, result);
94 if (node.num_children == 0)
return;
97 vector<vector<string> > child0_result;
98 PrintExecSummary(exec_summary, indent_level,
false, node_idx, &child0_result);
100 for (
int i = 1; i < node.num_children; ++i) {
103 for (
int i = 0; i < child0_result.size(); ++i) {
104 result->push_back(child0_result[i]);
110 if (!exec_summary.__isset.nodes)
return "";
121 printer.
AddColumn(
"Est. Peak Mem",
false);
124 vector<vector<string> > rows;
127 for (
int i = 0; i < rows.size(); ++i) {
std::string RedactCopy(const std::string &original)
Utility function to redacted a string without modifying the original.
#define COMPUTE_MAX_SUM_STATS(NAME)
std::string ToString(const std::string &prefix="") const
Print to a table with prefix coming before the output.
static std::string Print(bool value, TUnit::type ignored, bool verbose=false)
void AddColumn(const std::string &label, bool left_align)
std::string PrintExecSummary(const TExecSummary &exec_summary)
Print the exec summary as a formatted table.
const TExecSummary & exec_summary() const
void AddRow(const std::vector< std::string > &row)
Add a row to the table. This must have the same width as labels.
void set_max_output_width(int width)