A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DefaultDatabase.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
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 
19 #ifndef DEFAULTDATABASE_H
20 #define DEFAULTDATABASE_H
21 
22 #include "Configuration.h"
23 #include "DataTypes.h"
24 #include "PDBLogger.h"
25 #include "UserType.h"
26 #include "SharedMem.h"
27 #include "PageCache.h"
28 #include "PageCircularBuffer.h"
29 
30 #include <map>
31 #include <pthread.h>
32 #include <boost/filesystem.hpp>
33 using namespace std;
34 
35 // create a smart pointer for DummyDatabase objects
37 typedef shared_ptr<DefaultDatabase> DefaultDatabasePtr;
38 ;
39 
44 
45 public:
49  DefaultDatabase(NodeID nodeId,
50  DatabaseID dbId,
51  string dbName,
52  ConfigurationPtr conf,
53  pdb::PDBLoggerPtr logger,
54  SharedMemPtr shm,
55  string metaDBPath,
56  vector<string>* dataDBPaths,
57  PageCachePtr cache,
58  PageCircularBufferPtr flushBuffer);
59  ~DefaultDatabase();
60 
61 
66  bool initializeFromDBDir(boost::filesystem::path dbDir);
67 
72  bool initializeFromMetaDBDir(boost::filesystem::path metaDBDir);
73 
77  bool addType(TypePtr type);
78 
82  bool addType(string name, UserTypeID id);
83 
84 
88  TypePtr getType(UserTypeID typeId);
89 
90 
94  bool removeType(UserTypeID typeID);
95 
99  DatabaseID getDatabaseID();
100 
104  string getDatabaseName();
105 
109  void flush();
110 
114  map<UserTypeID, TypePtr>* getTypes();
115 
116 
117 protected:
121  void addTypeBySequenceFiles(string name, UserTypeID id, boost::filesystem::path typeDir);
122 
126  void addTypeByPartitionedFiles(string name, UserTypeID id, boost::filesystem::path metaTypeDir);
127 
131  void clearType(UserTypeID typeId, string typeName);
132 
136  string encodeTypePath(string dbPath, UserTypeID typeId, string typeName);
137 
138 private:
140  map<UserTypeID, TypePtr>* types;
141  string dbName;
145  pthread_mutex_t typeOpLock;
146  string metaDBPath;
147  vector<string>* dataDBPaths;
151 };
152 
153 
154 #endif /* DEFAULTDATABASE_H */
shared_ptr< UserType > TypePtr
Definition: UserType.h:41
shared_ptr< PageCache > PageCachePtr
Definition: PageCache.h:39
shared_ptr< DefaultDatabase > DefaultDatabasePtr
unsigned int NodeID
Definition: DataTypes.h:27
vector< string > * dataDBPaths
shared_ptr< SharedMem > SharedMemPtr
Definition: SharedMem.h:32
ConfigurationPtr conf
pthread_mutex_t typeOpLock
unsigned int DatabaseID
Definition: DataTypes.h:29
shared_ptr< Configuration > ConfigurationPtr
Definition: Configuration.h:89
pdb::PDBLoggerPtr logger
PageCircularBufferPtr flushBuffer
map< UserTypeID, TypePtr > * types
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition: PDBLogger.h:40
SharedMemPtr shm
shared_ptr< PageCircularBuffer > PageCircularBufferPtr
unsigned int UserTypeID
Definition: DataTypes.h:25
PageCachePtr cache