OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LRUEvictionAlgorithm.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021 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 
31 #pragma once
32 
33 #include <cstddef>
34 #include <list>
35 #include "CacheEvictionAlgorithm.h"
37 
39  public:
40  ~LRUEvictionAlgorithm() override {}
41  // Returns the next chunk to evict and evicts.
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_;
54 };
std::vector< int > ChunkKey
Definition: types.h:37
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_
mapd_shared_mutex cache_mutex_
void removeChunk(const ChunkKey &) override
std::shared_timed_mutex mapd_shared_mutex