OmniSciDB  2e3a973ef4
LRUEvictionAlgorithm.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
32 #pragma once
33 
34 #include <cstddef>
35 #include <list>
36 #include "CacheEvictionAlgorithm.h"
37 
39  public:
40  ~LRUEvictionAlgorithm() override {}
41  // Returns the next chunk to evict.
42  const ChunkKey evictNextChunk() override;
43  // Update the algorithm knowing that this chunk was recently touched by the system.
44  void touchChunk(const ChunkKey&) override;
45  // Removes a chunk from the eviction queue if present.
46  void removeChunk(const ChunkKey&) override;
47  // Used for debugging.
48  std::string dumpEvictionQueue();
49 
50  private:
51  std::list<ChunkKey> cache_items_list_;
52  std::map<const ChunkKey, std::list<ChunkKey>::iterator> cache_items_map_;
53 };
std::list< ChunkKey > cache_items_list_
const ChunkKey evictNextChunk() override
void touchChunk(const ChunkKey &) override
std::map< const ChunkKey, std::list< ChunkKey >::iterator > cache_items_map_
void removeChunk(const ChunkKey &) override
std::vector< int > ChunkKey
Definition: types.h:37