deystroy remote location info

This commit is contained in:
andrew (from workstation) 2020-05-20 19:51:45 +02:00
parent c6544b681c
commit 6d860e829a
2 changed files with 30 additions and 1 deletions

View File

@ -3852,6 +3852,14 @@ void FileManager::memory_cleanup() {
}
}
/* DESTROY INVALID remote_location_info_ */
for (const auto &pair : remote_location_info_.get_map()) {
auto &file = file_id_info_[pair.first.file_id_.fast_get()];
if (file_nodes_[file.node_id_] == nullptr) {
remote_location_info_.erase_map_key(pair.first, pair.second);
}
}
file_hash_to_file_id_.rehash(0);
file_id_info_.shrink_to_fit();

View File

@ -19,9 +19,29 @@ class Enumerator {
public:
using Key = int32;
std::map<ValueT, int32> get_map() const {
return map_;
}
Key next() {
if (!empty_id_.empty()) {
auto res = empty_id_.back();
empty_id_.pop_back();
return res;
}
return arr_.size() + 1;
}
void erase_map_key(ValueT key_x, Key key_y) {
empty_id_.push_back(key_y);
map_.erase(key_x);
arr_[key_y] = nullptr;
}
Key add(ValueT v) {
CHECK(arr_.size() < static_cast<size_t>(std::numeric_limits<int32>::max() - 1));
int32 next_id = static_cast<int32>(arr_.size() + 1);
Key next_id = next();
bool was_inserted;
decltype(map_.begin()) it;
std::tie(it, was_inserted) = map_.emplace(std::move(v), next_id);
@ -38,6 +58,7 @@ class Enumerator {
}
private:
std::vector<Key> empty_id_;
std::map<ValueT, int32> map_;
std::vector<const ValueT *> arr_;
};