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
AbstractPhysicalNode.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 #ifndef PDB_ABSTRACTPHYSICALNODE_H
19 #define PDB_ABSTRACTPHYSICALNODE_H
20 
21 #include <memory>
22 #include <list>
23 #include "TupleSetJobStage.h"
26 #include "AggregationJobStage.h"
27 #include "AtomicComputation.h"
28 #include "AbstractJobStage.h"
29 #include "SetIdentifier.h"
30 #include "Handle.h"
31 #include "Statistics.h"
32 
33 namespace pdb {
34 
37 
38 typedef std::shared_ptr<PhysicalOptimizerResult> PhysicalOptimizerResultPtr;
39 typedef std::shared_ptr<AbstractPhysicalNode> AbstractPhysicalNodePtr;
40 typedef std::shared_ptr<AbstractPhysicalNode> AbstractPhysicalNodeWeakPtr;
41 
47 
51  std::list<Handle<AbstractJobStage>> physicalPlanToOutput;
52 
56  std::list<Handle<SetIdentifier>> interGlobalSets;
57 
58 
62  list<AbstractPhysicalNodePtr> createdSourceComputations;
63 
67  bool success;
68 };
69 
70 
76 public:
77 
82 
87  virtual PhysicalOptimizerResultPtr analyze(const StatisticsPtr &stats, int nextStageID) = 0;
88 
95  virtual double getCost(const StatisticsPtr &stats) = 0;
96 
101  virtual bool hasConsumers() = 0;
102 
108  virtual bool isConsuming(Handle<SetIdentifier> &set) = 0;
109 
114  virtual std::string getNodeIdentifier() = 0;
115 
121 
126  virtual void removeConsumer(const AbstractPhysicalNodePtr &consumer) {
127  consumers.remove(consumer);
128  consumer->producers.remove(getHandle());
129  }
130 
135  virtual void addConsumer(const pdb::AbstractPhysicalNodePtr &consumer) {
136  consumers.push_back(consumer);
137  consumer->producers.push_back(getHandle());
138  }
139 
146 
151  size_t getNumConsumers();
152 
159 
164  size_t getNumProducers();
165 
166 
173  template<typename T>
174  std::shared_ptr<T> to() {
175  return std::dynamic_pointer_cast<T>(getHandle());
176  }
177 
178 
179  protected:
180 
184  std::string jobId;
185 
190 
195 
200 
204  std::list<AbstractPhysicalNodePtr> consumers;
205 
209  std::list<AbstractPhysicalNodeWeakPtr> producers;
210 
215 
222 };
223 
224 }
225 
226 
227 
228 #endif //PDB_ABSTRACTPHYSICALNODE_H
AbstractPhysicalNodePtr getHandle()
Handle< ComputePlan > computePlan
std::shared_ptr< Statistics > StatisticsPtr
Definition: Statistics.h:27
virtual bool isConsuming(Handle< SetIdentifier > &set)=0
AbstractPhysicalNodePtr getProducer(int idx)
std::shared_ptr< LogicalPlan > LogicalPlanPtr
Definition: ComputePlan.h:36
std::list< Handle< SetIdentifier > > interGlobalSets
std::shared_ptr< T > to()
virtual PhysicalOptimizerResultPtr analyze(const StatisticsPtr &stats, int nextStageID)=0
AbstractPhysicalNodeWeakPtr handle
AbstractPhysicalNode(string &jobId, const Handle< ComputePlan > &computePlan, LogicalPlanPtr &logicalPlan, ConfigurationPtr &conf)
list< AbstractPhysicalNodePtr > createdSourceComputations
std::shared_ptr< AbstractPhysicalNode > AbstractPhysicalNodeWeakPtr
AbstractPhysicalNodePtr getConsumer(int idx)
std::list< Handle< AbstractJobStage > > physicalPlanToOutput
shared_ptr< Configuration > ConfigurationPtr
Definition: Configuration.h:89
std::list< AbstractPhysicalNodePtr > consumers
std::shared_ptr< AbstractPhysicalNode > AbstractPhysicalNodePtr
virtual double getCost(const StatisticsPtr &stats)=0
Handle< SetIdentifier > getSetIdentifierFromComputation(Handle< Computation > computation)
virtual void addConsumer(const pdb::AbstractPhysicalNodePtr &consumer)
virtual void removeConsumer(const AbstractPhysicalNodePtr &consumer)
virtual bool hasConsumers()=0
virtual std::string getNodeIdentifier()=0
std::list< AbstractPhysicalNodeWeakPtr > producers
std::shared_ptr< PhysicalOptimizerResult > PhysicalOptimizerResultPtr