| 129 | |
| 130 | |
| 131 | comm::RetCode TopicConfig::Rebuild() { |
| 132 | bool need_check = NeedCheck(); |
| 133 | |
| 134 | impl_->pub_id2pub.clear(); |
| 135 | impl_->sub_id2sub.clear(); |
| 136 | impl_->queue_info_id2queue_info.clear(); |
| 137 | impl_->queue_info_id2ranges.clear(); |
| 138 | impl_->queue2queue_info_id.clear(); |
| 139 | impl_->pub_id2sub_ids.clear(); |
| 140 | impl_->pub_id2queue_info_ids.clear(); |
| 141 | impl_->handle_id2rank.clear(); |
| 142 | impl_->freq_infos.clear(); |
| 143 | impl_->replay_infos.clear(); |
| 144 | |
| 145 | auto &&proto = GetProto(); |
| 146 | |
| 147 | for (int i{0}; proto.pubs_size() > i; ++i) { |
| 148 | const auto &pub(proto.pubs(i)); |
| 149 | if (!pub.pub_id()) continue; |
| 150 | if (need_check) PHX_ASSERT(impl_->pub_id2pub.end() == impl_->pub_id2pub.find(pub.pub_id()), ==, true); |
| 151 | impl_->pub_id2pub.emplace(pub.pub_id(), make_shared<proto::Pub>(pub)); |
| 152 | |
| 153 | auto &&sub_ids = impl_->pub_id2sub_ids[pub.pub_id()]; |
| 154 | for (int j{0}; j < pub.sub_ids_size(); ++j) { |
| 155 | if (need_check) PHX_ASSERT(sub_ids.end() == sub_ids.find(pub.sub_ids(j)), ==, true); |
| 156 | sub_ids.insert(pub.sub_ids(j)); |
| 157 | } |
| 158 | |
| 159 | auto &&queue_info_ids = impl_->pub_id2queue_info_ids[pub.pub_id()]; |
| 160 | for (int j{0}; j < pub.queue_info_ids_size(); ++j) { |
| 161 | if (need_check) PHX_ASSERT(queue_info_ids.end() == queue_info_ids.find(pub.queue_info_ids(j)), ==, true); |
| 162 | queue_info_ids.insert(pub.queue_info_ids(j)); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | for (int i{0}; proto.subs_size() > i; ++i) { |
| 167 | const auto &sub(proto.subs(i)); |
| 168 | if (!sub.sub_id()) continue; |
| 169 | if (need_check) PHX_ASSERT(impl_->sub_id2sub.end() == impl_->sub_id2sub.find(sub.sub_id()), ==, true); |
| 170 | impl_->sub_id2sub.emplace(sub.sub_id(), make_shared<proto::Sub>(sub)); |
| 171 | } |
| 172 | |
| 173 | for (int i{0}; proto.queue_infos_size() > i; ++i) { |
| 174 | const auto &queue_info(proto.queue_infos(i)); |
| 175 | |
| 176 | |
| 177 | if (!queue_info.queue_info_id()) continue; |
| 178 | if (need_check) PHX_ASSERT(impl_->queue_info_id2queue_info.end() == impl_->queue_info_id2queue_info.find(queue_info.queue_info_id()), ==, true); |
| 179 | impl_->queue_info_id2queue_info.emplace(queue_info.queue_info_id(), make_shared<proto::QueueInfo>(queue_info)); |
| 180 | |
| 181 | { |
| 182 | auto &&ranges = impl_->queue_info_id2ranges[queue_info.queue_info_id()]; |
| 183 | |
| 184 | for (int j{0}; j < queue_info.ranges_size(); ++j) { |
| 185 | vector<string> arr; |
| 186 | comm::utils::StrSplitList(queue_info.ranges(j).c_str(), "-", arr); |
| 187 | if (2 == arr.size() && stoi(arr[0]) <= stoi(arr[1])) { |
| 188 | ranges.emplace_back(stoi(arr[0]), stoi(arr[1])); |
nothing calls this directly
no test coverage detected