OmniSciDB  6686921089
 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 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 
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) const 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  std::string toString() const override;
56 
57  private:
58  bool hasItemInCache(
59  QueryPlanHash key,
60  CacheItemType item_type,
61  DeviceIdentifier device_identifier,
62  std::lock_guard<std::mutex>& lock,
63  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) const override;
64 
65  // hashing scheme recycler clears the cached layouts at once
67  QueryPlanHash key,
68  CacheItemType item_type,
69  DeviceIdentifier device_identifier,
70  std::lock_guard<std::mutex>& lock,
71  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override {
72  UNREACHABLE();
73  }
74 
75  // hashing scheme recycler has unlimited capacity so we do not need this
77  CacheItemType item_type,
78  DeviceIdentifier device_identifier,
79  size_t required_size,
80  std::lock_guard<std::mutex>& lock,
81  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override {}
82 };
size_t DeviceIdentifier
Definition: DataRecycler.h:111
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
#define UNREACHABLE()
Definition: Logger.h:253
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:36
virtual std::optional< HashType > getItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) const =0
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
std::string toString() const override
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:132