| 606 | } |
| 607 | |
| 608 | Value QueryProfileToolAccessor::GetSpecificOperator(string_view node_id, |
| 609 | string_view fragment_id, string_view instance_id, |
| 610 | Document::AllocatorType& alloc) const { |
| 611 | Value all = GetAllOperators(node_id, fragment_id, alloc); |
| 612 | if (!all.IsArray() || all.Empty()) { |
| 613 | Value err(rapidjson::kObjectType); |
| 614 | err.AddMember(Value(ERROR_KEY, alloc), Value("operator not found", alloc), alloc); |
| 615 | return err; |
| 616 | } |
| 617 | if (instance_id.empty()) { |
| 618 | return Value(move(all.GetArray()[0])); |
| 619 | } |
| 620 | for (auto& row : all.GetArray()) { |
| 621 | if (!row.IsObject() || !row.HasMember("instance") |
| 622 | || !row["instance"].IsString()) { |
| 623 | continue; |
| 624 | } |
| 625 | const Value& instance_value = row["instance"]; |
| 626 | const string_view instance( |
| 627 | instance_value.GetString(), instance_value.GetStringLength()); |
| 628 | if (instance.find(instance_id) != string::npos) return Value(move(row)); |
| 629 | } |
| 630 | Value err(rapidjson::kObjectType); |
| 631 | err.AddMember( |
| 632 | Value(ERROR_KEY, alloc), |
| 633 | Value("specific operator instance not found", alloc), alloc); |
| 634 | return err; |
| 635 | } |
| 636 | |
| 637 | // Returns compact metrics for scan nodes across fragments. |
| 638 | Value QueryProfileToolAccessor::GetScanNodesSummary( |