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

Method ToJsonHelper

be/src/util/runtime-profile.cc:1291–1370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1289}
1290
1291void RuntimeProfileBase::ToJsonHelper(
1292 Verbosity verbosity, Value* parent, Document* d) const {
1293 Document::AllocatorType& allocator = d->GetAllocator();
1294 // Create copy of counter_map_ and child_counter_map_ so we don't need to hold lock
1295 // while we call value() on the counters (some of those might be DerivedCounters).
1296 CounterMap counter_map;
1297 ChildCounterMap child_counter_map;
1298 {
1299 lock_guard<SpinLock> l(counter_map_lock_);
1300 counter_map = counter_map_;
1301 child_counter_map = child_counter_map_;
1302 }
1303
1304 // 1. Name
1305 parent->AddMember("profile_name", name_, allocator);
1306
1307 // 2. Num_children
1308 parent->AddMember("num_children", children_.size(), allocator);
1309
1310 // 3. Metadata
1311 if (metadata_.__isset.plan_node_id || metadata_.__isset.data_sink_id){
1312 Value node_metadata_json(kObjectType);
1313 if (metadata_.__isset.plan_node_id){
1314 node_metadata_json.AddMember("plan_node_id", metadata_.plan_node_id, allocator);
1315 }
1316 if (metadata_.__isset.data_sink_id){
1317 node_metadata_json.AddMember("data_sink_id", metadata_.data_sink_id, allocator);
1318 }
1319 parent->AddMember("node_metadata", node_metadata_json, allocator);
1320 }
1321
1322 // 4. Info strings
1323 // TODO: IMPALA-9846: move to subclass once 'info_strings_' is also moved
1324 {
1325 lock_guard<SpinLock> l(info_strings_lock_);
1326 if (!info_strings_.empty()) {
1327 Value info_strings_json(kArrayType);
1328 for (const string& key : info_strings_display_order_) {
1329 Value info_string_json(kObjectType);
1330 auto value_itr = info_strings_.find(key);
1331 DCHECK(value_itr != info_strings_.end());
1332 info_string_json.AddMember("key", key, allocator);
1333 info_string_json.AddMember("value", value_itr->second, allocator);
1334 info_strings_json.PushBack(info_string_json, allocator);
1335 }
1336 parent->AddMember("info_strings", info_strings_json, allocator);
1337 }
1338 }
1339
1340 // 5. Counters and info strings from subclasses
1341 ToJsonSubclass(verbosity, parent, d);
1342
1343 // 6. Counters
1344 Value counters(kArrayType);
1345 ToJsonCounters(verbosity, &counters, d, ROOT_COUNTER, counter_map, child_counter_map);
1346 if (!counters.Empty()) {
1347 parent->AddMember("counters", counters, allocator);
1348 }

Callers 1

SetUpMethod · 0.80

Calls 7

PushBackMethod · 0.80
AddMemberMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
EmptyMethod · 0.45

Tested by 1

SetUpMethod · 0.64