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
LogicalPlan.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 LOG_PLAN_H
20 #define LOG_PLAN_H
21 
22 #include <iostream>
23 #include <memory>
24 #include <stdlib.h>
25 #include <string>
26 #include <utility>
27 #include <vector>
28 #include <map>
29 
30 #include "AtomicComputationList.h"
31 #include "ComputationNode.h"
32 #include "PDBVector.h"
33 
34 // NOTE: this struct is not part of the pdb namspace because it needs to work with extern "C"...
35 // probably it can be made to work, but this is for the future :-)
36 
37 // this is an actual logical plan
38 struct LogicalPlan {
39 
40 private:
41  // this is the parsed TCAP plan
43 
44  // this allows one to access a particular Computation in the Logical Plan
45  std::map<std::string, pdb::ComputationNode> allConstituentComputations;
46 
47 public:
48  // getter for this guy's AtomicComputationList
50  return computations;
51  }
52 
53  // constructor
55  pdb::Vector<pdb::Handle<pdb::Computation>>& allComputations) {
56  computations = computationsIn;
57  // std :: cout << "\nEXTRACTING LAMBDAS:\n";
58  for (int i = 0; i < allComputations.size(); i++) {
59  std::string compType = allComputations[i]->getComputationType();
60  compType += "_";
61  compType += std::to_string(i);
62  // std :: cout << "Extracting lambdas for computation " << compType << "\n";
63  pdb::ComputationNode temp(allComputations[i]);
64  allConstituentComputations[compType] = temp;
65  }
66  }
67 
68  // get a particular node in the computational plan
69  pdb::ComputationNode& getNode(std::string& whichComputationNode) {
70  if (allConstituentComputations.count(whichComputationNode) == 0) {
71  std::cout << "This is bad. I did not find a node corresponding to "
72  << whichComputationNode << "\n";
73  std::cout << "There were " << allConstituentComputations.size() << " computations.\n";
74  for (auto& a : allConstituentComputations) {
75  std::cout << a.first << "\n";
76  }
77  exit(1);
78  }
79  return allConstituentComputations[whichComputationNode];
80  }
81 
82  // getter for the list of nodes
83  std::map<std::string, pdb::ComputationNode>& getAllNodes() {
85  }
86 
87  friend std::ostream& operator<<(std::ostream& os, const LogicalPlan& printMe);
88 };
89 
90 inline std::ostream& operator<<(std::ostream& os, const LogicalPlan& printMe) {
91  os << printMe.computations;
92  return os;
93 }
94 
95 #endif
friend std::ostream & operator<<(std::ostream &os, const LogicalPlan &printMe)
Definition: LogicalPlan.h:90
LogicalPlan(AtomicComputationList &computationsIn, pdb::Vector< pdb::Handle< pdb::Computation >> &allComputations)
Definition: LogicalPlan.h:54
pdb::ComputationNode & getNode(std::string &whichComputationNode)
Definition: LogicalPlan.h:69
AtomicComputationList computations
Definition: LogicalPlan.h:42
std::map< std::string, pdb::ComputationNode > allConstituentComputations
Definition: LogicalPlan.h:45
std::ostream & operator<<(std::ostream &os, const LogicalPlan &printMe)
Definition: LogicalPlan.h:90
AtomicComputationList & getComputations()
Definition: LogicalPlan.h:49
std::map< std::string, pdb::ComputationNode > & getAllNodes()
Definition: LogicalPlan.h:83