mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 19:32:07 +00:00
Fix changes in commit c4be868222
This commit is contained in:
parent
ae9922abe5
commit
5c201698f4
@ -11,6 +11,8 @@ struct FileCacheKey
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
FileCacheKey() = default;
|
||||
|
||||
explicit FileCacheKey(const std::string & path);
|
||||
|
||||
explicit FileCacheKey(const UInt128 & key_);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user