This commit is contained in:
KinderRiven 2022-06-05 16:52:01 +08:00
parent 3ffb0b3549
commit cb9927cd00
3 changed files with 1 additions and 138 deletions

View File

@ -497,7 +497,7 @@ bool LRUFileCache::tryReserve(const Key & key, size_t offset, size_t size, std::
if (res == ReserveResult::NO_ENOUGH_SPACE)
{
/// The query currently does not have enough space to reserve.
/// It returns false and reads data directly from the remote end.
/// It returns false and reads data directly from the remote fs.
return false;
}
else if (res == ReserveResult::NO_NEED)

View File

@ -1,89 +0,0 @@
#include "MultilevelFileCacheWrapper.h"
namespace DB
{
namespace ErrorCodes
{
extern const int NOT_IMPLEMENTED;
}
MultiplelevelFileCacheWarpper::MultiplelevelFileCacheWarpper(
const String & cache_base_path_, const FileCacheSettings & cache_settings_, FileCachePtr cache_)
: IFileCache(cache_base_path_, cache_settings_), cache(cache_)
{
}
void MultiplelevelFileCacheWarpper::initialize()
{
cache->initialize();
}
void MultiplelevelFileCacheWarpper::remove(const Key & key)
{
cache->remove(key);
}
std::vector<String> MultiplelevelFileCacheWarpper::tryGetCachePaths(const Key & key)
{
return cache->tryGetCachePaths(key);
}
FileSegmentsHolder MultiplelevelFileCacheWarpper::getOrSet(const Key & key, size_t offset, size_t size)
{
return cache->getOrSet(key, offset, size);
}
FileSegmentsHolder MultiplelevelFileCacheWarpper::get(const Key & key, size_t offset, size_t size)
{
return cache->get(key, offset, size);
}
FileSegmentsHolder MultiplelevelFileCacheWarpper::setDownloading(const Key & key, size_t offset, size_t size)
{
return cache->setDownloading(key, offset, size);
}
FileSegments MultiplelevelFileCacheWarpper::getSnapshot() const
{
return cache->getSnapshot();
}
String MultiplelevelFileCacheWarpper::dumpStructure(const Key & key)
{
return cache->dumpStructure(key);
}
size_t MultiplelevelFileCacheWarpper::getUsedCacheSize() const
{
return cache->getUsedCacheSize();
}
size_t MultiplelevelFileCacheWarpper::getFileSegmentsNum() const
{
return cache->getFileSegmentsNum();
}
bool MultiplelevelFileCacheWarpper::tryReserve(const Key &, size_t, size_t, std::lock_guard<std::mutex> &)
{
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "tryReserve not implemented");
}
void MultiplelevelFileCacheWarpper::remove(Key, size_t, std::lock_guard<std::mutex> &, std::lock_guard<std::mutex> &)
{
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "remove");
}
bool MultiplelevelFileCacheWarpper::isLastFileSegmentHolder(
const Key &, size_t, std::lock_guard<std::mutex> &, std::lock_guard<std::mutex> &)
{
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "isLastFileSegmentHolder");
}
void MultiplelevelFileCacheWarpper::reduceSizeToDownloaded(
const Key &, size_t, std::lock_guard<std::mutex> &, std::lock_guard<std::mutex> &)
{
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "reduceSizeToDownloaded");
}
};

View File

@ -1,48 +0,0 @@
#pragma once
#include "FileCache.h"
namespace DB
{
class MultiplelevelFileCacheWarpper : public IFileCache
{
public:
MultiplelevelFileCacheWarpper(const String & cache_base_path_, const FileCacheSettings & cache_settings_, FileCachePtr cache_);
void initialize() override;
void remove(const Key & key) override;
std::vector<String> tryGetCachePaths(const Key & key) override;
FileSegmentsHolder getOrSet(const Key & key, size_t offset, size_t size) override;
FileSegmentsHolder get(const Key & key, size_t offset, size_t size) override;
FileSegmentsHolder setDownloading(const Key & key, size_t offset, size_t size) override;
FileSegments getSnapshot() const override;
String dumpStructure(const Key & key) override;
size_t getUsedCacheSize() const override;
size_t getFileSegmentsNum() const override;
private:
bool tryReserve(const Key & key, size_t offset, size_t size, std::lock_guard<std::mutex> & cache_lock) override;
void remove(Key key, size_t offset, std::lock_guard<std::mutex> & cache_lock, std::lock_guard<std::mutex> & segment_lock) override;
bool isLastFileSegmentHolder(
const Key & key, size_t offset, std::lock_guard<std::mutex> & cache_lock, std::lock_guard<std::mutex> & segment_lock) override;
void reduceSizeToDownloaded(
const Key & key, size_t offset, std::lock_guard<std::mutex> & cache_lock, std::lock_guard<std::mutex> & segment_lock) override;
private:
FileCachePtr cache;
};
};