OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BoundingBoxIntersectTuningParamRecycler.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 
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) 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  void markCachedItemAsDirty(size_t table_key,
64  std::unordered_set<QueryPlanHash>& key_set,
65  CacheItemType item_type,
66  DeviceIdentifier device_identifier) override;
67 
68  std::string toString() const override;
69 
70  private:
71  bool hasItemInCache(
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) const override;
77 
78  // auto tuner param recycler has unlimited capacity so we do not need this
80  QueryPlanHash key,
81  CacheItemType item_type,
82  DeviceIdentifier device_identifier,
83  std::lock_guard<std::mutex>& lock,
84  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override;
85 
86  // hauto tuner param has unlimited capacity so we do not need this
88  CacheItemType item_type,
89  DeviceIdentifier device_identifier,
90  size_t required_size,
91  std::lock_guard<std::mutex>& lock,
92  std::optional<EMPTY_META_INFO> meta_info = std::nullopt) override {
93  UNREACHABLE();
94  }
95 };
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
size_t DeviceIdentifier
Definition: DataRecycler.h:129
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
#define UNREACHABLE()
Definition: Logger.h:338
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
constexpr DeviceIdentifier PARAM_CACHE_DEVICE_IDENTIFIER
CacheItemType
Definition: DataRecycler.h:38
void markCachedItemAsDirty(size_t table_key, std::unordered_set< QueryPlanHash > &key_set, CacheItemType item_type, DeviceIdentifier device_identifier) override
size_t QueryPlanHash
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::optional< AutoTunerMetaInfo > getItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136