mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 18:42:26 +00:00
keeper SnapshotableHashTable clean opt.
This commit is contained in:
parent
34092fa2a3
commit
72ffcbbb05
@ -36,6 +36,7 @@ private:
|
||||
/// Allows to avoid additional copies in updateValue function
|
||||
size_t snapshot_up_to_size = 0;
|
||||
ArenaWithFreeLists arena;
|
||||
std::vector<Mapped> snapshot_invalid_iters{100000};
|
||||
|
||||
uint64_t approximate_data_size{0};
|
||||
|
||||
@ -175,6 +176,7 @@ public:
|
||||
list_itr->active_in_map = false;
|
||||
auto new_list_itr = list.insert(list.end(), elem);
|
||||
it->getMapped() = new_list_itr;
|
||||
snapshot_invalid_iters.push_back(list_itr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -197,6 +199,7 @@ public:
|
||||
list_itr->active_in_map = false;
|
||||
list_itr->free_key = true;
|
||||
map.erase(it->getKey());
|
||||
snapshot_invalid_iters.push_back(list_itr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -239,6 +242,7 @@ public:
|
||||
auto itr = list.insert(list.end(), elem_copy);
|
||||
it->getMapped() = itr;
|
||||
ret = itr;
|
||||
snapshot_invalid_iters.push_back(list_itr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -274,23 +278,15 @@ public:
|
||||
|
||||
void clearOutdatedNodes()
|
||||
{
|
||||
auto start = list.begin();
|
||||
auto end = list.end();
|
||||
for (auto itr = start; itr != end;)
|
||||
for (auto & itr: snapshot_invalid_iters)
|
||||
{
|
||||
if (!itr->active_in_map)
|
||||
{
|
||||
updateDataSize(CLEAR_OUTDATED_NODES, itr->key.size, itr->value.sizeInBytes(), 0);
|
||||
if (itr->free_key)
|
||||
arena.free(const_cast<char *>(itr->key.data), itr->key.size);
|
||||
itr = list.erase(itr);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(!itr->free_key);
|
||||
itr++;
|
||||
}
|
||||
assert(!itr->active_in_map);
|
||||
updateDataSize(CLEAR_OUTDATED_NODES, itr->key.size, itr->value.sizeInBytes(), 0);
|
||||
if (itr->free_key)
|
||||
arena.free(const_cast<char *>(itr->key.data), itr->key.size);
|
||||
list.erase(itr);
|
||||
}
|
||||
snapshot_invalid_iters.clear();
|
||||
}
|
||||
|
||||
void clear()
|
||||
@ -300,12 +296,14 @@ public:
|
||||
arena.free(const_cast<char *>(itr->key.data), itr->key.size);
|
||||
list.clear();
|
||||
updateDataSize(CLEAR, 0, 0, 0);
|
||||
snapshot_invalid_iters.clear();
|
||||
}
|
||||
|
||||
void enableSnapshotMode(size_t up_to_size)
|
||||
{
|
||||
snapshot_mode = true;
|
||||
snapshot_up_to_size = up_to_size;
|
||||
snapshot_invalid_iters.clear();
|
||||
}
|
||||
|
||||
void disableSnapshotMode()
|
||||
|
Loading…
Reference in New Issue
Block a user