ObjectLocation.h

00001 /* 
00002    EyeDB Object Database Management System
00003    Copyright (C) 1994-2008 SYSRA
00004    
00005    EyeDB is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009    
00010    EyeDB is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014    
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA 
00018 */
00019 
00020 /*
00021    Author: Eric Viara <viara@sysra.com>
00022 */
00023 
00024 
00025 #ifndef _EYEDB_OBJECT_LOCATION_H
00026 #define _EYEDB_OBJECT_LOCATION_H
00027 
00028 namespace eyedb {
00029 
00035   class Database;
00036   class Datafile;
00037 
00041   class ObjectLocation {
00042 
00043   public:
00044     struct Info {
00045       unsigned int size;
00046       unsigned int slot_start_num;
00047       unsigned int slot_end_num;
00048       unsigned int dat_start_pagenum;
00049       unsigned int dat_end_pagenum;
00050       unsigned int omp_start_pagenum;
00051       unsigned int omp_end_pagenum;
00052       unsigned int dmp_start_pagenum;
00053       unsigned int dmp_end_pagenum;
00054     };
00055 
00060     const Oid &getOid() const {return oid;}
00061 
00066     short getDspid() const {return dspid;}
00067 
00072     short getDatid() const {return datid;}
00073 
00078     unsigned int getSize() const {return info.size;}
00079 
00084     const Info & getInfo() const {return info;}
00085 
00086 
00091     unsigned int getSlotStartNum() const {return info.slot_start_num;}
00092 
00097     unsigned int getSlotEndNum() const {return info.slot_end_num;}
00098 
00103     unsigned int getDatStartPagenum() const {return info.dat_start_pagenum;}
00104 
00109     unsigned int getDatEndPagenum() const {return info.dat_end_pagenum;}
00110 
00115     unsigned int getOmpStartPagenum() const {return info.omp_start_pagenum;}
00116 
00121     unsigned int getOmpEndPagenum() const {return info.omp_end_pagenum;}
00122 
00127     unsigned int getDmpStartPagenum() const {return info.dmp_start_pagenum;}
00128 
00133     unsigned int getDmpEndPagenum() const {return info.dmp_end_pagenum;}
00134 
00135 
00140     ObjectLocation(Database *_db = 0) { db = _db; }
00141 
00149     ObjectLocation(const Oid &_oid, short _dspid, short _datid,
00150                    const Info &_info) {
00151       set(_oid, _dspid, _datid, _info);
00152     }
00153 
00159     ObjectLocation& operator()(Database *_db) {db = _db; return *this;}
00160 
00168     void set(const Oid &_oid, short _dspid, short _datid, const Info &_info) {
00169       oid = _oid;
00170       dspid = _dspid;
00171       datid = _datid;
00172       info = _info;
00173     }
00174 
00175   private:
00176     Database *db;
00177     Oid oid;
00178     unsigned short dspid;
00179     unsigned short datid;
00180     Info info;
00181     friend std::ostream &operator<<(std::ostream &, const ObjectLocation &);
00182   };
00183 
00184   std::ostream &operator<<(std::ostream &, const ObjectLocation &);
00185 
00186   class PageStats;
00187 
00188   class ObjectLocationArray {
00189 
00190   public:
00191     ObjectLocationArray(Database *_db = 0) {db = _db; locs = 0; cnt = 0;}
00192     ObjectLocationArray(ObjectLocation *, unsigned int);
00193 
00194     void set(ObjectLocation *, unsigned int);
00195     unsigned int getCount() const {return cnt;}
00196     const ObjectLocation & getLocation(int idx) const {
00197       return locs[idx];
00198     }
00199 
00200     ObjectLocationArray& operator()(Database *_db) {db = _db; return *this;}
00201     PageStats *computePageStats(Database *db = 0);
00202     ~ObjectLocationArray();
00203 
00204   private:
00205     void garbage();
00206     unsigned int cnt;
00207     ObjectLocation *locs;
00208     Database *db;
00209     friend std::ostream &operator<<(std::ostream &, const ObjectLocationArray &);
00210   };
00211 
00212   class PageStats
00213   {
00214   public:
00215     PageStats(Database *);
00216     void add(const ObjectLocation &loc);
00217     ~PageStats();
00218 
00219     struct PGS {
00220       const Datafile *datafile;
00221       unsigned int slotsize;
00222       unsigned int slotpow2;
00223 
00224       unsigned long long totalsize;
00225       unsigned long long totalsize_align;
00226 
00227       unsigned int totaldatpages_cnt;
00228       unsigned int totaldatpages_max;
00229       char *totaldatpages;
00230 
00231       unsigned int totaldmppages_max;
00232       unsigned int totaldmppages_cnt;
00233       char *totaldmppages;
00234 
00235       unsigned int totalomppages_max;
00236       unsigned int totalomppages_cnt;
00237       char *totalomppages;
00238 
00239       unsigned int oid_cnt;
00240 
00241       void init(const Datafile *);
00242       void add(const ObjectLocation &loc);
00243     };
00244 
00245     const PageStats::PGS *getPGS() const {return pgs;}
00246   private:
00247     PGS *pgs;
00248     const Datafile **datafiles;
00249     unsigned int datafile_cnt;
00250     friend std::ostream &operator<<(std::ostream &os, const PageStats &pgs);
00251   };
00252 
00253   std::ostream &operator<<(std::ostream &, const ObjectLocationArray &);
00254   std::ostream &operator<<(std::ostream &os, const PageStats &pgs);
00255 
00260 }
00261 
00262 #endif

Generated on Mon Dec 22 18:15:59 2008 for eyedb by  doxygen 1.5.3