Column-oriented GPU-accelerated Database Management System
CoGaDB
|
00001 #pragma once 00002 #include <core/global_definitions.hpp> 00003 #include <core/base_table.hpp> 00004 00005 00006 namespace CoGaDB{ 00007 00008 class Table : public BaseTable{ 00009 public: 00010 //typedef std::tr1::shared_ptr<Table> TablePtr; 00011 /***************** constructors and destructor *****************/ 00012 Table(const std::string& name, const TableSchema& schema); 00013 00014 Table(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 00015 virtual ~Table(); 00016 /***************** utility functions *****************/ 00017 // const std::string& getName() const throw(); 00018 00019 // const TableSchema getSchema() const throw(); 00020 00021 virtual void print(); 00023 bool store(); 00025 bool load(); 00026 bool loadDatafromFile(std::string filepath); 00027 00028 virtual const TablePtr materialize() const; 00029 00030 virtual bool addColumn(ColumnPtr); 00031 00032 /***************** status report *****************/ 00033 unsigned int getNumberofRows() const throw(); 00034 // unsigned int getSizeinBytes() const throw(){ 00035 // const std::vector<ColumnPtr>& columns = this->getColumns(); 00036 // unsigned int size_in_bytes=0; 00037 // std::vector<ColumnPtr>::const_iterator cit; 00038 // for(cit=columns.begin();cit!=columns.end();++cit){ 00039 // size_in_bytes+=(*cit)->size(); 00040 // } 00041 // return size_in_bytes; 00042 // } 00043 bool isMaterialized() const throw(); 00044 00045 /***************** relational operations *****************/ 00046 // virtual const TablePtr selection(const std::string& column_name, const boost::any& value_for_comparison, const ValueComparator& comp, const ComputeDevice& comp_dev) const;// = 0; 00047 00048 // virtual const TablePtr projection(const std::list<std::string>& columns_to_select, const ComputeDevice comp_dev) const;// = 0; 00049 00050 // virtual const TablePtr join(TablePtr table, const std::string& join_column_table1, const std::string& join_column_table2, const ComputeDevice comp_dev) const;// = 0; 00051 00052 // virtual const TablePtr sort(const std::string& column_name, SortOrder order, ComputeDevice comp_dev) const;// = 0; 00053 00054 // virtual const TablePtr groupby(const std::string& grouping_column, const std::string& aggregation_column, AggregationMethod agg_meth=SUM, ComputeDevice comp_dev=CPU) const;// = 0; 00055 /***************** read and write operations at table level *****************/ 00056 const Tuple fetchTuple(const TID& id) const; 00057 00058 bool insert(const Tuple& t); 00059 00060 bool update(const std::string& attribute_name, const boost::any& value); 00061 00062 bool remove(const std::string& attribute_name, const boost::any& value); 00063 00064 const ColumnPtr getColumnbyName(const std::string& column_name) const throw(); 00065 00066 protected: 00067 virtual const std::vector<ColumnPtr>& getColumns() const; 00068 00069 00070 /***************** relational operations that return lookup tables *****************/ 00071 // const std::vector<TID> lookup_selection(const std::string& column_name, const boost::any& value_for_comparison, const ValueComparator& comp, const ComputeDevice& comp_dev) const; 00072 00073 // //const TablePtr projection(const std::list<std::string>& columns_to_select, const ComputeDevice comp_dev) const; 00074 00075 // const std::vector<TID_Pair> lookup_join(TablePtr table, const std::string& join_column_table1, const std::string& join_column_table2, const ComputeDevice comp_dev) const; 00076 00077 // const TablePtr lookup_sort(const std::string& column_name, SortOrder order, ComputeDevice comp_dev) const; 00078 00079 // //const TablePtr groupby(const std::string& grouping_column, const std::string& aggregation_column, AggregationMethod agg_meth=SUM, ComputeDevice comp_dev=CPU) const; 00080 00081 00082 std::vector<ColumnPtr> columns_; 00083 00084 // std::string name_; 00085 // TableSchema schema_; 00086 00087 }; 00088 00089 typedef shared_pointer_namespace::shared_ptr<Table> MaterializedTablePtr; 00090 00091 const TableSchema mergeTableSchemas(const TableSchema& schema1, const std::string& join_attributname_table1, 00092 const TableSchema& schema2, const std::string& join_attributname_table2); 00093 00094 00095 //typedef Table::TablePtr TablePtr; 00096 00097 }; //end namespace CogaDB 00098