deystroy remote location info
This commit is contained in:
parent
c6544b681c
commit
6d860e829a
@ -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_hash_to_file_id_.rehash(0);
|
||||||
|
|
||||||
file_id_info_.shrink_to_fit();
|
file_id_info_.shrink_to_fit();
|
||||||
|
@ -19,9 +19,29 @@ class Enumerator {
|
|||||||
public:
|
public:
|
||||||
using Key = int32;
|
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) {
|
Key add(ValueT v) {
|
||||||
CHECK(arr_.size() < static_cast<size_t>(std::numeric_limits<int32>::max() - 1));
|
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;
|
bool was_inserted;
|
||||||
decltype(map_.begin()) it;
|
decltype(map_.begin()) it;
|
||||||
std::tie(it, was_inserted) = map_.emplace(std::move(v), next_id);
|
std::tie(it, was_inserted) = map_.emplace(std::move(v), next_id);
|
||||||
@ -38,6 +58,7 @@ class Enumerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::vector<Key> empty_id_;
|
||||||
std::map<ValueT, int32> map_;
|
std::map<ValueT, int32> map_;
|
||||||
std::vector<const ValueT *> arr_;
|
std::vector<const ValueT *> arr_;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user