OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HashingSchemeRecycler.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, 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 
17 #pragma once
18 
19 #include "DataRecycler.h"
20 
23 
25  : public DataRecycler<std::optional<HashType>, EMPTY_META_INFO> {
26  public:
27  // hashing scheme recycler caches logical information instead of actual data
28  // so we do not limit its capacity
29  // thus we do not maintain a metric cache for hashing scheme
32  std::numeric_limits<size_t>::max(),
33  std::numeric_limits<size_t>::max(),
34  0) {}
35 
36  std::optional<HashType> getItemFromCache(
37  QueryPlanHash key,
38  CacheItemType item_type,
39  DeviceIdentifier device_identifier,
40  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override;
41 
43  std::optional<HashType> item,
44  CacheItemType item_type,
45  DeviceIdentifier device_identifier,
46  size_t item_size,
47  size_t compute_time,
48  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override;
49 
50  // nothing to do with hashing scheme recycler
51  void initCache() override {}
52 
53  void clearCache() override;
54 
55  void markCachedItemAsDirty(size_t table_key,
56  std::unordered_set<QueryPlanHash>& key_set,
57  CacheItemType item_type,
58  DeviceIdentifier device_identifier) override;
59 
60  std::string toString() const override;
61 
62  private:
63  bool hasItemInCache(
64  QueryPlanHash key,
65  CacheItemType item_type,
66  DeviceIdentifier device_identifier,
67  std::lock_guard<std::mutex>& lock,
68  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) const override;
69 
70  // hashing scheme recycler clears the cached layouts at once
72  QueryPlanHash key,
73  CacheItemType item_type,
74  DeviceIdentifier device_identifier,
75  std::lock_guard<std::mutex>& lock,
76  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override;
77 
78  // hashing scheme recycler has unlimited capacity so we do not need this
80  CacheItemType item_type,
81  DeviceIdentifier device_identifier,
82  size_t required_size,
83  std::lock_guard<std::mutex>& lock,
84  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override {}
85 };
size_t DeviceIdentifier
Definition: DataRecycler.h:129
bool hasItemInCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) const override
constexpr DeviceIdentifier LAYOUT_CACHE_DEVICE_IDENTIFIER
void markCachedItemAsDirty(size_t table_key, std::unordered_set< QueryPlanHash > &key_set, CacheItemType item_type, DeviceIdentifier device_identifier) override
void putItemToCache(QueryPlanHash key, std::optional< HashType > item, CacheItemType item_type, DeviceIdentifier device_identifier, size_t item_size, size_t compute_time, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
CacheItemType
Definition: DataRecycler.h:38
size_t QueryPlanHash
void removeItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
void cleanupCacheForInsertion(CacheItemType item_type, DeviceIdentifier device_identifier, size_t required_size, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
virtual std::optional< HashType > getItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< EMPTY_META_INFO > meta_info=std::nullopt)=0
std::string toString() const override
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136