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
AtomicComputationList.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 
19 #ifndef COMP_LIST_CC
20 #define COMP_LIST_CC
21 
22 #include "AtomicComputationList.h"
24 #include "PDBDebug.h"
25 
26 // gets the computation that builds the tuple set with the specified name
28  if (producers.count(outputName) == 0) {
29  PDB_COUT << "This could be bad... can't find the guy producing output " << outputName
30  << ".\n";
31  }
32  return producers[outputName];
33 }
34 
35 // gets the list of comptuations that consume the tuple set with the specified name
36 std::vector<AtomicComputationPtr>& AtomicComputationList::getConsumingAtomicComputations(
37  std::string inputName) {
38  if (consumers.count(inputName) == 0) {
39  PDB_COUT << "This could be bad... can't find the guy consuming input " << inputName
40  << ".\n";
41  }
42  return consumers[inputName];
43 }
44 
45 // this effectively gets all of the leaves of the graph, since it returns all of the scans... every
46 // AtomicComputationPtr in the returned list will point to a ScanSet object
47 std::vector<AtomicComputationPtr>& AtomicComputationList::getAllScanSets() {
48  return scans;
49 }
50 
51 // add an atomic computation to the graph
53 
54  if (addMe->getAtomicComputationType() == "Scan") {
55  scans.push_back(addMe);
56  }
57 
58  producers[addMe->getOutputName()] = addMe;
59  if (consumers.count(addMe->getInputName()) == 0) {
60  std::vector<AtomicComputationPtr> rhs;
61  consumers[addMe->getInputName()] = rhs;
62  }
63  consumers[addMe->getInputName()].push_back(addMe);
64 
65  // now, see if this guy is a join; join is special, because we have to add both inputs to the
66  // join to the consumers map
67  if (addMe->getAtomicComputationType() == "JoinSets") {
68  ApplyJoin* myPtr = (ApplyJoin*)addMe.get();
69  consumers[myPtr->getRightInput().getSetName()].push_back(addMe);
70  }
71 
72  // kill the copy of the shared pointer that is inside him
73  addMe->destroyPtr();
74 }
75 
76 std::ostream& operator<<(std::ostream& os, const AtomicComputationList& printMe) {
77  for (auto& a : printMe.producers) {
78  os << a.second->output << " <= " << a.second->getAtomicComputationType() << "("
79  << a.second->input << ", " << a.second->projection;
80  os << ")\n";
81  }
82  return os;
83 }
84 
85 #endif
std::vector< AtomicComputationPtr > scans
TupleSpec & getRightInput()
std::string & getSetName()
Definition: TupleSpec.h:56
AtomicComputationPtr getProducingAtomicComputation(std::string outputName)
std::vector< AtomicComputationPtr > & getConsumingAtomicComputations(std::string inputName)
std::map< std::string, std::vector< AtomicComputationPtr > > consumers
void addAtomicComputation(AtomicComputationPtr addMe)
#define PDB_COUT
Definition: PDBDebug.h:31
std::shared_ptr< struct AtomicComputation > AtomicComputationPtr
std::map< std::string, AtomicComputationPtr > producers
std::ostream & operator<<(std::ostream &os, const AtomicComputationList &printMe)
std::vector< AtomicComputationPtr > & getAllScanSets()