| 1004 | } |
| 1005 | |
| 1006 | void FixTabletGap(std::map<std::string, std::pair<std::string, std::string>>& map_scan, |
| 1007 | const std::vector<std::string>& fail_tablet, const std::string& table_name, |
| 1008 | uint64_t tablet_num) { |
| 1009 | uint32_t index = 0; |
| 1010 | bool table_start = true; |
| 1011 | std::string path_gap; |
| 1012 | std::pair<std::string, std::string> keyrange_scan; |
| 1013 | |
| 1014 | auto it = map_scan.begin(); |
| 1015 | |
| 1016 | if (map_scan.size() == 1) { |
| 1017 | // start not - |
| 1018 | if (!it->first.empty()) { |
| 1019 | path_gap = table_name + "/" + GetTabletName(fail_tablet, index, tablet_num); |
| 1020 | keyrange_scan = make_pair(it->first, path_gap); |
| 1021 | map_scan.insert(make_pair("", keyrange_scan)); |
| 1022 | } |
| 1023 | // end not - |
| 1024 | if (!it->second.first.empty()) { |
| 1025 | path_gap = table_name + "/" + GetTabletName(fail_tablet, index, tablet_num); |
| 1026 | keyrange_scan = make_pair("", path_gap); |
| 1027 | map_scan.insert(make_pair(it->second.first, keyrange_scan)); |
| 1028 | } |
| 1029 | return; |
| 1030 | } |
| 1031 | |
| 1032 | while (it != map_scan.end()) { |
| 1033 | // it_pre->first always < it->first |
| 1034 | auto it_pre = it; |
| 1035 | ++it; |
| 1036 | if (it != map_scan.end()) { |
| 1037 | if (table_start) { // start not - |
| 1038 | table_start = false; |
| 1039 | if (!it_pre->first.empty()) { |
| 1040 | path_gap = table_name + "/" + GetTabletName(fail_tablet, index, tablet_num); |
| 1041 | keyrange_scan = make_pair(it_pre->first, path_gap); |
| 1042 | map_scan.insert(make_pair("", keyrange_scan)); |
| 1043 | } |
| 1044 | } |
| 1045 | /************* fix the gap ******************* |
| 1046 | * <it->first, <it->second.first, it->second.second>> |
| 1047 | * <startkey, <endkey, path>> |
| 1048 | * |
| 1049 | * it_pre |------) |
| 1050 | * it |------) |
| 1051 | * ---------------------------------- |
| 1052 | * new |---------) |
| 1053 | */ |
| 1054 | if (it->first > it_pre->second.first) { |
| 1055 | path_gap = table_name + "/" + GetTabletName(fail_tablet, index, tablet_num); |
| 1056 | keyrange_scan = make_pair(it->first, path_gap); |
| 1057 | map_scan.insert(make_pair(it_pre->second.first, keyrange_scan)); |
| 1058 | |
| 1059 | LOG(INFO) << "gap - path:" << path_gap << "startkey" << it_pre->second.first << "endkey" |
| 1060 | << it->first; |
| 1061 | } |
| 1062 | } else { // end not - |
| 1063 | if (!it_pre->second.first.empty()) { |
no test coverage detected