Column-oriented GPU-accelerated Database Management System
CoGaDB
|
00001 #pragma once 00002 00003 #include <query_processing/definitions.hpp> 00004 00005 namespace CoGaDB { 00006 namespace query_processing { 00007 namespace physical_operator { 00008 00009 class CPU_Projection_Operator : public hype::queryprocessing::UnaryOperator<TablePtr, TablePtr> { 00010 public: 00011 typedef hype::queryprocessing::OperatorMapper_Helper_Template<TablePtr>::TypedOperatorPtr TypedOperatorPtr; 00012 00013 CPU_Projection_Operator(const hype::SchedulingDecision& sched_dec, 00014 TypedOperatorPtr child, 00015 const std::list<std::string>& columns_to_select, 00016 MaterializationStatus mat_stat = MATERIALIZE) : UnaryOperator<TablePtr, TablePtr>(sched_dec, child), 00017 columns_to_select_(columns_to_select), 00018 mat_stat_(mat_stat) { 00019 } 00020 00021 virtual bool execute() { 00022 if (!quiet && verbose && debug) std::cout << "Execute Projection CPU" << std::endl; 00023 //const TablePtr sort(TablePtr table, const std::string& column_name, SortOrder order=ASCENDING, MaterializationStatus mat_stat=MATERIALIZE, ComputeDevice comp_dev=CPU); 00024 //this->result_=BaseTable::sort(this->getInputData(), column_name_,order_, mat_stat_,CPU); 00025 this->result_ = BaseTable::projection(this->getInputData(), columns_to_select_, mat_stat_, CPU); 00026 if (this->result_) { 00027 setResultSize(((TablePtr) this->result_)->getNumberofRows()); 00028 return true; 00029 } else 00030 return false; 00031 } 00032 00033 virtual ~CPU_Projection_Operator() { 00034 } 00035 private: 00036 std::list<std::string> columns_to_select_; 00037 MaterializationStatus mat_stat_; 00038 }; 00039 00040 class GPU_Projection_Operator : public hype::queryprocessing::UnaryOperator<TablePtr, TablePtr> { 00041 public: 00042 typedef hype::queryprocessing::OperatorMapper_Helper_Template<TablePtr>::TypedOperatorPtr TypedOperatorPtr; 00043 00044 GPU_Projection_Operator(const hype::SchedulingDecision& sched_dec, 00045 TypedOperatorPtr child, 00046 const std::list<std::string>& columns_to_select, 00047 MaterializationStatus mat_stat = MATERIALIZE) : UnaryOperator<TablePtr, TablePtr>(sched_dec, child), 00048 columns_to_select_(columns_to_select), 00049 mat_stat_(mat_stat) { 00050 } 00051 00052 virtual bool execute() { 00053 if (!quiet && verbose && debug) std::cout << "Execute Projection GPU" << std::endl; 00054 //const TablePtr sort(TablePtr table, const std::string& column_name, SortOrder order=ASCENDING, MaterializationStatus mat_stat=MATERIALIZE, ComputeDevice comp_dev=CPU); 00055 this->result_ = BaseTable::projection(this->getInputData(), columns_to_select_, mat_stat_, GPU); 00056 if (this->result_) { 00057 setResultSize(((TablePtr) this->result_)->getNumberofRows()); 00058 return true; 00059 } else 00060 return false; 00061 } 00062 00063 virtual ~GPU_Projection_Operator() { 00064 } 00065 private: 00066 std::list<std::string> columns_to_select_; 00067 MaterializationStatus mat_stat_; 00068 }; 00069 00070 Physical_Operator_Map_Ptr map_init_function_projection_operator(); 00071 TypedOperatorPtr create_CPU_Projection_Operator(TypedLogicalNode& logical_node, const hype::SchedulingDecision&, TypedOperatorPtr left_child, TypedOperatorPtr right_child); 00072 TypedOperatorPtr create_GPU_Projection_Operator(TypedLogicalNode& logical_node, const hype::SchedulingDecision&, TypedOperatorPtr left_child, TypedOperatorPtr right_child); 00073 00074 }//end namespace physical_operator 00075 00076 //extern Map_Init_Function init_function_Projection_operator; 00077 00078 //Map_Init_Function init_function_Projection_operator=physical_operator::map_init_function_Projection_operator; //boost::bind(); 00079 00080 namespace logical_operator { 00081 00082 class Logical_Projection : public hype::queryprocessing::TypedNode_Impl<TablePtr,physical_operator::map_init_function_projection_operator> //init_function_Projection_operator> 00083 { 00084 public: 00085 00086 Logical_Projection(const std::list<std::string>& columns_to_select, 00087 MaterializationStatus mat_stat = MATERIALIZE) : TypedNode_Impl<TablePtr, physical_operator::map_init_function_projection_operator>(), 00088 columns_to_select_(columns_to_select), 00089 mat_stat_(mat_stat) { 00090 } 00091 00092 virtual unsigned int getOutputResultSize() const { 00093 return 10; 00094 } 00095 00096 virtual double getCalculatedSelectivity() const { 00097 return 1; 00098 } 00099 00100 virtual std::string getOperationName() const { 00101 return "PROJECTION"; 00102 } 00103 00104 std::string toString(bool verbose) const{ 00105 std::string result="PROJECTION"; 00106 if(verbose){ 00107 result+=" ("; 00108 std::list<std::string>::const_iterator cit; 00109 for(cit=columns_to_select_.begin();cit!=columns_to_select_.end();++cit){ 00110 result+=*cit; 00111 if(cit!=--columns_to_select_.end()) 00112 result+=","; 00113 } 00114 result+=")"; 00115 } 00116 return result; 00117 00118 } 00119 00120 const std::list<std::string>& getColumnList() { 00121 return columns_to_select_; 00122 } 00123 00124 const MaterializationStatus& getMaterializationStatus() const { 00125 return mat_stat_; 00126 } 00127 private: 00128 std::list<std::string> columns_to_select_; 00129 MaterializationStatus mat_stat_; 00130 }; 00131 00132 }//end namespace logical_operator 00133 00134 }//end namespace query_processing 00135 00136 }; //end namespace CogaDB