| 1090 | } |
| 1091 | |
| 1092 | int LoadTablesMapFile(const std::string& file_name, std::map<std::string, std::string>* tables_map, |
| 1093 | std::map<std::string, std::string>* tables_lg_map) { |
| 1094 | std::fstream fin(file_name.c_str()); |
| 1095 | std::string line; |
| 1096 | while (getline(fin, line)) { |
| 1097 | // line format : |
| 1098 | // test1,test2 |
| 1099 | // test3:lg1|lg2|lg3,test5:lg1|lg2|lg3 |
| 1100 | std::vector<std::string> tables; |
| 1101 | std::string delimiter(","); |
| 1102 | SplitString(line, delimiter, &tables); |
| 1103 | if (tables.size() != 2) { |
| 1104 | return -1; |
| 1105 | } |
| 1106 | if (tables_map->find(tables[0]) != tables_map->end()) { |
| 1107 | LOG(WARNING) << "Reduplicative table name"; |
| 1108 | return -1; |
| 1109 | } |
| 1110 | std::string src_table = tables[0]; |
| 1111 | std::string dest_table = tables[1]; |
| 1112 | std::string lg_delimiter(":"); |
| 1113 | std::size_t pos = src_table.find(lg_delimiter); |
| 1114 | if (pos != std::string::npos) { |
| 1115 | std::string src_table_no_lg = src_table.substr(0, pos); |
| 1116 | std::string lg = src_table.substr(pos + 1); |
| 1117 | |
| 1118 | pos = dest_table.find(lg_delimiter); |
| 1119 | if (pos == std::string::npos) { |
| 1120 | LOG(WARNING) << "Wrong arguement in specifing lg"; |
| 1121 | return -1; |
| 1122 | } |
| 1123 | std::string dest_table_no_lg = dest_table.substr(0, pos); |
| 1124 | std::string dest_lg = dest_table.substr(pos + 1); |
| 1125 | if (lg != dest_lg) { |
| 1126 | LOG(WARNING) << "Mismatch lg in src_table & dest_table is forbidden"; |
| 1127 | return -1; |
| 1128 | } |
| 1129 | (*tables_map)[src_table_no_lg] = dest_table_no_lg; |
| 1130 | (*tables_lg_map)[src_table_no_lg] = lg; |
| 1131 | } else { |
| 1132 | (*tables_map)[src_table] = dest_table; |
| 1133 | } |
| 1134 | } |
| 1135 | return 0; |
| 1136 | } |
| 1137 | |
| 1138 | int CheckTablesMapSensible(const TableMetaList& src_table_list, |
| 1139 | const TableMetaList& dest_table_list, |
no test coverage detected