Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoupling local cache function and cache algorithm #38048

Merged
Prev Previous commit
Next Next commit
add note
  • Loading branch information
KinderRiven committed Aug 10, 2022
commit 61b580aba449a7d7bb756659c287c3f8fbfc2564
5 changes: 2 additions & 3 deletions src/Common/FileCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
namespace DB
{

/**
* Local cache for remote filesystem files, represented as a set of non-overlapping non-empty file segments.
*/
/// Local cache for remote filesystem files, represented as a set of non-overlapping non-empty file segments.
/// Different caching algorithms are implemented based on IFileCachePriority.
class FileCache : private boost::noncopyable
{
friend class FileSegment;
Expand Down
3 changes: 3 additions & 0 deletions src/Common/IFileCachePriority.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class IFileCachePriority

virtual size_t hits() const = 0;

/// Point the iterator to the next higher priority cache record.
virtual void next() const = 0;

virtual bool valid() const = 0;
Expand All @@ -72,6 +73,8 @@ class IFileCachePriority
/// Deletes an existing cached record.
virtual void remove(std::lock_guard<std::mutex> &) = 0;

/// Get an iterator to handle write operations. Write iterators should only
/// be allowed to call remove, use and incrementSize methods.
virtual WriteIterator getWriteIterator() const = 0;

virtual void incrementSize(size_t, std::lock_guard<std::mutex> &) = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/Common/LRUFileCachePriority.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace DB
{

/// Based on the LRU algorithm implementation, the data with the lowest priority is stored at
/// the head of the queue, and the data with the highest priority is stored at the tail.
/// Based on the LRU algorithm implementation, the record with the lowest priority is stored at
/// the head of the queue, and the record with the highest priority is stored at the tail.
class LRUFileCachePriority : public IFileCachePriority
{
public:
Expand Down