MCPcopy Create free account
hub / github.com/apache/impala / ExecStatsToJsonHelper

Function ExecStatsToJsonHelper

be/src/service/impala-http-handler.cc:1143–1177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1141namespace {
1142
1143void ExecStatsToJsonHelper(
1144 const TPlanNodeExecSummary& summary, rapidjson::Document* document, Value* value) {
1145 int64_t cardinality = 0;
1146 int64_t max_time = 0;
1147 int64_t total_time = 0;
1148 for (const TExecStats& stat : summary.exec_stats) {
1149 if (summary.is_broadcast) {
1150 // Avoid multiple-counting for recipients of broadcasts.
1151 cardinality = ::max(cardinality, stat.cardinality);
1152 } else {
1153 cardinality += stat.cardinality;
1154 }
1155 total_time += stat.latency_ns;
1156 max_time = ::max(max_time, stat.latency_ns);
1157 }
1158 value->AddMember("output_card", cardinality, document->GetAllocator());
1159 value->AddMember("num_instances", static_cast<uint64_t>(summary.exec_stats.size()),
1160 document->GetAllocator());
1161 if (summary.is_broadcast) {
1162 value->AddMember("is_broadcast", true, document->GetAllocator());
1163 }
1164
1165 const string& max_time_str = PrettyPrinter::Print(max_time, TUnit::TIME_NS);
1166 Value max_time_str_json(max_time_str, document->GetAllocator());
1167 value->AddMember("max_time", max_time_str_json, document->GetAllocator());
1168 value->AddMember("max_time_val", max_time, document->GetAllocator());
1169
1170 // Round to the nearest ns, to workaround a bug in pretty-printing a fraction of a
1171 // ns. See IMPALA-1800.
1172 const string& avg_time_str = PrettyPrinter::Print(
1173 // A bug may occasionally cause 1-instance nodes to appear to have 0 instances.
1174 total_time / ::max(static_cast<int>(summary.exec_stats.size()), 1), TUnit::TIME_NS);
1175 Value avg_time_str_json(avg_time_str, document->GetAllocator());
1176 value->AddMember("avg_time", avg_time_str_json, document->GetAllocator());
1177}
1178
1179// Helper for PlanToJson(), processes a single list of plan nodes which are the
1180// DFS-flattened representation of a single plan fragment. Called recursively, the

Callers 2

PlanToJsonHelperFunction · 0.85
SinkToJsonHelperFunction · 0.85

Calls 3

maxFunction · 0.85
AddMemberMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected