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
DataProxy.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 DATAPROXY_H
20 #define DATAPROXY_H
21 
22 #include "DataTypes.h"
23 #include "PDBPage.h"
24 #include "PDBCommunicator.h"
25 #include "SharedMem.h"
26 #include "PageScanner.h"
27 
28 #include <memory>
29 using namespace std;
30 class DataProxy;
31 typedef shared_ptr<DataProxy> DataProxyPtr;
32 
33 /*
34  * The DataProxy class will use a BackEndCommunicator instance to interact with Storage to do all
35  *stuffs like
36  * addTempSet, removeTempSet, addTempPage, pinTempPage, unpinTempPage, pinUserPage, unpinUserPage,
37  *getScanner, and closeCleaner.
38  * Because multiple threads can not share one communicator, a data proxy instance can only be
39  *owned/accessed by one thread.
40  **/
41 class DataProxy {
42 public:
43  DataProxy(NodeID nodeId,
44  pdb::PDBCommunicatorPtr communicator,
45  SharedMemPtr shm,
46  pdb::PDBLoggerPtr logger);
47  ~DataProxy();
48 
54  bool addTempSet(string setName, SetID& setId, bool needMem = true, int numTries = 0);
55 
60  bool removeTempSet(SetID setId, bool needMem = true, int numTries = 0);
61 
68  bool addTempPage(SetID setId, PDBPagePtr& page, bool needMem = true, int numTries = 0);
69 
76  bool addUserPage(DatabaseID dbId,
77  UserTypeID typeId,
78  SetID setId,
79  PDBPagePtr& page,
80  bool needMem = true,
81  int numTries = 0);
82 
88  bool pinTempPage(
89  SetID setId, PageID pageId, PDBPagePtr& page, bool needMem = true, int numTries = 0);
90 
97  bool unpinTempPage(SetID setId, PDBPagePtr page, bool needMem = true, int numTries = 0);
98 
106  bool pinUserPage(NodeID nodeId,
107  DatabaseID dbId,
108  UserTypeID typeId,
109  SetID setId,
110  PageID pageId,
111  PDBPagePtr& page,
112  bool needMem = true,
113  int numTries = 0);
114 
118  bool pinBytes(DatabaseID dbId,
119  UserTypeID typeId,
120  SetID setId,
121  size_t sizeOfBytes,
122  void* bytes,
123  bool needMem = true,
124  int numTries = 0);
125 
126 
135  bool unpinUserPage(NodeID nodeId,
136  DatabaseID dbId,
137  UserTypeID typeId,
138  SetID setId,
139  PDBPagePtr page,
140  bool needMem = true,
141  int numTries = 0);
142 
147  PageScannerPtr getScanner(int numThreads);
148 
149 
150 private:
155 };
156 #endif /* DATAPROXY_H */
shared_ptr< PageScanner > PageScannerPtr
Definition: PageScanner.h:39
unsigned int SetID
Definition: DataTypes.h:31
shared_ptr< PDBPage > PDBPagePtr
Definition: PDBPage.h:32
shared_ptr< DataProxy > DataProxyPtr
Definition: DataProxy.h:30
unsigned int NodeID
Definition: DataTypes.h:27
pdb::PDBLoggerPtr logger
Definition: DataProxy.h:153
shared_ptr< SharedMem > SharedMemPtr
Definition: SharedMem.h:32
unsigned int DatabaseID
Definition: DataTypes.h:29
std::shared_ptr< PDBCommunicator > PDBCommunicatorPtr
unsigned int PageID
Definition: DataTypes.h:26
pdb::PDBCommunicatorPtr communicator
Definition: DataProxy.h:151
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition: PDBLogger.h:40
SharedMemPtr shm
Definition: DataProxy.h:152
NodeID nodeId
Definition: DataProxy.h:154
unsigned int UserTypeID
Definition: DataTypes.h:25