Column-oriented GPU-accelerated Database Management System
CoGaDB
/home/sebastian/gpudbms/trunk/cogadb/include/query_processing/complex_selection_operator.hpp
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include <core/selection_expression.hpp>
00004 #include <query_processing/definitions.hpp>
00005 #include <core/runtime_configuration.hpp>
00006 
00007 #include "query_processor.hpp"
00008 
00009 namespace CoGaDB {
00010     namespace query_processing {
00011         namespace physical_operator {
00012 
00013             class CPU_ComplexSelection_Operator : public hype::queryprocessing::UnaryOperator<TablePtr, TablePtr> {
00014             public:
00015                 typedef hype::queryprocessing::OperatorMapper_Helper_Template<TablePtr>::TypedOperatorPtr TypedOperatorPtr;
00016 
00017                 CPU_ComplexSelection_Operator(const hype::SchedulingDecision& sched_dec,
00018                         TypedOperatorPtr child,
00019                         const KNF_Selection_Expression& knf_expr,
00020                         hype::DeviceConstraint dev_constr = CoGaDB::RuntimeConfiguration::instance().getGlobalDeviceConstraint(), // hype::DeviceConstraint(),
00021                         MaterializationStatus mat_stat = MATERIALIZE) : UnaryOperator<TablePtr, TablePtr>(sched_dec, child),
00022                 knf_expr_(knf_expr),
00023                 dev_constr_(dev_constr),
00024                 mat_stat_(mat_stat) {
00025                 }
00026 
00027                 virtual bool execute();
00028 //                {
00029 //
00030 //                    
00031 //                    
00032 //#ifdef ENABLE_TWO_PHASE_PHYSICAL_OPTIMIZATION
00033 //                    this->result_ = query_processing::two_phase_physical_optimization_selection(this->getInputData(), knf_expr_, mat_stat_);
00034 //#else
00035 //                    this->result_ = BaseTable::selection(this->getInputData(), knf_expr_, mat_stat_, SERIAL);
00036 //#endif
00037 //                    if (this->result_)
00038 //                        return true;
00039 //                    else
00040 //                        return false;
00041 //                }
00042 
00043                 virtual ~CPU_ComplexSelection_Operator() {
00044                 }
00045             private:
00046                 KNF_Selection_Expression knf_expr_;
00047                 hype::DeviceConstraint dev_constr_;
00048                 MaterializationStatus mat_stat_;
00049             };
00050 
00051 
00052             Physical_Operator_Map_Ptr map_init_function_complex_selection_operator();
00053             TypedOperatorPtr create_CPU_ComplexSelection_Operator(TypedLogicalNode& logical_node, const hype::SchedulingDecision&, TypedOperatorPtr left_child, TypedOperatorPtr right_child);
00054 
00055         }//end namespace physical_operator
00056 
00057         //extern Map_Init_Function init_function_ComplexSelection_operator;
00058 
00059         //Map_Init_Function init_function_ComplexSelection_operator=physical_operator::map_init_function_ComplexSelection_operator; //boost::bind();
00060 
00061         namespace logical_operator {
00062 
00063             class Logical_ComplexSelection : public hype::queryprocessing::TypedNode_Impl<TablePtr, physical_operator::map_init_function_complex_selection_operator> //init_function_ComplexSelection_operator>
00064             {
00065             public:
00066 
00067                 Logical_ComplexSelection(const KNF_Selection_Expression& knf_expr,
00068                         MaterializationStatus mat_stat = MATERIALIZE,
00069                         hype::DeviceConstraint dev_constr = CoGaDB::RuntimeConfiguration::instance().getGlobalDeviceConstraint() // = hype::DeviceConstraint()
00070                         ) : TypedNode_Impl<TablePtr, physical_operator::map_init_function_complex_selection_operator>(false, dev_constr),
00071                 knf_expr_(knf_expr),
00072                 mat_stat_(mat_stat),
00073                 could_not_be_pushed_down_further_(false){
00074                 }
00075 
00076                 virtual unsigned int getOutputResultSize() const {
00077                     return 10;
00078                 }
00079 
00080                 virtual double getCalculatedSelectivity() const {
00081                     return 0.1;
00082                 }
00083 
00084                 virtual std::string getOperationName() const {
00085                     return "COMPLEX_SELECTION";
00086                 }
00087                 std::string toString(bool verbose) const{
00088                     std::string result="COMPLEX_SELECTION";
00089                     if(verbose){
00090                         result+=" (";
00091                         for(unsigned int i=0;i<knf_expr_.disjunctions.size();++i){
00092                             for(unsigned int j=0;j<knf_expr_.disjunctions[i].size();++j){
00093                                 result+=knf_expr_.disjunctions[i][j].toString();
00094                                 if(j+1<knf_expr_.disjunctions[i].size())    
00095                                         result+=" OR ";                                
00096                             }
00097                             
00098                             if(i+1<knf_expr_.disjunctions.size())
00099                                 result+=") AND (";
00100                         }
00101                         result+=")";
00102                     }    
00103                     return result;
00104 
00105                 }
00106                 const KNF_Selection_Expression& getKNF_Selection_Expression() {
00107                     return knf_expr_;
00108                 }
00109 
00110                 const MaterializationStatus& getMaterializationStatus() const {
00111                     return mat_stat_;
00112                 }
00113                 bool couldNotBePushedDownFurther(){
00114                     return could_not_be_pushed_down_further_;
00115                 }
00116                 void couldNotBePushedDownFurther(bool val){
00117                     could_not_be_pushed_down_further_=val;
00118                 }
00119                 
00120 //                virtual TypedOperatorPtr getOptimalOperator(TypedOperatorPtr left_child, TypedOperatorPtr right_child, hype::DeviceTypeConstraint dev_constr){
00121 //                    return TypedOperatorPtr(new CPU_ComplexSelection_Operator(sched_dec,
00122 //                                                            left_child,
00123 //                                                            log_selection_ref.getKNF_Selection_Expression(),
00124 //                                                            log_selection_ref.getDeviceConstraint(),
00125 //                                                            log_selection_ref.getMaterializationStatus()) );
00126 //                }
00127                 
00128             private:
00129                 KNF_Selection_Expression knf_expr_;
00130                 MaterializationStatus mat_stat_;
00131                 /* \brief Bit that shows the optimizer that this selection could not be pushed down more in the query plan*/
00132                 bool could_not_be_pushed_down_further_;
00133             };
00134 
00135         }//end namespace logical_operator
00136 
00137     }//end namespace query_processing
00138 
00139 }; //end namespace CogaDB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines