| 1258 | } // unnamed namespace |
| 1259 | |
| 1260 | void impala::PlanToJson(const vector<TPlanFragment>& fragments, |
| 1261 | const TExecSummary& summary, rapidjson::Document* document, Value* value) { |
| 1262 | // Build a map from id to label so that we can resolve the targets of data-stream sinks |
| 1263 | // and connect plan fragments. |
| 1264 | map<TPlanNodeId, string> label_map; |
| 1265 | for (const TPlanFragment& fragment : fragments) { |
| 1266 | for (const TPlanNode& node : fragment.plan.nodes) { |
| 1267 | label_map[node.node_id] = node.label; |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | map<TPlanNodeId, TPlanNodeExecSummary> exec_summaries; |
| 1272 | for (const TPlanNodeExecSummary& s : summary.nodes) { |
| 1273 | // All sink has -1 as node_id, we want to store the summary of the first one (the root |
| 1274 | // of the plan tree) and insert will not overwrite the existing value |
| 1275 | // if the key is already present. |
| 1276 | exec_summaries.insert({s.node_id, s}); |
| 1277 | } |
| 1278 | |
| 1279 | Value nodes(kArrayType); |
| 1280 | for (const TPlanFragment& fragment : fragments) { |
| 1281 | Value plan_fragment(kObjectType); |
| 1282 | vector<TPlanNode>::const_iterator it = fragment.plan.nodes.begin(); |
| 1283 | if (fragment.__isset.output_sink |
| 1284 | && (fragment.output_sink.type == TDataSinkType::type::MERGE_SINK |
| 1285 | || fragment.output_sink.type == TDataSinkType::type::MULTI_DATA_SINK |
| 1286 | || fragment.output_sink.type == TDataSinkType::type::TABLE_SINK)) { |
| 1287 | SinkToJsonHelper( |
| 1288 | fragment.output_sink, exec_summaries, &it, document, &plan_fragment); |
| 1289 | } else { |
| 1290 | PlanToJsonHelper(exec_summaries, &it, document, &plan_fragment); |
| 1291 | if (fragment.__isset.output_sink) { |
| 1292 | const TDataSink& sink = fragment.output_sink; |
| 1293 | if (sink.__isset.stream_sink) { |
| 1294 | Value target( |
| 1295 | label_map[sink.stream_sink.dest_node_id], document->GetAllocator()); |
| 1296 | plan_fragment.AddMember("data_stream_target", target, document->GetAllocator()); |
| 1297 | } else if (sink.__isset.join_build_sink) { |
| 1298 | Value target( |
| 1299 | label_map[sink.join_build_sink.dest_node_id], document->GetAllocator()); |
| 1300 | plan_fragment.AddMember("join_build_target", target, document->GetAllocator()); |
| 1301 | } |
| 1302 | } |
| 1303 | } |
| 1304 | nodes.PushBack(plan_fragment, document->GetAllocator()); |
| 1305 | } |
| 1306 | value->AddMember("plan_nodes", nodes, document->GetAllocator()); |
| 1307 | } |
| 1308 | |
| 1309 | void ImpalaHttpHandler::QueryBackendsHandler( |
| 1310 | const Webserver::WebRequest& req, Document* document) { |
nothing calls this directly
no test coverage detected