OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OverlapsTuningParamRecycler.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 
21 #include <numeric>
22 
25 
29  std::vector<double> bucket_sizes;
30 };
31 
33  : public DataRecycler<std::optional<AutoTunerMetaInfo>, EMPTY_META_INFO> {
34  public:
35  // hashing scheme recycler caches logical information instead of actual data
36  // so we do not limit its capacity
37  // thus we do not maintain a metric cache for hashing scheme
40  std::numeric_limits<size_t>::max(),
41  std::numeric_limits<size_t>::max(),
42  0) {}
43 
44  std::optional<AutoTunerMetaInfo> getItemFromCache(
45  QueryPlanHash key,
46  CacheItemType item_type,
47  DeviceIdentifier device_identifier,
48  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) const override;
49 
51  std::optional<AutoTunerMetaInfo> item,
52  CacheItemType item_type,
53  DeviceIdentifier device_identifier,
54  size_t item_size,
55  size_t compute_time,
56  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override;
57 
58  // nothing to do with hashing scheme recycler
59  void initCache() override {}
60 
61  void clearCache() override;
62 
63  std::string toString() const override;
64 
65  private:
66  bool hasItemInCache(
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) const override;
72 
73  // auto tuner param recycler has unlimited capacity so we do not need this
75  QueryPlanHash key,
76  CacheItemType item_type,
77  DeviceIdentifier device_identifier,
78  std::lock_guard<std::mutex>& lock,
79  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override {
80  UNREACHABLE();
81  }
82 
83  // hauto tuner param has unlimited capacity so we do not need this
85  CacheItemType item_type,
86  DeviceIdentifier device_identifier,
87  size_t required_size,
88  std::lock_guard<std::mutex>& lock,
89  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override {
90  UNREACHABLE();
91  }
92 };
size_t DeviceIdentifier
Definition: DataRecycler.h:111
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
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
std::vector< double > bucket_sizes
#define UNREACHABLE()
Definition: Logger.h:253
CacheItemType
Definition: DataRecycler.h:36
constexpr DeviceIdentifier PARAM_CACHE_DEVICE_IDENTIFIER
virtual std::optional< AutoTunerMetaInfo > getItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) const =0
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
size_t QueryPlanHash
std::string toString() const override
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:132
void putItemToCache(QueryPlanHash key, std::optional< AutoTunerMetaInfo > 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