OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CachingForeignStorageMgr.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2020 OmniSci, Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include "ForeignStorageCache.h"
21 #include "ForeignStorageMgr.h"
22 
23 namespace foreign_storage {
24 
25 /*
26  A version of the ForeignStorageMgr that incorporates disk caching.
27  */
29  public:
31 
32  void fetchBuffer(const ChunkKey& chunk_key,
33  AbstractBuffer* destination_buffer,
34  const size_t num_bytes) override;
35 
37  const ChunkKey& chunk_key_prefix) override;
38 
40  const ChunkKey& chunk_key_prefix);
41 
42  void removeTableRelatedDS(const int db_id, const int table_id) override;
43 
44  void refreshTable(const ChunkKey& table_key, const bool evict_cached_entries) override;
45 
46  bool createDataWrapperIfNotExists(const ChunkKey& chunk_key) override;
47 
48  private:
49  void refreshTableInCache(const ChunkKey& table_key);
50 
51  int getHighestCachedFragId(const ChunkKey& table_key);
52 
53  void refreshAppendTableInCache(const ChunkKey& table_key,
54  const std::vector<ChunkKey>& old_chunk_keys);
55 
56  void refreshNonAppendTableInCache(const ChunkKey& table_key,
57  const std::vector<ChunkKey>& old_chunk_keys);
58 
59  void refreshChunksInCacheByFragment(const std::vector<ChunkKey>& old_chunk_keys,
60  int last_frag_id);
61 
63  ChunkToBufferMap& required_buffers,
64  ChunkToBufferMap& optional_buffers);
65 
66  void eraseDataWrapper(const ChunkKey& key) override;
67 
68  void clearTable(const ChunkKey& table_key);
69 
70  size_t maxFetchSize(int32_t db_id) const override;
71 
72  bool hasMaxFetchSize() const override;
73 
74  std::set<ChunkKey> getOptionalKeysWithinSizeLimit(
75  const ChunkKey& chunk_key,
76  const std::set<ChunkKey, decltype(set_comp)*>& same_fragment_keys,
77  const std::set<ChunkKey, decltype(set_comp)*>& diff_fragment_keys) const override;
78 
79  size_t getBufferSize(const ChunkKey& key) const;
80 
81  size_t getRequiredBuffersSize(const ChunkKey& chunk_key) const;
82 
84 };
85 
86 } // namespace foreign_storage
bool set_comp(const ChunkKey &left, const ChunkKey &right)
void refreshAppendTableInCache(const ChunkKey &table_key, const std::vector< ChunkKey > &old_chunk_keys)
std::vector< int > ChunkKey
Definition: types.h:37
size_t getBufferSize(const ChunkKey &key) const
size_t maxFetchSize(int32_t db_id) const override
std::map< ChunkKey, AbstractBuffer * > ChunkToBufferMap
void refreshTableInCache(const ChunkKey &table_key)
std::set< ChunkKey > getOptionalKeysWithinSizeLimit(const ChunkKey &chunk_key, const std::set< ChunkKey, decltype(set_comp)* > &same_fragment_keys, const std::set< ChunkKey, decltype(set_comp)* > &diff_fragment_keys) const override
void eraseDataWrapper(const ChunkKey &key) override
void getChunkMetadataVecFromDataWrapper(ChunkMetadataVector &chunk_metadata, const ChunkKey &chunk_key_prefix)
void refreshNonAppendTableInCache(const ChunkKey &table_key, const std::vector< ChunkKey > &old_chunk_keys)
void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector &chunk_metadata, const ChunkKey &chunk_key_prefix) override
void refreshChunksInCacheByFragment(const std::vector< ChunkKey > &old_chunk_keys, int last_frag_id)
bool createDataWrapperIfNotExists(const ChunkKey &chunk_key) override
std::vector< std::pair< ChunkKey, std::shared_ptr< ChunkMetadata >>> ChunkMetadataVector
An AbstractBuffer is a unit of data management for a data manager.
void populateChunkBuffersSafely(ForeignDataWrapper &data_wrapper, ChunkToBufferMap &required_buffers, ChunkToBufferMap &optional_buffers)
void refreshTable(const ChunkKey &table_key, const bool evict_cached_entries) override
void fetchBuffer(const ChunkKey &chunk_key, AbstractBuffer *destination_buffer, const size_t num_bytes) override
void removeTableRelatedDS(const int db_id, const int table_id) override
size_t getRequiredBuffersSize(const ChunkKey &chunk_key) const
int getHighestCachedFragId(const ChunkKey &table_key)