5 #ifndef JODA_STORAGECOLLECTION_H
6 #define JODA_STORAGECOLLECTION_H
10 #include <unordered_map>
13 #include <boost/functional/hash.hpp>
14 #include "../../../../../include/joda/storage/JSONStorage.h"
16 #define JODA_TEMPORARY_STORAGE_NAME "TEMPORARY_RESULT"
17 #define JODA_STORE_SKIPPED_QUERY_ID 0
18 #define JODA_STORE_EXTERNAL_RS_ID 1
19 #define JODA_STORE_EMPTY_RS_ID 2
20 #define JODA_STORE_VALID_ID_START 3
48 std::shared_ptr<JSONStorage>
getStorage(
const std::string &name);
71 std::vector<std::shared_ptr<JSONStorage>>
getStorages();
82 std::vector<std::pair<unsigned long, std::shared_ptr<JSONStorage>>>
90 std::shared_ptr<JSONStorage>
getStorage(
unsigned long id);
97 const std::shared_ptr<JSONStorage> &storage);
116 std::unique_ptr<joda::query::IValueProvider> &&valProv);
140 const std::shared_ptr<JSONStorage> &withoutDependency =
nullptr);
141 void addDependency(
const std::shared_ptr<JSONStorage> &store,
142 const std::shared_ptr<JSONStorage> &dependson);
151 const std::shared_ptr<JSONStorage> &store)
const;
154 long long toFree,
const std::vector<JSONStorage *> &except)
const;
156 std::vector<std::pair<JSONStorage *, size_t>> &candidates)
const;
158 std::vector<std::pair<JSONStorage *, size_t>> &candidates)
const;
160 std::vector<std::pair<JSONStorage *, size_t>> &candidates)
const;
162 std::vector<std::pair<JSONStorage *, size_t>> &candidates)
const;
164 std::vector<std::pair<JSONStorage *, size_t>> &candidates)
const;
167 std::unordered_map<std::string, std::shared_ptr<JSONStorage>>
storages;
169 std::unordered_map<unsigned long, std::shared_ptr<JSONStorage>>
resultStorage;
170 std::unordered_map<std::string, std::shared_ptr<JoinManager>>
runningJoins;
175 std::pair<std::shared_ptr<JSONStorage>, std::shared_ptr<JSONStorage>>,
176 boost::hash<std::pair<std::shared_ptr<JSONStorage>,
177 std::shared_ptr<JSONStorage>>>>
#define JODA_STORE_VALID_ID_START
Definition: StorageCollection.h:20
Definition: CollectionTest.cpp:9
Definition: JoinManager.h:19
Definition: StorageCollection.h:27
void ensureSpace(unsigned long long estimatedSize, const std::shared_ptr< JSONStorage > &withoutDependency=nullptr)
Definition: StorageCollection.cpp:187
void orderContainerByDependencies(std::vector< std::pair< JSONStorage *, size_t >> &candidates) const
Definition: StorageCollection.cpp:327
size_t estimateHierarchySize(const std::shared_ptr< JSONStorage > &store) const
Definition: StorageCollection.cpp:371
std::vector< std::shared_ptr< JSONStorage > > getStorages()
Definition: StorageCollection.cpp:60
void orderContainerBySize(std::vector< std::pair< JSONStorage *, size_t >> &candidates) const
Definition: StorageCollection.cpp:294
void orderContainerByLRU(std::vector< std::pair< JSONStorage *, size_t >> &candidates) const
Definition: StorageCollection.cpp:303
std::shared_ptr< JSONStorage > getOrAddStorage(const std::string &name)
Definition: StorageCollection.cpp:49
virtual ~StorageCollection()
Definition: StorageCollection.cpp:167
long long estimatedStorageSize() const
Definition: StorageCollection.cpp:287
unsigned long addTemporaryStorage()
Definition: StorageCollection.cpp:88
std::string getJoinName(const joda::query::IValueProvider &valProv)
Definition: StorageCollection.cpp:151
std::shared_ptr< JSONStorage > getStorage(const std::string &name)
Definition: StorageCollection.cpp:18
size_t parsedHierarchySize(const std::shared_ptr< JSONStorage > &store) const
Definition: StorageCollection.cpp:393
void orderContainerByRandomExplorer(std::vector< std::pair< JSONStorage *, size_t >> &candidates) const
Definition: StorageCollection.cpp:431
bool storageExists(const std::string &name)
Definition: StorageCollection.cpp:93
size_t estimatedSize() const
Definition: StorageCollection.cpp:415
std::vector< std::string > storageInsertion
Definition: StorageCollection.h:168
void orderContainerByFIFO(std::vector< std::pair< JSONStorage *, size_t >> &candidates) const
Definition: StorageCollection.cpp:312
std::unordered_map< unsigned long, std::shared_ptr< JSONStorage > > resultStorage
Definition: StorageCollection.h:169
void operator=(StorageCollection const &)=delete
static StorageCollection & getInstance()
Definition: StorageCollection.h:32
friend class CollectionTest_DEPENDENCIES_Test
Definition: StorageCollection.h:186
void removeStorage(const std::string &name)
Definition: StorageCollection.cpp:27
size_t estimatedParsedSize() const
Definition: StorageCollection.cpp:423
std::shared_ptr< JoinManager > getOrStartJoin(std::unique_ptr< joda::query::IValueProvider > &&valProv)
Definition: StorageCollection.cpp:118
StorageCollection(StorageCollection const &)=delete
std::unordered_map< std::string, std::shared_ptr< JoinManager > > runningJoins
Definition: StorageCollection.h:170
std::atomic_ulong tmpRes
Definition: StorageCollection.h:172
std::vector< JSONStorage * > getDependencies(const std::shared_ptr< JSONStorage > &store) const
Definition: StorageCollection.cpp:353
std::unordered_set< std::pair< std::shared_ptr< JSONStorage >, std::shared_ptr< JSONStorage > >, boost::hash< std::pair< std::shared_ptr< JSONStorage >, std::shared_ptr< JSONStorage > > > > dependencies
Definition: StorageCollection.h:178
std::unordered_map< std::string, std::shared_ptr< JSONStorage > > storages
Definition: StorageCollection.h:167
friend class CollectionTest_LARGEST_Test
Definition: StorageCollection.h:185
friend class CollectionTest_FIFO_Test
Definition: StorageCollection.h:184
std::mutex mut
Definition: StorageCollection.h:171
void addDependency(const std::shared_ptr< JSONStorage > &store, const std::shared_ptr< JSONStorage > &dependson)
Definition: StorageCollection.cpp:346
StorageCollection()
Definition: StorageCollection.h:180
std::vector< std::pair< JSONStorage *, size_t > > chooseStoragesToRemove(long long toFree, const std::vector< JSONStorage * > &except) const
Definition: StorageCollection.cpp:243
std::vector< std::pair< unsigned long, std::shared_ptr< JSONStorage > > > getTemporaryIDStorages()
Definition: StorageCollection.cpp:109
std::vector< std::shared_ptr< JSONStorage > > getTemporaryStorages()
Definition: StorageCollection.cpp:99
void stopJoin(const joda::query::IValueProvider &valProv)
Definition: StorageCollection.cpp:144
Definition: IValueProvider.h:143