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;
|
std::string toString() const;
|
||||||
|
|
||||||
|
FileCacheKey() = default;
|
||||||
|
|
||||||
explicit FileCacheKey(const std::string & path);
|
explicit FileCacheKey(const std::string & path);
|
||||||
|
|
||||||
explicit FileCacheKey(const UInt128 & key_);
|
explicit FileCacheKey(const UInt128 & key_);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <Interpreters/Cache/FileCacheKey.h>
|
#include <Interpreters/Cache/FileCacheKey.h>
|
||||||
#include <Interpreters/Cache/CacheMetadata.h>
|
#include <Interpreters/Cache/CacheMetadata.h>
|
||||||
#include <Interpreters/Cache/Guards.h>
|
#include <Interpreters/Cache/Guards.h>
|
||||||
|
#include <Common/ConcurrentBoundedQueue.h>
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
@ -76,22 +77,20 @@ private:
|
|||||||
|
|
||||||
struct KeysQueue
|
struct KeysQueue
|
||||||
{
|
{
|
||||||
std::unordered_set<FileCacheKey> keys;
|
ConcurrentBoundedQueue<FileCacheKey> keys{100000}; /// TODO: add a setting for the size
|
||||||
std::mutex mutex;
|
|
||||||
|
|
||||||
void add(const FileCacheKey & key)
|
void add(const FileCacheKey & key)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex);
|
[[maybe_unused]] const auto pushed = keys.tryPush(key);
|
||||||
keys.insert(key);
|
chassert(pushed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear(std::function<void(const FileCacheKey &)> && func)
|
void clear(std::function<void(const FileCacheKey &)> && func)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex);
|
FileCacheKey key;
|
||||||
for (auto it = keys.begin(); it != keys.end();)
|
while (keys.tryPop(key))
|
||||||
{
|
{
|
||||||
func(*it);
|
func(key);
|
||||||
it = keys.erase(it);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user