Column-oriented GPU-accelerated Database Management System
CoGaDB
|
00001 #pragma once 00002 00003 //#include <core/scheduling_decision.hpp> 00004 00005 //#include <boost/shared_ptr.hpp> 00006 #include <config/global_definitions.hpp> 00007 #include <config/configuration.hpp> 00008 #include <query_processing/typed_operator.hpp> 00009 00010 namespace hype { 00011 namespace queryprocessing { 00012 00013 template <typename OperatorInputType, typename OperatorOutputType> 00014 class N_AryOperator : public TypedOperator<OperatorOutputType> { //uses 2D Learning Method 00015 public: 00016 //typedef typename OperatorMapper_Helper_Template<OperatorOutputType>::TypedOperator TypedOperator; 00017 typedef typename OperatorMapper_Helper_Template<OperatorOutputType>::TypedOperatorPtr TypedOperatorPtr; 00018 typedef typename OperatorMapper_Helper_Template<OperatorOutputType>::TypedNodePtr TypedNodePtr; 00019 00020 N_AryOperator(const hype::SchedulingDecision& sched_dec, const std::list<OperatorInputType>& childs) 00021 : TypedOperator<OperatorOutputType>(sched_dec), childs_(childs) { 00022 } 00023 00024 virtual ~N_AryOperator() { 00025 } 00026 00027 // OperatorInputTypeLeftChild getInputDataLeftChild(){ 00028 // return this->left_child_->getResult(); 00029 // } 00030 00031 // OperatorInputTypeRightChild getInputDataRightChild(){ 00032 // return this->right_child_->getResult(); 00033 // } 00034 00035 const std::list<OperatorInputType>& getOutputDataOfChilds() { 00036 return childs_; 00037 } 00038 00039 virtual bool run() { 00040 std::list<OperatorInputType>::iterator it; 00041 if (!hype::core::Runtime_Configuration::instance().isQueryChoppingEnabled()) { 00042 for (it = childs_.begin(); it != childs_.end(); ++it) { 00043 if (*it) 00044 it->run(); 00045 } 00046 } 00047 //execute this operator 00048 double begin = double(hype::core::getTimestamp()); 00049 timeEstimated = double(this->getEstimatedExecutionTime().getTimeinNanoseconds()); 00050 bool retVal = (*this)(); 00051 timeNeeded = double( hype::core::getTimestamp()) - begin; 00052 return retVal; 00053 } 00054 00055 virtual void print(unsigned int tree_level) const { 00056 for (unsigned int i = 0; i < tree_level; ++i) { 00057 std::cout << "\t"; 00058 } 00059 assert(!this->getFeatureValues().empty()); 00060 std::cout << this->getAlgorithmName() << " ET: " << this->getEstimatedExecutionTime().getTimeinNanoseconds() 00061 << "\tEC: " << this->getFeatureValues()[0] 00062 << std::endl; // << " Features: " << this->getFeatureValues() << std::endl; 00063 00064 for (it = childs_.begin(); it != childs_.end(); +cit) { 00065 if (*it) 00066 it->print(tree_level + 1); 00067 } 00068 } 00069 00070 virtual void printResult(unsigned int tree_level) const { 00071 for (unsigned int i = 0; i < tree_level; ++i) { 00072 std::cout << "\t"; 00073 } 00074 assert(!this->getFeatureValues().empty()); 00075 std::cout << this->getAlgorithmName() << " ET: " << timeEstimated 00076 << "\tMT: " << timeNeeded 00077 << "\tEE: " << 1 - (timeEstimated / timeNeeded) 00078 << "\tEC: " << this->getFeatureValues()[0]; 00079 if (this->getResultSize() != -1) { 00080 std::cout << "\tRR: " << this->getResultSize(); 00081 } 00082 std::cout << std::endl; 00083 for (it = childs_.begin(); it != childs_.end(); +cit) { 00084 if (*it) 00085 it->printResult(tree_level + 1); 00086 } 00087 } 00088 00089 virtual double getRecursiveExecutionTimeInNanoseconds() { 00090 double executiontime = this->getEstimatedExecutionTime().getTimeinNanoseconds(); 00091 if (executiontime < 0) { 00092 executiontime = 0; 00093 } 00094 if (!hype::core::Runtime_Configuration::instance().isQueryChoppingEnabled()) { 00095 for (it = childs_.begin(); it != childs_.end(); +cit) { 00096 if (*it) { 00097 executiontime += it->getRecursiveExecutionTimeInNanoseconds(); 00098 } 00099 } 00100 } else { 00101 double maxChildExecution = 0; 00102 for (it = childs_.begin(); it != childs_.end(); +cit) { 00103 if (*it && it->getRecursiveExecutionTimeInNanoseconds() > maxChildExecution) { 00104 maxChildExecution = it->getRecursiveExecutionTimeInNanoseconds(); 00105 } 00106 } 00107 executiontime += maxChildExecution; 00108 } 00109 return executiontime; 00110 } 00111 00112 void addChild(OperatorInputType child) { 00113 childs_.push_back(child); 00114 } 00115 00116 /* 00117 virtual std::list<TypedOperator<OperatorOutputType>& > getOperatorQueue(){ 00118 00119 std::list<TypedOperator<OperatorOutputType>& > left_list = left_child_->getOperatorQueue(); 00120 left_list.push_front(*this); 00121 00122 std::list<TypedOperator<OperatorOutputType>& > right_list = right_child_->getOperatorQueue(); 00123 00124 left_list.insert(left_list.end(),right_list.begin(),right_list.end()); 00125 return left_list; 00126 //this->left_child_-> 00127 }*/ 00128 00129 private: 00130 double timeNeeded; 00131 double timeEstimated; 00132 std::list<OperatorInputType> childs_; 00133 // boost::shared_ptr<TypedOperator<OperatorInputTypeLeftChild> > left_child_; 00134 // boost::shared_ptr<TypedOperator<OperatorInputTypeRightChild> > right_child_; 00135 //boost::shared_ptr<TypedOperator<OperatorOutputType> > succsessor_; 00136 }; 00137 00138 00139 }; //end namespace queryprocessing 00140 }; //end namespace hype 00141 00142