summaryrefslogtreecommitdiffstats
path: root/relindexif/dbrcindexds.hh
blob: ee740619d39fd7b7140a9bac06a0a622907a4d3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
* This file is part of rasdaman community.
*
* Rasdaman community is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
*/
/*************************************************************
 *
 *
 * PURPOSE:
 * RC index RDBMS adaptor include file.
 *
 *
 * COMMENTS:
 *
 ************************************************************/

#ifndef _DBRCINDEXDS_HH_
#define _DBRCINDEXDS_HH_

#include "reladminif/dbobject.hh"
#include "indexmgr/indexds.hh"
#include "relcatalogif/inlineminterval.hh"

//@ManMemo: Module: {\bf relindexif}
/*@Doc:
Can't have DBRCIndex and DBHierIndex under a common father class because the compiler has problems resolving the DBRef<> functions correctly.

Persistent class for storing data on regular computed indexes.

Beware of the cache when droping the IndexDS classes!

See indexmgr/indexds.hh for documentation.

Data to store:
RAS_RCINDEXDYN
	OId	NUMBER(15,0),
	Count	NUMBER(3,0),
	DynData	VARCHAR(3990)
NB: under Oracle 9i, Dyndata is defined as:
	DynData	BLOB NOT NULL
This should be done for the other systems too,
as VARCHAR usually is subject to charset translation
which we don't want on our binary data.

DynData holds: r_Dimension, OId::OIdType, OId::OIdCounter, InlineMinterval, InlineMinterval
As:
	r_Dimension	dimension	4
	OId::OIdType	myBaseOIdType	2
	OId::OIdCounter	myBaseCounter	4
	unsigned int	mySize		4
	InlineMinterval	myDomain	10 * dim

*/
class DBRCIndexDS	:	public IndexDS
	{
	public:
		DBRCIndexDS(const r_Minterval& definedDomain, unsigned int numberTiles, OId::OIdType theEntryType = OId::BLOBOID);
		/*@Doc:
			Create a new index which handles the domain definedDomain, with tiles of domain
			tileConfig.  As soon as you create this index it will check if the tileConfig fits
			the definedDomain (the tileConfig must completely cover the definedDomain) and then
			allocate as many oids as are neccessary to fill the definedDomain.
		*/

		virtual r_Minterval getCoveredDomain() const;
		/// return defined domain
		
		virtual r_Minterval getAssignedDomain() const;	
		/// return defined domain

		virtual r_Minterval getObjectDomain(unsigned int pos) const;
		/// throw r_Error_FeatureNotSupported
		
		virtual r_Dimension getDimension() const;
		
		virtual void setAssignedDomain(const r_Minterval& domain);
		/// throw r_Error_FeatureNotSupported
		
		virtual unsigned int getSize() const;
		/// this will return the maximum number of tiles that can be stored in the definedDomain.
		
		virtual r_Bytes getTotalStorageSize() const;
		
		virtual bool isValid() const;
		/// returns true

		virtual bool isUnderFull() const;
		/// returns false

		virtual bool isOverFull() const;
		/// returns false

		virtual bool isSameAs(const IndexDS* pix) const; 
		
		virtual bool removeObject(unsigned int pos);
		/// throw r_Error_FeatureNotSupported
		
		virtual bool removeObject(const KeyObject& theKey);
		/// throw r_Error_FeatureNotSupported

		virtual void insertObject(const KeyObject& theKey, unsigned int pos);
		/// throw r_Error_FeatureNotSupported

		virtual void setObject(const KeyObject& theKey, unsigned int pos);
		/// throw r_Error_FeatureNotSupported

		virtual void setObjectDomain(const r_Minterval& dom, unsigned int pos);
		/// throw r_Error_FeatureNotSupported

		virtual const KeyObject& getObject(unsigned int pos) const;
		/// throw r_Error_FeatureNotSupported

		virtual void getObjects(KeyObjectVector& objs) const;
		/// throw r_Error_FeatureNotSupported

		virtual unsigned int getOptimalSize() const;
		/// returns the maximum number of entries that can be stored in this index

		virtual void freeDS();
		
		virtual OId::OIdPrimitive getIdentifier() const;
		
		static r_Bytes BytesPerTupel; 
		/*@Doc:
			tuning parameter.  used to calculate the optimal size of
			an index.  this is also the number of bytes written to the
			database.
		*/

		virtual void printStatus(unsigned int level = 0, std::ostream& stream = std::cout) const;

		virtual ~DBRCIndexDS();

		virtual void destroy();

		virtual IndexDS* getNewInstance() const;
		/// throw r_Error_FeatureNotSupported

		virtual OId::OIdType getBaseOIdType() const;
		
		virtual OId::OIdCounter getBaseCounter() const;

	protected:
		friend class ObjectBroker;
		/*@Doc:
			ObjectBroker needs to access OId constructor
		*/

		DBRCIndexDS(const OId& id);
		/*@Doc:
		*/
	
		virtual void readFromDb() throw (r_Error);
		/*@Doc:
		*/

		virtual void updateInDb() throw (r_Error);
		/*@Doc:
		*/

		virtual void deleteFromDb() throw (r_Error);
		/*@Doc:
		*/

		virtual void insertInDb() throw (r_Error);
		/*@Doc:
		*/

		OId::OIdCounter myBaseCounter;
		/*@Doc:
			The first oid that will be used to store entries.
		*/

		OId::OIdType myBaseOIdType;
		/*@Doc:
			The type of objects to store in this index (most of the time this will be OId::BLOBOID).
		*/

		OId::OIdCounter mySize;

		InlineMinterval myDomain;
		/*@Doc:
			Defined domain of this index.
		*/

		short currentDbRows;
		/*@Doc:
			is needed to support update of index in database
			keeps the number of rows currently taken up in the db by
			this instance
		*/
	};
#endif