rasdaman complete source
dbtcindex.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 */
23 #ifndef _DBTCINDEX_HH_
24 #define _DBTCINDEX_HH_
25 
26 #include "hierindex.hh"
27 #include "relblobif/tileid.hh"
28 
29 //@ManMemo: Module: {\bf relindexif}
30 /*@Doc:
31 This class stores data of hierarchical indexes in the database. It is extended to store tiles _inline_. this means it is possible for this class to concatenate several tiles into one large blob and store this blob in the database. the tiles must be inlinetiles. it is only interessting if the size of the tiles is very small (smaller than a disc page).
32 
33 for further information on the methods of this class see hierindexds and indexds interface classes in indexmgr.
34 */
39 class DBTCIndex : public DBHierIndex
40 {
41 public:
42  DBTCIndex(r_Dimension dim, bool isNode);
43  /*@Doc:
44  constructs a new index with dimension dim.
45  instance is imediately persistent
46  */
47 
48  virtual void printStatus(unsigned int level = 0, std::ostream& stream = std::cout) const;
49  /*@Doc:
50  Prints current status of index, in hierarchical format.
51  */
52 
53  ~DBTCIndex();
54  /*@Doc:
55  */
56 
57  virtual bool removeObject(const KeyObject& entry);
58  /*@Doc:
59  will take care of inlined tiles when they are removed.
60  */
61 
62  virtual bool removeObject(unsigned int pos);
63  /*@Doc:
64  will take care of inlined tiles when they are removed.
65  */
66 
67  virtual void removeInlineTile(InlineTile*);
68  /*@Doc:
69  this method is called by inlinetile to removeitselve from the index when it is outlined. the oid of this tile is still stored in the index. do not confuse with removeObejct!
70  */
71 
72  virtual void addInlineTile(InlineTile*);
73  /*@Doc:
74  this method is called by inlinetile when it is told to inline itself into this index.
75  */
76 
78  /*@Doc:
79  called by an inlined inlinetile when it is modified. the index must know about this in order to update the inlinetile in the database.
80  */
81 
82  virtual IndexDS* getNewInstance() const;
83  /*@Doc:
84  used by indexmgr index logic classes to generate new nodes/leaves without knowing what kind of index structure it is operating with. in essence a clone() pattern.
85  */
86 
87 protected:
88  friend class ObjectBroker;
89  /*@Doc:
90  ObjectBroker needs to access OId constructor and getInlineTile
91  */
92 
93  InlineTile* getInlineTile(const OId& itid);
94  /*@Doc:
95  returns the specified inline tile.
96  memory management is done by the DBTCIndex object.
97  */
98 
99 
100  void changeIOIdToBOId();
101  /*@Doc:
102  changes all inlineoids to bloboids. needed in order to be able to use dbhierindex database functionality.
103  */
104 
105 
106  void readyForRemoval(const OId& id);
107  /*@Doc:
108  inlined inlinetiles must be loaded previous to removing them in order to get them outlined.
109  */
110 
111  void changeBOIdToIOId();
112  /*@Doc:
113  changes the bloboids of the inlinetiles which are stored in this index into inlineoids. also neccessary to be able to use dbhierindex functionality.
114  */
115 
116  void registerIOIds();
117  /*@Doc:
118  registers all inline oids with the objectbroker. changeIOIdToBOId is supposed to be called afterwards.
119  */
120 
121  void readInlineTiles() throw (r_Error);
122  /*
123  loads the tiles from the blob tablespace.
124  errors are database errors.
125  */
126 
127  void decideForInlining();
128  /*
129  makes blobtiles to inlinetiles and vice versa.
130  */
131 
132  void insertBlob();
133  /*@Doc:
134  insert empty blob into db
135  */
136 
137  void storeTiles();
138  /*@Doc:
139  write the tiles into the blob space if neccessary.
140  */
141 
142  void writeInlineTiles(char* cells, r_Bytes blobSize) throw (r_Error);
143  /*
144  writes the tiles into the blob tablespace.
145  errors are database errors.
146  */
147 
148  void updateTileIndexMappings() throw (r_Error);
149  /*
150  writes the mappings among dbtcindex and inlinetiles into the database for objectbroker to see.
151  errors are database errors.
152  */
153 
154  DBTCIndex(const OId& id);
155 
156  void setMappingHasChanged();
157  /*@Doc:
158  tells the index that it has to update the table for mapping inlined inlinetile oids to dbtcindexes.
159  */
160 
161  virtual void readFromDb() throw (r_Error);
162 
163  virtual void updateInDb() throw (r_Error);
164 
165  virtual void deleteFromDb() throw (r_Error);
166 
167  virtual void insertInDb() throw (r_Error);
168 
170  /*@Doc:
171  is true when an inlinetile has been added or removed.
172  */
173 
175  /*@Doc:
176  is true when the inlined tiles need to be updated.
177  */
178 
179  bool _isLoaded;
180  /*@Doc:
181  transient, tells if the object has loaded its inlined tiles.
182  */
183 
184  bool hasBlob;
185  /*@Doc:
186  transient, tells if the object has already a blob in the database or not.
187  */
188 
190  /*@Doc:
191  transient, contains pointers to materialised inlinetiles.
192  is filled on demand by loadInlineTiles.
193  */
194 
195 };
196 #endif
void changeIOIdToBOId()
virtual void insertInDb()
bool inlineTileHasChanged
Definition: dbtcindex.hh:174
Definition: hierindex.hh:45
virtual void readFromDb()
virtual void updateInDb()
std::map< double, DBObject *, std::less< double > > DBObjectPMap
Definition: lists.h:91
DBTCIndex(r_Dimension dim, bool isNode)
void updateTileIndexMappings()
Definition: dbtcindex.hh:39
DBObjectPMap inlineTiles
Definition: dbtcindex.hh:189
void changeBOIdToIOId()
void setInlineTileHasChanged()
Definition: keyobject.hh:43
bool _isLoaded
Definition: dbtcindex.hh:179
Definition: objectbroker.hh:71
void setMappingHasChanged()
Definition: oidif.hh:67
virtual void addInlineTile(InlineTile *)
void insertBlob()
virtual IndexDS * getNewInstance() const
void readInlineTiles()
void decideForInlining()
Definition: inlinetile.hh:63
InlineTile * getInlineTile(const OId &itid)
void writeInlineTiles(char *cells, r_Bytes blobSize)
bool hasBlob
Definition: dbtcindex.hh:184
virtual void removeInlineTile(InlineTile *)
void registerIOIds()
virtual void deleteFromDb()
void readyForRemoval(const OId &id)
virtual void printStatus(unsigned int level=0, std::ostream &stream=std::cout) const
void storeTiles()
virtual bool removeObject(const KeyObject &entry)
bool mappingHasChanged
Definition: dbtcindex.hh:169