rasdaman complete source
hierindex.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 _DBHIERINDEX_HH_
24 #define _DBHIERINDEX_HH_
25 
26 #include "reladminif/dbobject.hh"
27 #include "indexmgr/hierindexds.hh"
29 
30 //@ManMemo: Module: {\bf relindexif}
31 /*@Doc:
32 This class stores data of hierarchical indexes in the database.
33 
34 There should be another interface to include the isLeaf/isRoot/...
35 functionality.
36 
37 Beware of the cache when droping the IndexDS classes!
38 
39 See indexmgr/hierindexds.hh and indexmgr/indexds.hh for documentation.
40 */
45 class DBHierIndex : public HierIndexDS
46 {
47 public:
48  DBHierIndex(r_Dimension dim, bool isNode, bool makePersistent);
49  /*@Doc:
50  constructs a new index with type ixType, dimension dim.
51  if isNode is true the index behaves as a node, else as
52  a leaf instance is imediately persistent
53  */
54 
55  virtual double getOccupancy() const;
56 
57  HierIndexDS* getParent() const;
58 
59  void setParent(const HierIndexDS* newPa);
60 
61  virtual void setIsNode(bool beNode);
62 
63  virtual bool isLeaf() const;
64 
65  virtual bool isRoot() const;
66  /*@Doc:
67  is a check for a valid myParent OId
68  */
69 
70  virtual unsigned int getHeight() const;
71 
72  virtual unsigned int getHeightOfTree() const;
73  /*@Doc:
74  Recursive function to get height of the tree.
75  */
76 
77  virtual unsigned int getHeightToRoot() const;
78  /*@Doc:
79  Recursive function to get the number of levels to the root.
80  */
81 
82  virtual unsigned int getHeightToLeaf() const;
83  /*@Doc:
84  Recursive function to get the number of levels to the
85  leafs.
86  */
87 
88  virtual unsigned int getTotalEntryCount() const;
89 
90  virtual unsigned int getTotalNodeCount() const;
91 
92  virtual unsigned int getTotalLeafCount() const;
93 
94  virtual r_Minterval getCoveredDomain() const;
95 
96  virtual r_Minterval getAssignedDomain() const;
97 
98  virtual r_Minterval getObjectDomain(unsigned int pos) const;
99 
100  virtual r_Dimension getDimension() const;
101 
102  virtual void setAssignedDomain(const r_Minterval& domain);
103 
104  virtual unsigned int getSize() const;
105 
106  virtual r_Bytes getTotalStorageSize() const;
107 
108  virtual bool isValid() const;
109 
110  virtual bool isUnderFull() const;
111 
112  virtual bool isOverFull() const;
113 
114  virtual bool isSameAs(const IndexDS* pix) const;
115 
116  virtual bool removeObject(unsigned int pos);
117 
118  virtual bool removeObject(const KeyObject& theKey);
119 
120  virtual void insertObject(const KeyObject& theKey, unsigned int pos);
121 
122  virtual void setObject(const KeyObject& theKey, unsigned int pos);
123 
124  virtual void setObjectDomain(const r_Minterval& dom, unsigned int pos);
125 
126  virtual const KeyObject& getObject(unsigned int pos) const;
127 
128  virtual void getObjects(KeyObjectVector& objs) const;
129 
130  virtual unsigned int getOptimalSize() const;
131 
132  static unsigned int getOptimalSize(r_Dimension dim);
133  /*@Doc:
134  Used to calculate the optimal number of entries for
135  that dimension
136  */
137 
138  virtual void freeDS();
139 
140  virtual OId::OIdPrimitive getIdentifier() const;
141 
142  static r_Bytes BytesPerTupel;
143  /*@Doc:
144  tuning parameter. used to calculate the optimal size of
145  an index. this is also the number of bytes written to the
146  database.
147  */
148 
149  virtual void printStatus(unsigned int level = 0, std::ostream& stream = std::cout) const;
150 
151  virtual ~DBHierIndex();
152 
153  virtual void destroy();
154 
155  virtual IndexDS* getNewInstance() const;
156 
157  virtual BinaryRepresentation getBinaryRepresentation() const throw (r_Error);
158 
159  virtual void setBinaryRepresentation(const BinaryRepresentation&) throw (r_Error);
160 
161 protected:
162  friend class ObjectBroker;
163  /*@Doc:
164  ObjectBroker needs to access OId constructor
165  */
166 
167  DBHierIndex(const OId& id);
168  /*@Doc:
169  */
170 
171  virtual void readFromDb() throw (r_Error);
172  /*@Doc:
173  */
174 
175  virtual void updateInDb() throw (r_Error);
176  /*@Doc:
177  */
178 
179  virtual void deleteFromDb() throw (r_Error);
180  /*@Doc:
181  */
182 
183  virtual void insertInDb() throw (r_Error);
184  /*@Doc:
185  */
186 
187  void extendCoveredDomain(const r_Minterval& newTilesExtents) throw (r_Edim_mismatch, r_Eno_interval);
188  /*@Doc:
189  Recalculates the current domain of this index to
190  include newTilesExtents.
191  */
192 
194  /*@Doc:
195  persistent, identifies the parent
196  */
197 
198  bool _isNode;
199  /*@Doc:
200  persistent, tells the object what it is.
201  */
202 
203 
204  unsigned int maxSize;
205  /*@Doc:
206  Non persistent attribute. a cache so the maxSize does not have to be calculated all the time.
207  */
208 
210 
212  /*@Doc:
213  Defined domain of this index.
214  */
215 
217  /*@Doc:
218  is needed to support update of index in database
219  keeps the number of rows currently taken up in the db by
220  this instance
221  */
222 };
223 #endif
Definition: hierindex.hh:45
virtual void getObjects(KeyObjectVector &objs) const
virtual BinaryRepresentation getBinaryRepresentation() const
static r_Bytes BytesPerTupel
Definition: hierindex.hh:142
virtual void setBinaryRepresentation(const BinaryRepresentation &)
virtual void destroy()
virtual r_Bytes getTotalStorageSize() const
virtual IndexDS * getNewInstance() const
virtual double getOccupancy() const
virtual bool isRoot() const
virtual unsigned int getHeightToLeaf() const
std::vector< KeyObject > KeyObjectVector
Definition: lists.h:79
virtual bool isLeaf() const
unsigned int maxSize
Definition: hierindex.hh:204
virtual const KeyObject & getObject(unsigned int pos) const
Definition: inlineminterval.hh:44
virtual unsigned int getSize() const
virtual unsigned int getHeightOfTree() const
virtual void setIsNode(bool beNode)
HierIndexDS * getParent() const
virtual void printStatus(unsigned int level=0, std::ostream &stream=std::cout) const
virtual r_Minterval getObjectDomain(unsigned int pos) const
virtual bool isSameAs(const IndexDS *pix) const
Definition: keyobject.hh:43
virtual ~DBHierIndex()
Definition: objectbroker.hh:71
virtual unsigned int getOptimalSize() const
virtual void deleteFromDb()
Definition: oidif.hh:67
DBHierIndex(r_Dimension dim, bool isNode, bool makePersistent)
virtual void updateInDb()
bool _isNode
Definition: hierindex.hh:198
virtual OId::OIdPrimitive getIdentifier() const
short currentDbRows
Definition: hierindex.hh:216
virtual r_Minterval getAssignedDomain() const
virtual void setObject(const KeyObject &theKey, unsigned int pos)
double OIdPrimitive
Definition: oidif.hh:102
OId parent
Definition: hierindex.hh:193
virtual r_Dimension getDimension() const
virtual unsigned int getTotalLeafCount() const
void extendCoveredDomain(const r_Minterval &newTilesExtents)
virtual unsigned int getHeight() const
virtual unsigned int getHeightToRoot() const
virtual bool isOverFull() const
virtual bool removeObject(unsigned int pos)
virtual unsigned int getTotalEntryCount() const
virtual void insertObject(const KeyObject &theKey, unsigned int pos)
virtual r_Minterval getCoveredDomain() const
virtual void freeDS()
virtual bool isUnderFull() const
InlineMinterval myDomain
Definition: hierindex.hh:211
KeyObjectVector myKeyObjects
Definition: hierindex.hh:209
virtual bool isValid() const
virtual void setObjectDomain(const r_Minterval &dom, unsigned int pos)
virtual void setAssignedDomain(const r_Minterval &domain)
Definition: binaryrepresentation.hh:26
virtual void insertInDb()
void setParent(const HierIndexDS *newPa)
virtual void readFromDb()
virtual unsigned int getTotalNodeCount() const