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
PDBClientTemplate.cc
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 #ifndef PDB_CLIENT_TEMPLATE_CC
19 #define PDB_CLIENT_TEMPLATE_CC
20 
21 #include "PDBClient.h"
22 
23 namespace pdb {
24 
25  template <class DataType>
26  bool PDBClient::createSet(const std::string &databaseName,
27  const std::string &setName, size_t pageSize) {
28 
29  bool result = distributedStorageClient->createSet<DataType>(
30  databaseName, setName, returnedMsg, pageSize);
31 
32  if (result==false) {
33  errorMsg = "Not able to create set: " + returnedMsg;
34  exit(-1);
35  } else {
36  cout << "Created set.\n";
37  }
38  return result;
39  }
40 
41  template <class DataType>
42  bool PDBClient::createSet(const std::string &databaseName,
43  const std::string &setName) {
44 
45  bool result = distributedStorageClient->createSet<DataType>(
46  databaseName, setName, returnedMsg, DEFAULT_PAGE_SIZE);
47 
48  if (result==false) {
49  errorMsg = "Not able to create set: " + returnedMsg;
50  exit(-1);
51  } else {
52  cout << "Created set.\n";
53  }
54  return result;
55  }
56 
57  template <class DataType>
58  bool PDBClient::sendData(std::pair<std::string, std::string> setAndDatabase,
59  Handle<Vector<Handle<DataType>>> dataToSend) {
60 
61  bool result = dispatcherClient->sendData<DataType>(setAndDatabase, dataToSend,
62  returnedMsg);
63 
64  if (result==false) {
65  errorMsg = "Not able to send data: " + returnedMsg;
66  exit(-1);
67  } else {
68  cout << "Data sent.\n";
69  }
70  return result;
71  }
72 
73  template <class DataType>
74  bool PDBClient::sendBytes(std::pair<std::string, std::string> setAndDatabase,
75  char* bytes,
76  size_t numBytes){
77 
78  bool result = dispatcherClient->sendBytes<DataType>(
79  setAndDatabase,
80  bytes,
81  numBytes,
82  returnedMsg);
83 
84  if (result==false) {
85  errorMsg = "Not able to send bytes: " + returnedMsg;
86  exit(-1);
87  } else {
88  cout << "Bytes sent.\n";
89  }
90  return result;
91  }
92 
93  template <class... Types>
95  Handle<Types>... args) {
96 
97  bool result = queryClient->executeComputations(returnedMsg, firstParam, args...);
98 
99  if (result==false) {
100  errorMsg = "Not able to execute computations: " + returnedMsg;
101  exit(-1);
102  }
103  return result;
104  }
105 
106  template <class Type>
108  std::string setName) {
109 
110  return queryClient->getSetIterator<Type>(databaseName, setName);
111  }
112 
113  template <class KeyClass, class ValueClass>
114  bool PDBClient::partitionSet(std::pair<std::string, std::string> inputSet,
115  std::pair<std::string, std::string> outputSet,
117 
118  std::shared_ptr<Partitioner<KeyClass, ValueClass>> myPartitioner
119  = std::make_shared<Partitioner<KeyClass, ValueClass>>(inputSet, outputSet);
120  return myPartitioner->partition(errorMsg, this->queryClient, partitionComp);
121 
122  }
123 
124  template <class KeyClass, class ValueClass>
125  bool PDBClient::partitionAndTransformSet(std::pair<std::string, std::string> inputSet,
126  std::pair<std::string, std::string> outputSet,
128 
129  std::shared_ptr<Partitioner<KeyClass, ValueClass>> myPartitioner
130  = std::make_shared<Partitioner<KeyClass, ValueClass>>(inputSet, outputSet);
131  return myPartitioner->partitionWithTransformation(errorMsg, this->queryClient, partitionComp);
132 
133  }
134 
135 
136 }
137 #endif
bool sendData(std::pair< std::string, std::string > setAndDatabase, Handle< Vector< Handle< DataType >>> dataToSend)
bool sendBytes(std::pair< std::string, std::string > setAndDatabase, char *bytes, size_t numBytes)
std::shared_ptr< pdb::DistributedStorageManagerClient > distributedStorageClient
Definition: PDBClient.h:230
std::shared_ptr< pdb::DispatcherClient > dispatcherClient
Definition: PDBClient.h:229
std::string errorMsg
Definition: PDBClient.h:243
std::string returnedMsg
Definition: PDBClient.h:246
SetIterator< Type > getSetIterator(std::string databaseName, std::string setName)
bool partitionAndTransformSet(std::pair< std::string, std::string > inputSet, std::pair< std::string, std::string > outputSet, Handle< PartitionTransformationComp< KeyClass, ValueClass >> partitionComp)
bool createSet(const std::string &databaseName, const std::string &setName, const std::string &typeName)
Definition: PDBClient.cc:82
std::shared_ptr< pdb::QueryClient > queryClient
Definition: PDBClient.h:231
bool executeComputations(Handle< Computation > firstParam, Handle< Types >...args)
#define DEFAULT_PAGE_SIZE
Definition: Configuration.h:36
bool partitionSet(std::pair< std::string, std::string > inputSet, std::pair< std::string, std::string > outputSet, Handle< PartitionComp< KeyClass, ValueClass >> partitionComp)