Column-oriented GPU-accelerated Database Management System
CoGaDB
/home/sebastian/gpudbms/trunk/cogadb/include/lookup_table/lookup_table.hpp
Go to the documentation of this file.
00001 #pragma once
00002 #include <core/base_table.hpp>
00003 #include <lookup_table/lookup_column.hpp>
00004 //#include <core/lookup_array.hpp>
00005 
00006 namespace CoGaDB {
00007 
00008     typedef std::vector<LookupColumnPtr> LookupColumnVector;
00009     typedef shared_pointer_namespace::shared_ptr<LookupColumnVector> LookupColumnVectorPtr;
00010 
00011 
00012     //typedef std::pair<TableSchema,TablePtr> LookupTableSchema;
00013 
00014     class LookupTable : public BaseTable {
00015     public:
00016         typedef shared_pointer_namespace::shared_ptr<LookupTable> LookupTablePtr;
00017         /***************** constructors and destructor *****************/
00018         //      LookupTable(const std::string& name, const TableSchema& schema);
00019 
00020         LookupTable(const std::string& name, const TableSchema& schema, const std::vector<LookupColumnPtr>& lookup_columns, const std::vector<ColumnPtr> lookup_arrays_, const std::vector<ColumnPtr> dense_value_arrays = std::vector<ColumnPtr>());
00021 
00022         //      LookupTable(const std::string& name, const std::vector<ColumnPtr>& columns); //if we already have columns, we can use this constructor to pass them in the table without any copy effort
00023         virtual ~LookupTable();
00024         /***************** utility functions *****************/
00025         //      const std::string& getName() const throw();
00026 
00027         //      const TableSchema getSchema() const throw();
00028 
00029         virtual void print();
00031         virtual bool store();
00033         virtual bool load();
00034         virtual bool loadDatafromFile(std::string filepath);
00035 
00036         virtual const TablePtr materialize() const;
00037 
00038         virtual bool addColumn(ColumnPtr);
00039         /************** Lookup Table Algebra *************/
00040 
00041         static const LookupTablePtr aggregate(const std::string& result_lookup_table_name, const LookupTable& lookup_table, const LookupColumn& lookup_col);
00042         static const LookupTablePtr concatenate(const std::string& result_lookup_table_name, const LookupTable& lookup_table1, const LookupTable& lookup_table2);
00043 
00044         /***************** status report *****************/
00045         //      const unsigned int getNumberofRows() const throw();
00046 
00047         virtual bool isMaterialized() const throw ();
00048 
00049         /***************** relational operations *****************/
00050         //      virtual const TablePtr selection(const std::string& column_name, const boost::any& value_for_comparison, const ValueComparator& comp, const ComputeDevice& comp_dev) const;// = 0;
00051 
00052         //      virtual const TablePtr projection(const std::list<std::string>& columns_to_select, const ComputeDevice comp_dev) const;// = 0;
00053 
00054         //      virtual const TablePtr join(TablePtr table, const std::string& join_column_table1, const std::string& join_column_table2, const ComputeDevice comp_dev) const;// = 0;
00055 
00056         //      virtual const TablePtr sort(const std::string& column_name, SortOrder order, ComputeDevice comp_dev) const;// = 0;
00057 
00058         //      virtual const TablePtr groupby(const std::string& grouping_column, const std::string& aggregation_column,  AggregationMethod agg_meth=SUM, ComputeDevice comp_dev=CPU) const;// = 0;
00059         /***************** read and write operations at table level *****************/
00060         virtual const Tuple fetchTuple(const TID& id) const;
00061 
00062         virtual bool insert(const Tuple& t);
00063 
00064         virtual bool update(const std::string& attribute_name, const boost::any& value);
00065 
00066         virtual bool remove(const std::string& attribute_name, const boost::any& value);
00067 
00068         virtual const ColumnPtr getColumnbyName(const std::string& column_name) const throw ();
00069 
00070         const std::vector<LookupColumnPtr>& getLookupColumns() const;
00071         const ColumnVector& getDenseValueColumns();
00072 
00073     protected:
00074         virtual const std::vector<ColumnPtr>& getColumns() const;
00075         const ColumnVectorPtr getLookupArrays();
00076 
00077     private:
00078         std::vector<LookupColumnPtr> lookup_columns_; //Lookup Colums
00079         std::vector<ColumnPtr> lookup_arrays_to_real_columns_; //each column from this list corresponds to the same entry in schema_
00080         std::vector<ColumnPtr> appended_dense_value_columns_;
00081         std::vector<ColumnPtr> all_columns_;
00082     };
00083 
00084     typedef LookupTable::LookupTablePtr LookupTablePtr;
00085 
00086     /* Utility functions*/
00087     const LookupTablePtr createLookupTableforUnaryOperation(const std::string& lookup_table_name, const TablePtr table, PositionListPtr ids);
00088 
00089 }; //end namespace CogaDB
00090 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines