OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResultSetRecyclerHolder.cpp
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 
18 
19 extern bool g_bigint_count;
20 
21 std::unique_ptr<ResultSetRecycler> ResultSetRecyclerHolder::query_resultset_cache_ =
22  std::make_unique<ResultSetRecycler>();
23 std::unique_ptr<ChunkMetadataRecycler> ResultSetRecyclerHolder::chunk_metadata_cache_ =
24  std::make_unique<ChunkMetadataRecycler>();
25 
27  return query_resultset_cache_->hasItemInCache(key);
28 }
29 
31  return query_resultset_cache_->getItemFromCache(key,
34  std::nullopt);
35 }
36 
37 std::optional<std::vector<TargetMetaInfo>> ResultSetRecyclerHolder::getOutputMetaInfo(
38  QueryPlanHash key) {
39  return query_resultset_cache_->getOutputMetaInfo(key);
40 }
41 
43  const size_t key,
44  const std::unordered_set<size_t>& input_table_keys,
45  const ResultSetPtr query_result,
46  size_t resultset_size,
47  std::vector<std::shared_ptr<Analyzer::Expr>>& target_exprs) {
48  ResultSetMetaInfo resultset_meta_info{input_table_keys};
49  resultset_meta_info.keepTargetExprs(target_exprs);
50  query_resultset_cache_->putItemToCache(key,
51  query_result,
54  resultset_size,
55  query_result->getExecTime(),
56  resultset_meta_info);
57 }
58 
59 std::optional<ChunkMetadataMap> ResultSetRecyclerHolder::getCachedChunkMetadata(
60  const size_t key) {
61  return chunk_metadata_cache_->getItemFromCache(
63 }
64 
66  const size_t key,
67  const std::unordered_set<size_t>& input_table_keys,
68  const ChunkMetadataMap& chunk_metadata_map) {
69  if (!chunk_metadata_map.empty()) {
70  ChunkMetadataMetaInfo meta_info{input_table_keys};
71  chunk_metadata_cache_->putItemToCache(key,
72  chunk_metadata_map,
75  0,
76  0,
77  meta_info);
78  }
79 }
80 
81 std::vector<std::shared_ptr<Analyzer::Expr>>& ResultSetRecyclerHolder::getTargetExprs(
82  QueryPlanHash key) const {
83  return query_resultset_cache_->getTargetExprs(key);
84 }
static std::unique_ptr< ResultSetRecycler > query_resultset_cache_
std::shared_ptr< ResultSet > ResultSetPtr
const ResultSetPtr getCachedQueryResultSet(const size_t key)
std::map< int, std::shared_ptr< ChunkMetadata >> ChunkMetadataMap
static std::unique_ptr< ChunkMetadataRecycler > chunk_metadata_cache_
bool g_bigint_count
bool hasCachedQueryResultSet(const size_t key)
void putChunkMetadataToCache(const size_t key, const std::unordered_set< size_t > &input_table_keys, const ChunkMetadataMap &chunk_metadata)
std::vector< std::shared_ptr< Analyzer::Expr > > & getTargetExprs(QueryPlanHash key) const
std::optional< std::vector< TargetMetaInfo > > getOutputMetaInfo(QueryPlanHash key)
size_t QueryPlanHash
std::optional< ChunkMetadataMap > getCachedChunkMetadata(const size_t key)
void keepTargetExprs(std::vector< std::shared_ptr< Analyzer::Expr >> &in_target_exprs)
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136
void putQueryResultSetToCache(const size_t key, const std::unordered_set< size_t > &input_table_keys, const ResultSetPtr query_result, size_t resultset_size, std::vector< std::shared_ptr< Analyzer::Expr >> &target_exprs)
constexpr DeviceIdentifier CHUNK_METADATA_CACHE_DEVICE_IDENTIFIER