Column-oriented GPU-accelerated Database Management System
CoGaDB
|
00001 00002 #pragma once 00003 00004 //#include <core/scheduling_decision.hpp> 00005 00006 //#include <boost/shared_ptr.hpp> 00007 00008 #include <query_processing/typed_operator.hpp> 00009 #include <query_processing/unary_operator.hpp> 00010 #include <query_processing/binary_operator.hpp> 00011 00012 namespace hype { 00013 namespace queryprocessing { 00014 00015 template <typename Type> 00016 class PhysicalQueryPlan { 00017 public: 00018 typedef typename OperatorMapper_Helper_Template<Type>::TypedOperatorPtr TypedOperatorPtr; 00019 typedef typename OperatorMapper_Helper_Template<Type>::TypedNodePtr TypedNodePtr; 00020 typedef typename OperatorMapper_Helper_Template<Type>::PhysicalQueryPlanPtr PhysicalQueryPlanPtr; 00021 //typedef typename OperatorMapper_Helper_Template<Type>::TypedOperator TypedOperator; 00022 00023 PhysicalQueryPlan(TypedOperatorPtr root) : root_(root) { 00024 timeNeeded = 0; 00025 timeEstimated = 0; 00026 } 00027 00028 bool run() { 00029 bool retVal = false; 00030 double begin = double(hype::core::getTimestamp()); 00031 if (root_) { 00032 retVal = root_->run(); 00033 } 00034 timeNeeded = double( hype::core::getTimestamp()) - begin; 00035 return retVal; 00036 } 00037 00038 const Type getResult() { 00039 return root_->getResult(); 00040 } 00041 00042 /* 00043 template <typename CallableType> 00044 void reverse_level_order(CallableType f){ 00045 00046 }*/ 00047 00048 //copy 00049 //print 00050 00051 void print() { 00052 if (timeNeeded > 0) { 00053 printResults(); 00054 } else { 00055 std::cout << "PhysicalQueryPlan:" << std::endl; 00056 root_->print(); 00057 timeEstimated = root_->getRecursiveExecutionTimeInNanoseconds(); 00058 std::cout << "Estimated Time (total): " << timeEstimated / 1000000 << "ms (" << timeEstimated << "ns)" << std::endl; 00059 } 00060 } 00061 00062 void printResults() { 00063 std::cout << "Measured Values:" << std::endl; 00064 root_->printResult(); 00065 std::cout << "Estimated Time (total): " << timeEstimated / 1000000 << "ms (" << timeEstimated << "ns)" << std::endl; 00066 std::cout << "Measured Time (total): " << (timeNeeded) / 1000000 << "ms (" << timeNeeded << "ns)" << std::endl; 00067 std::cout << "Estimation Error: " << 1 - (timeEstimated / timeNeeded) << std::endl; 00068 } 00069 00070 void setTimeNeeded(double ns) { 00071 timeNeeded = ns; 00072 } 00073 private: 00074 double timeNeeded; 00075 double timeEstimated; 00076 TypedOperatorPtr root_; 00077 }; 00078 00079 //typedef boost::shared_ptr<PhysicalQueryPlan> PhysicalQueryPlanPtr; 00080 00081 }; //end namespace queryprocessing 00082 }; //end namespace hype