OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LRUEvictionAlgorithm Class Reference

#include <LRUEvictionAlgorithm.h>

+ Inheritance diagram for LRUEvictionAlgorithm:
+ Collaboration diagram for LRUEvictionAlgorithm:

Public Member Functions

 ~LRUEvictionAlgorithm () override
 
const ChunkKey evictNextChunk () override
 
void touchChunk (const ChunkKey &) override
 
void removeChunk (const ChunkKey &) override
 
std::string dumpEvictionQueue ()
 
- Public Member Functions inherited from CacheEvictionAlgorithm
virtual ~CacheEvictionAlgorithm ()
 

Private Attributes

std::list< ChunkKeycache_items_list_
 
std::map< const ChunkKey,
std::list< ChunkKey >
::iterator > 
cache_items_map_
 
heavyai::shared_mutex cache_mutex_
 

Detailed Description

Definition at line 39 of file LRUEvictionAlgorithm.h.

Constructor & Destructor Documentation

LRUEvictionAlgorithm::~LRUEvictionAlgorithm ( )
inlineoverride

Definition at line 41 of file LRUEvictionAlgorithm.h.

41 {}

Member Function Documentation

std::string LRUEvictionAlgorithm::dumpEvictionQueue ( )

Definition at line 59 of file LRUEvictionAlgorithm.cpp.

References cache_items_list_, cache_mutex_, and show_chunk().

Referenced by File_Namespace::CachingFileMgr::dump(), File_Namespace::CachingFileMgr::dumpEvictionQueue(), and File_Namespace::CachingFileMgr::dumpTableQueue().

59  {
61  std::string ret = "Eviction queue:\n{";
62  for (auto chunk : cache_items_list_) {
63  ret += show_chunk(chunk) + ", ";
64  }
65  ret += "}\n";
66  return ret;
67 }
heavyai::shared_mutex cache_mutex_
std::list< ChunkKey > cache_items_list_
std::string show_chunk(const ChunkKey &key)
Definition: types.h:98
std::shared_lock< T > shared_lock

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const ChunkKey LRUEvictionAlgorithm::evictNextChunk ( )
overridevirtual

Implements CacheEvictionAlgorithm.

Definition at line 27 of file LRUEvictionAlgorithm.cpp.

References cache_items_list_, cache_items_map_, cache_mutex_, and CHECK.

Referenced by anonymous_namespace{CachingFileMgr.cpp}::evict_chunk_or_fail().

27  {
29  if (cache_items_list_.size() < 1) {
30  throw NoEntryFoundException();
31  }
32  auto last = cache_items_list_.back();
33  CHECK(cache_items_map_.erase(last) > 0) << "Chunk not evicted!";
34  cache_items_list_.pop_back();
35  return last;
36 }
heavyai::shared_mutex cache_mutex_
std::list< ChunkKey > cache_items_list_
std::map< const ChunkKey, std::list< ChunkKey >::iterator > cache_items_map_
std::unique_lock< T > unique_lock
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

void LRUEvictionAlgorithm::removeChunk ( const ChunkKey key)
overridevirtual

Implements CacheEvictionAlgorithm.

Definition at line 49 of file LRUEvictionAlgorithm.cpp.

References cache_items_list_, cache_items_map_, and cache_mutex_.

49  {
51  auto it = cache_items_map_.find(key);
52  if (it == cache_items_map_.end()) {
53  return;
54  }
55  cache_items_list_.erase(it->second);
56  cache_items_map_.erase(key);
57 }
heavyai::shared_mutex cache_mutex_
std::list< ChunkKey > cache_items_list_
std::map< const ChunkKey, std::list< ChunkKey >::iterator > cache_items_map_
std::unique_lock< T > unique_lock
void LRUEvictionAlgorithm::touchChunk ( const ChunkKey key)
overridevirtual

Implements CacheEvictionAlgorithm.

Definition at line 38 of file LRUEvictionAlgorithm.cpp.

References cache_items_list_, cache_items_map_, and cache_mutex_.

38  {
40  auto it = cache_items_map_.find(key);
41  if (it != cache_items_map_.end()) {
42  cache_items_list_.erase(it->second);
43  cache_items_map_.erase(it);
44  }
45  cache_items_list_.emplace_front(key);
46  cache_items_map_[key] = cache_items_list_.begin();
47 }
heavyai::shared_mutex cache_mutex_
std::list< ChunkKey > cache_items_list_
std::map< const ChunkKey, std::list< ChunkKey >::iterator > cache_items_map_
std::unique_lock< T > unique_lock

Member Data Documentation

std::list<ChunkKey> LRUEvictionAlgorithm::cache_items_list_
private

Definition at line 52 of file LRUEvictionAlgorithm.h.

Referenced by dumpEvictionQueue(), evictNextChunk(), removeChunk(), and touchChunk().

std::map<const ChunkKey, std::list<ChunkKey>::iterator> LRUEvictionAlgorithm::cache_items_map_
private

Definition at line 53 of file LRUEvictionAlgorithm.h.

Referenced by evictNextChunk(), removeChunk(), and touchChunk().

heavyai::shared_mutex LRUEvictionAlgorithm::cache_mutex_
mutableprivate

Definition at line 54 of file LRUEvictionAlgorithm.h.

Referenced by dumpEvictionQueue(), evictNextChunk(), removeChunk(), and touchChunk().


The documentation for this class was generated from the following files: