OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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_
 

Detailed Description

Definition at line 38 of file LRUEvictionAlgorithm.h.

Constructor & Destructor Documentation

LRUEvictionAlgorithm::~LRUEvictionAlgorithm ( )
inlineoverride

Definition at line 40 of file LRUEvictionAlgorithm.h.

40 {}

Member Function Documentation

std::string LRUEvictionAlgorithm::dumpEvictionQueue ( )

Definition at line 56 of file LRUEvictionAlgorithm.cpp.

References cache_items_list_, and show_chunk().

56  {
57  std::string ret = "Eviction queue:\n{";
58  for (auto chunk : cache_items_list_)
59  ret += show_chunk(chunk) + ", ";
60  ret += "}\n";
61  return ret;
62 }
std::list< ChunkKey > cache_items_list_
std::string show_chunk(const ChunkKey &key)
Definition: types.h:73

+ Here is the call graph for this function:

const ChunkKey LRUEvictionAlgorithm::evictNextChunk ( )
overridevirtual

Implements CacheEvictionAlgorithm.

Definition at line 27 of file LRUEvictionAlgorithm.cpp.

References cache_items_list_, and cache_items_map_.

27  {
28  if (cache_items_list_.size() < 1)
29  throw NoEntryFoundException();
30  auto last = cache_items_list_.end();
31  last--;
32  cache_items_map_.erase(*last);
33  const ChunkKey ret = cache_items_list_.back();
34  cache_items_list_.pop_back();
35  return ret;
36 }
std::vector< int > ChunkKey
Definition: types.h:37
std::list< ChunkKey > cache_items_list_
std::map< const ChunkKey, std::list< ChunkKey >::iterator > cache_items_map_
void LRUEvictionAlgorithm::removeChunk ( const ChunkKey key)
overridevirtual

Implements CacheEvictionAlgorithm.

Definition at line 48 of file LRUEvictionAlgorithm.cpp.

References cache_items_list_, and cache_items_map_.

48  {
49  auto it = cache_items_map_.find(key);
50  if (it == cache_items_map_.end())
51  return;
52  cache_items_list_.erase(it->second);
53  cache_items_map_.erase(key);
54 }
std::list< ChunkKey > cache_items_list_
std::map< const ChunkKey, std::list< ChunkKey >::iterator > cache_items_map_
void LRUEvictionAlgorithm::touchChunk ( const ChunkKey key)
overridevirtual

Implements CacheEvictionAlgorithm.

Definition at line 38 of file LRUEvictionAlgorithm.cpp.

References cache_items_list_, and cache_items_map_.

38  {
39  auto it = cache_items_map_.find(key);
40  cache_items_list_.emplace_front(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_map_[key] = cache_items_list_.begin();
46 }
std::list< ChunkKey > cache_items_list_
std::map< const ChunkKey, std::list< ChunkKey >::iterator > cache_items_map_

Member Data Documentation

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

Definition at line 51 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 52 of file LRUEvictionAlgorithm.h.

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


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