Column-oriented GPU-accelerated Database Management System
CoGaDB
/home/sebastian/gpudbms/trunk/cogadb/include/compression/tmp/db2/core/base_column.hpp
Go to the documentation of this file.
00001 #pragma once
00002 
00003 //STL includes
00004 #include <typeinfo>
00005 
00006 //boost includes
00007 #include <boost/archive/binary_oarchive.hpp>
00008 #include <boost/archive/binary_iarchive.hpp>
00009 #include <boost/serialization/binary_object.hpp>
00010 #include <boost/serialization/vector.hpp>
00011 #include <boost/serialization/list.hpp>
00012 
00013 //CoGaDB includes
00014 #include <core/global_definitions.hpp>
00015 
00016 namespace CoGaDB {
00017         /* \brief a PositionList is an STL vector of TID values*/
00018         typedef std::vector<TID> PositionList;
00019         /* \brief a PositionListPtr is a a references counted smart pointer to a PositionList object*/
00020         typedef shared_pointer_namespace::shared_ptr<PositionList> PositionListPtr;
00021         /* \brief a PositionListPair is an STL pair consisting of two PositionListPtr objects
00022         *  \details This type is returned by binary operators, e.g., joins*/
00023         typedef std::pair<PositionListPtr,PositionListPtr> PositionListPair;
00024         /* \brief a PositionListPairPtr is a a references counted smart pointer to a PositionListPair object*/
00025         typedef shared_pointer_namespace::shared_ptr<PositionListPair> PositionListPairPtr;
00026 
00027         class Table; //forward declaration
00028 
00040         class ColumnBase {
00041         public:
00043                 typedef shared_pointer_namespace::shared_ptr<ColumnBase> ColumnPtr;
00044                 /***************** constructors and destructor *****************/
00045                 ColumnBase(const std::string& name, AttributeType db_type);
00046                 virtual ~ColumnBase();
00047                 /***************** methods *****************/   
00050                 virtual bool insert(const boost::any& new_Value) = 0;
00053                 virtual bool update(TID tid, const boost::any& new_Value) = 0;
00056                 virtual bool update(PositionListPtr tids, const boost::any& new_value) = 0;             
00059                 virtual bool remove(TID tid) = 0;
00063                 virtual bool remove(PositionListPtr tid) = 0;   
00066                 virtual bool clearContent() = 0;
00070                 virtual const boost::any get(TID tid) = 0; //not const, because operator [] does not provide const return type and the child classes rely on []
00072                 virtual void print() const throw() = 0;
00074                 virtual size_t size() const throw() = 0;
00076                 virtual unsigned int getSizeinBytes() const throw() = 0;
00079                 virtual const ColumnPtr copy() const = 0;
00080                 /***************** relational operations on Columns which return a PositionListPtr/PositionListPairPtr *****************/
00083                 virtual const PositionListPtr sort(SortOrder order=ASCENDING) = 0; 
00086                 virtual const PositionListPtr selection(const boost::any& value_for_comparison, const ValueComparator comp) = 0;
00090                 virtual const PositionListPtr parallel_selection(const boost::any& value_for_comparison, const ValueComparator comp, unsigned int number_of_threads) = 0;
00093                 virtual const PositionListPairPtr hash_join(ColumnPtr join_column)=0;
00096                 virtual const PositionListPairPtr sort_merge_join(ColumnPtr join_column) = 0;
00099                 virtual const PositionListPairPtr nested_loop_join(ColumnPtr join_column) = 0;
00100                 /***************** column algebra operations *****************/ 
00103                 virtual bool add(const boost::any& new_Value) = 0;
00106                 virtual bool add(ColumnPtr column) = 0;
00109                 virtual bool minus(const boost::any& new_Value) = 0;
00112                 virtual bool minus(ColumnPtr column) = 0;       
00115                 virtual bool multiply(const boost::any& new_Value) = 0;
00118                 virtual bool multiply(ColumnPtr column) = 0;
00121                 virtual bool division(const boost::any& new_Value) = 0; 
00124                 virtual bool division(ColumnPtr column) = 0;    
00125                 /***************** persistency operations *****************/            
00128                 virtual bool store(const std::string& path) = 0;
00132                 virtual bool load(const std::string& path) = 0;
00135                 /***************** misc operations *****************/   
00136                 virtual bool isMaterialized() const throw() = 0;
00139                 virtual bool isCompressed() const throw() = 0;  
00141                 virtual const std::type_info& type() const throw() = 0;
00143                 AttributeType getType() const throw();
00146                 const std::string getName() const throw();
00147 
00148         protected:
00150                 std::string name_;
00152                 AttributeType db_type_;
00153                 //      Table& table_;
00154         };
00155 
00157         typedef ColumnBase::ColumnPtr ColumnPtr;
00158 
00159         typedef std::vector<ColumnPtr> ColumnVector;
00160         typedef shared_pointer_namespace::shared_ptr<ColumnVector> ColumnVectorPtr;
00161 
00163         const ColumnPtr createColumn(AttributeType type, const std::string& name);
00164 
00165 }; //end namespace CogaDB
00166 
00167 
00168 //extend boost namespace to add serialization feature to my own types
00169 namespace boost {
00170         namespace serialization {
00171 
00172                 template<class Archive>
00173                 void serialize(Archive & ar, std::pair<CoGaDB::AttributeType,std::string> & pair, const unsigned int ) //version)
00174                 {
00175 
00176                         ar & pair.first;
00177                         ar & pair.second;
00178 
00179                 }
00180 
00181         } // namespace serialization
00182 } // namespace boost
00183 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines