Fix changes in commit c4be868222

This commit is contained in:
kssenii 2023-02-07 16:50:55 +01:00
parent ae9922abe5
commit 5c201698f4
2 changed files with 9 additions and 8 deletions

View File

@ -11,6 +11,8 @@ struct FileCacheKey
std::string toString() const;
FileCacheKey() = default;
explicit FileCacheKey(const std::string & path);
explicit FileCacheKey(const UInt128 & key_);

View File

@ -2,6 +2,7 @@
#include <Interpreters/Cache/FileCacheKey.h>
#include <Interpreters/Cache/CacheMetadata.h>
#include <Interpreters/Cache/Guards.h>
#include <Common/ConcurrentBoundedQueue.h>
namespace DB
{
@ -76,22 +77,20 @@ private:
struct KeysQueue
{
std::unordered_set<FileCacheKey> keys;
std::mutex mutex;
ConcurrentBoundedQueue<FileCacheKey> keys{100000}; /// TODO: add a setting for the size
void add(const FileCacheKey & key)
{
std::lock_guard lock(mutex);
keys.insert(key);
[[maybe_unused]] const auto pushed = keys.tryPush(key);
chassert(pushed);
}
void clear(std::function<void(const FileCacheKey &)> && func)
{
std::lock_guard lock(mutex);
for (auto it = keys.begin(); it != keys.end();)
FileCacheKey key;
while (keys.tryPop(key))
{
func(*it);
it = keys.erase(it);
func(key);
}
}
};