| 671 | }; |
| 672 | |
| 673 | OpenDatabaseRequest ClientData::getRequest() { |
| 674 | OpenDatabaseRequest req; |
| 675 | |
| 676 | std::map<StringRef, ClientStatusStats> issueMap; |
| 677 | std::map<ClientVersionRef, ClientStatusStats> versionMap; |
| 678 | std::map<StringRef, ClientStatusStats> maxProtocolMap; |
| 679 | int clientCount = 0; |
| 680 | |
| 681 | // SOMEDAY: add a yield in this loop |
| 682 | for (auto& ci : clientStatusInfoMap) { |
| 683 | for (auto& it : ci.second.issues) { |
| 684 | auto& entry = issueMap[it]; |
| 685 | entry.count++; |
| 686 | if (entry.examples.size() < CLIENT_KNOBS->CLIENT_EXAMPLE_AMOUNT) { |
| 687 | entry.examples.emplace_back(ci.first, ci.second.traceLogGroup); |
| 688 | } |
| 689 | } |
| 690 | if (ci.second.versions.size()) { |
| 691 | clientCount++; |
| 692 | StringRef maxProtocol; |
| 693 | for (auto& it : ci.second.versions) { |
| 694 | maxProtocol = std::max(maxProtocol, it.protocolVersion); |
| 695 | auto& entry = versionMap[it]; |
| 696 | entry.count++; |
| 697 | if (entry.examples.size() < CLIENT_KNOBS->CLIENT_EXAMPLE_AMOUNT) { |
| 698 | entry.examples.emplace_back(ci.first, ci.second.traceLogGroup); |
| 699 | } |
| 700 | } |
| 701 | auto& maxEntry = maxProtocolMap[maxProtocol]; |
| 702 | maxEntry.count++; |
| 703 | if (maxEntry.examples.size() < CLIENT_KNOBS->CLIENT_EXAMPLE_AMOUNT) { |
| 704 | maxEntry.examples.emplace_back(ci.first, ci.second.traceLogGroup); |
| 705 | } |
| 706 | } else { |
| 707 | auto& entry = versionMap[ClientVersionRef()]; |
| 708 | entry.count++; |
| 709 | if (entry.examples.size() < CLIENT_KNOBS->CLIENT_EXAMPLE_AMOUNT) { |
| 710 | entry.examples.emplace_back(ci.first, ci.second.traceLogGroup); |
| 711 | } |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | req.issues.reserve(issueMap.size()); |
| 716 | for (auto& it : issueMap) { |
| 717 | req.issues.push_back(ItemWithExamples<Key>(it.first, it.second.count, it.second.examples)); |
| 718 | } |
| 719 | req.supportedVersions.reserve(versionMap.size()); |
| 720 | for (auto& it : versionMap) { |
| 721 | req.supportedVersions.push_back( |
| 722 | ItemWithExamples<Standalone<ClientVersionRef>>(it.first, it.second.count, it.second.examples)); |
| 723 | } |
| 724 | req.maxProtocolSupported.reserve(maxProtocolMap.size()); |
| 725 | for (auto& it : maxProtocolMap) { |
| 726 | req.maxProtocolSupported.push_back(ItemWithExamples<Key>(it.first, it.second.count, it.second.examples)); |
| 727 | } |
| 728 | req.clientCount = clientCount; |
| 729 | |
| 730 | return req; |
no test coverage detected