Column-oriented GPU-accelerated Database Management System
CoGaDB
/home/sebastian/gpudbms/trunk/cogadb/include/core/compressed_column.hpp
Go to the documentation of this file.
00001 
00002 #pragma once
00003 
00004 #include <core/column_base_typed.hpp>
00005 #include <core/column.hpp>
00006 
00007 namespace CoGaDB{
00008         
00019 template<class T>
00020 class CompressedColumn : public ColumnBaseTyped<T>{
00021         public:
00022         /***************** constructors and destructor *****************/
00023         CompressedColumn(const std::string& name, AttributeType db_type);
00024         virtual ~CompressedColumn();
00025 
00026         virtual bool insert(const boost::any& new_Value) = 0;
00027         virtual bool insert(const T& new_value) = 0;
00028 
00029         virtual bool update(TID tid, const boost::any& new_value) = 0;
00030         virtual bool update(PositionListPtr tid, const boost::any& new_value) = 0;      
00031         
00032         virtual bool remove(TID tid)=0;
00033         //assumes tid list is sorted ascending
00034         virtual bool remove(PositionListPtr tid)=0;
00035         virtual bool clearContent()=0;
00036 
00037         virtual const boost::any get(TID tid) = 0;
00038         //virtual const boost::any* const getRawData()=0;
00039         virtual void print() const throw() = 0;
00040         virtual size_t size() const throw() = 0;
00041         virtual unsigned int getSizeinBytes() const throw() = 0;
00042 
00043         virtual const ColumnPtr copy() const = 0;
00044         const ColumnPtr gather(PositionListPtr tid_list); 
00045 
00046         virtual bool store(const std::string& path)  = 0;
00047         virtual bool load(const std::string& path)  = 0;
00048         virtual bool isMaterialized() const  throw();
00049         
00050         virtual bool isCompressed() const  throw();     
00051         const ColumnPtr materialize() throw();
00052         
00053         virtual T& operator[](const int index) = 0;
00054 
00055 };
00056 
00057 typedef CompressedColumn<int> CompressedIntegerColumn;
00058 typedef CompressedColumn<float> CompressedFloatColumn;
00059 typedef CompressedColumn<double> CompressedDoubleColumn;
00060 typedef CompressedColumn<std::string> CompressedStringColumn;
00061 
00062 
00063 /***************** Start of Implementation Section ******************/
00064 
00065         
00066         template<class T>
00067         CompressedColumn<T>::CompressedColumn(const std::string& name, AttributeType db_type) : ColumnBaseTyped<T>(name,db_type){
00068 
00069         }
00070 
00071         template<class T>
00072         CompressedColumn<T>::~CompressedColumn(){
00073 
00074         }
00075         
00076         template<class T>
00077         bool CompressedColumn<T>::isMaterialized() const  throw(){
00078                 return false;
00079         }
00080 
00081         template<class T>
00082         bool CompressedColumn<T>::isCompressed() const  throw(){
00083                 return true;
00084         }
00085 
00086         template<class T>
00087         const ColumnPtr CompressedColumn<T>::materialize() throw(){
00088             Column<T>* result = new Column<T>(this->name_,this->db_type_);
00089             std::vector<T>& data = result->getContent();
00090             data.resize(this->size());
00091             for(unsigned int i=0;i<this->size();i++){
00092                 data[i]=(*this)[i];
00093             }
00094             return ColumnPtr(result); 
00095         }        
00096         
00097         template<class T>
00098         const ColumnPtr CompressedColumn<T>::gather(PositionListPtr tid_list){
00099             Column<T>* result = new Column<T>(this->name_,this->db_type_);
00100             std::vector<T>& data = result->getContent();
00101             data.resize(tid_list->size());
00102             for(unsigned int i=0;i<tid_list->size();i++){              
00103                 data[i]=(*this)[(*tid_list)[i]];
00104             }
00105             return ColumnPtr(result); 
00106         }       
00107         
00108 /*
00109         template<class T>
00110         bool CompressedColumn<T>::insert(const boost::any& new_Value){
00111 
00112                 return false;
00113         }
00114 
00115         template<class T>
00116         const boost::any CompressedColumn<T>::get(TID tid){
00117 
00118                 return boost::any();
00119         }
00120 
00121         template<class T>
00122         void CompressedColumn<T>::print() const throw(){
00123 
00124         }
00125         template<class T>
00126         size_t CompressedColumn<T>::size() const throw(){
00127 
00128                 return 0;
00129         }
00130         template<class T>
00131         const ColumnPtr CompressedColumn<T>::copy() const{
00132 
00133                 return ColumnPtr(NULL);
00134         }
00135 
00136         template<class T>
00137         bool CompressedColumn<T>::store(const std::string& path){
00138 
00139                 return std::vector<TID>();
00140         }
00141         template<class T>
00142         bool CompressedColumn<T>::load(const std::string& path){
00143 
00144                 return false;
00145         }
00146         template<class T>
00147         bool CompressedColumn<T>::isMaterialized() const  throw(){
00148 
00149                 return false;
00150         }
00151         
00152         template<class T>
00153         bool CompressedColumn<T>::isCompressed() const  throw(){
00154                 return true;
00155         }
00156 
00157         template<class T>
00158         T& CompressedColumn<T>::operator[](const int index){
00159                 static T t;
00160                 return t;
00161         }
00162 
00163         template<class T>
00164         unsigned int CompressedColumn<T>::getSizeinBytes() const throw(){
00165                 return values_.capacity()*sizeof(T);
00166         }
00167 */
00168 
00169 /***************** End of Implementation Section ******************/
00170 
00171 
00172 
00173 }; //end namespace CogaDB
00174 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines