casacore
Loading...
Searching...
No Matches
StManAipsIO.h
Go to the documentation of this file.
1//# StManAipsIO.h: Storage manager for tables using AipsIO
2//# Copyright (C) 1994,1995,1996,1997,1998,1999,2001
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef TABLES_STMANAIPSIO_H
27#define TABLES_STMANAIPSIO_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/tables/DataMan/MSMBase.h>
33#include <casacore/tables/DataMan/MSMColumn.h>
34#include <casacore/casa/Containers/Block.h>
35#include <casacore/casa/BasicSL/Complex.h>
36#include <casacore/casa/Arrays/IPosition.h>
37#include <casacore/casa/BasicSL/String.h>
38#include <casacore/casa/Utilities/DataType.h>
39#include <casacore/casa/IO/ByteIO.h>
40
41namespace casacore { //# NAMESPACE CASACORE - BEGIN
42
43//# Forward clarations
44class AipsIO;
45class StManAipsIO;
46class StManArrayFile;
47
48
49// <summary>
50// AipsIO table column storage manager class
51// </summary>
52
53// <use visibility=local>
54
55// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
56// </reviewed>
57
58// <prerequisite>
59//# Classes you should understand before using this one.
60// <li> DataManagerColumn
61// </prerequisite>
62
63// <etymology>
64// StManColumnAipsIO handles a column for an AipsIO storage manager.
65// </etymology>
66
67// <synopsis>
68// StManColumnAipsIO is used by StManAipsIO to handle the access to
69// the data in a table column.
70// It is an storage manager based on AipsIO. The entire column is
71// kept in memory and only written when the storage manager closes.
72// When the storage manager gets opened, the entire column gets
73// read back.
74// It fully supports addition and removal of rows.
75//
76// StManColumnAipsIO serves 2 purposes:
77// <ol>
78// <li> It handles a column containing scalar values.
79// <li> It serves as a base class for StManArrayColumnAipsIO and
80// StManIndArrayColumnAipsIO. These classes handle arrays and
81// use StManColumnAipsIO to hold a pointer to the array in each row.
82// </ol>
83//
84// StManColumnAipsIO does not hold a column as a consecutive array,
85// because extending the column (i.e. adding rows) proofed be too
86// expensive due to the repeated copying involved when creating a table
87// (this method was used by the old table system).
88// Instead it has a number of data blocks (extensions) indexed to by a
89// super block. Accessing a row means finding the appropriate extension
90// via a binary search. Because there is only 1 extension when a table is
91// read back, the overhead in finding a row is small.
92// </synopsis>
93
94// <motivation>
95// StManColumnAipsIO handles the standard data types. The class
96// is not templated, but a switch statement is used instead.
97// Templates would cause too many instantiations.
98// </motivation>
99
100// <todo asof="$DATE:$">
101//# A List of bugs, limitations, extensions or planned refinements.
102// </todo>
103
104
106{
107public:
108
109 // Create a column of the given type.
110 // It will maintain a pointer to its parent storage manager.
112
113 // Frees up the storage.
115
116 // Forbid copy constructor.
118
119 // Forbid assignment.
121
122 // Write the column data into AipsIO.
123 // It will successively write all extensions using putData.
124 virtual void putFile (rownr_t nrval, AipsIO&);
125
126 // Read the column data from AipsIO.
127 // One extension gets allocated to hold all rows in the column.
128 virtual void getFile (rownr_t nrval, AipsIO&);
129
130protected:
131 // initData does not do anything (only used in MSMColumn).
132 virtual void initData (void* datap, rownr_t nrval);
133
134 // Put the data (nrval elements) in an extension (starting at datap)
135 // into AipsIO.
136 virtual void putData (void* datap, uInt nrval, AipsIO&);
137
138 // Get data (nrval elements) into an extension (starting at datap
139 // plus the given index).
140 virtual void getData (void* datap, uInt index, uInt nrval, AipsIO&,
141 uInt version);
142};
143
144
145
146
147// <summary>
148// AipsIO table storage manager class
149// </summary>
150
151// <use visibility=export>
152
153// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
154// </reviewed>
155
156// <prerequisite>
157//# Classes you should understand before using this one.
158// <li> DataManager
159// <li> StManColumnAipsIO
160// </prerequisite>
161
162// <etymology>
163// StManAipsIO is the storage manager using AipsIO.
164// </etymology>
165
166// <synopsis>
167// StManAipsIO is a table storage manager based on AipsIO.
168// It holds the data in the columns in memory and writes them to
169// a file when the table gets closed. Only the data of indirect arrays
170// are directly read/written from/to a file.
171// It contains pointers to the underlying StManColumnAipsIO objects,
172// which do the actual data handling.
173//
174// The AipsIO storage manager does fully support addition and removal
175// of rows and columns.
176//
177// All data, except indirect columns, for this storage manager are kept
178// in one file. The file name is the table name appended with
179// .N_AipsIO, where N is the (unique) storage manager sequence number.
180// Each column containing indirect arrays is stored in a separate file
181// using class StManIndArrayColumnAipsIO. The name of such a file is
182// the storage manager file name appended with _cM, where M is a unique
183// column sequence number acquired using function uniqueNr().
184// </synopsis>
185
186// <todo asof="$DATE:$">
187//# A List of bugs, limitations, extensions or planned refinements.
188// </todo>
189
190
191class StManAipsIO : public MSMBase
192{
193public:
194
195 // Create an AipsIO storage manager.
196 // Its name will be blank.
198
199 // Create an AipsIO storage manager with the given name.
200 // Its name can be used later in e.g. Table::addColumn to
201 // add a column to this storage manager.
202 // <br> Note that the 2nd constructor is needed for table creation
203 // from a record specification.
204 // <group>
205 StManAipsIO (const String& storageManagerName);
206 StManAipsIO (const String& storageManagerName, const Record&);
207 // </group>
208
209 virtual ~StManAipsIO();
210
211 // Forbid copy constructor.
212 StManAipsIO (const StManAipsIO&) = delete;
213
214 // Forbid assignment.
216
217 // Clone this object.
218 // It does not clone StManAipsIOColumn objects possibly used.
219 virtual DataManager* clone() const;
220
221 // Get the type name of the data manager (i.e. StManAipsIO).
222 virtual String dataManagerType() const;
223
224 // Get a unique column number for the column
225 // (it is only unique for this storage manager).
226 // This is used by StManIndArrayColumnAipsIO to create a unique file name.
228 { return uniqnr_p++; }
229
230 // Make the object from the string.
231 // This function gets registered in the DataManager "constructor" map.
233 const Record& spec);
234
235 // Open (if needed) the file for indirect arrays with the given mode.
236 // Return a pointer to the object.
238
239
240private:
241 // Flush and optionally fsync the data.
242 // It returns a True status if it had to flush (i.e. if data have changed).
243 virtual Bool flush (AipsIO&, Bool fsync);
244
245 // Let the storage manager create files as needed for a new table.
246 // This allows a column with an indirect array to create its file.
247 virtual void create64 (rownr_t nrrow);
248
249 // Open the storage manager file for an existing table and read in
250 // the data and let the StManColumnAipsIO objects read their data.
251 virtual rownr_t open64 (rownr_t nrrow, AipsIO&);
252
253 // Resync the storage manager with the new file contents.
254 // This is done by clearing the cache.
255 virtual rownr_t resync64 (rownr_t nrrow);
256
257 // Reopen the storage manager files for read/write.
258 virtual void reopenRW();
259
260 // The data manager will be deleted (because all its columns are
261 // requested to be deleted).
262 // So clean up the things needed (e.g. delete files).
263 virtual void deleteManager();
264
265 // Create a column in the storage manager on behalf of a table column.
266 // <group>
267 // Create a scalar column.
268 DataManagerColumn* makeScalarColumn (const String& name, int dataType,
269 const String& dataTypeID);
270 // Create a direct array column.
271 DataManagerColumn* makeDirArrColumn (const String& name, int dataType,
272 const String& dataTypeID);
273 // Create an indirect array column.
274 DataManagerColumn* makeIndArrColumn (const String& name, int dataType,
275 const String& dataTypeID);
276 // </group>
277
278
279 // Unique nr for column in this storage manager.
281 // The file containing the indirect arrays.
283};
284
285
286
287
288} //# NAMESPACE CASACORE - END
289
290#endif
OpenOption
Define the possible ByteIO open options.
Definition ByteIO.h:63
Abstract base class for a data manager.
AipsIO table storage manager class.
virtual rownr_t open64(rownr_t nrrow, AipsIO &)
Open the storage manager file for an existing table and read in the data and let the StManColumnAipsI...
virtual void deleteManager()
The data manager will be deleted (because all its columns are requested to be deleted).
StManAipsIO()
Create an AipsIO storage manager.
StManArrayFile * iosfile_p
The file containing the indirect arrays.
StManAipsIO & operator=(const StManAipsIO &)=delete
Forbid assignment.
virtual rownr_t resync64(rownr_t nrrow)
Resync the storage manager with the new file contents.
virtual Bool flush(AipsIO &, Bool fsync)
Flush and optionally fsync the data.
DataManagerColumn * makeDirArrColumn(const String &name, int dataType, const String &dataTypeID)
Create a direct array column.
uInt uniqnr_p
Unique nr for column in this storage manager.
StManAipsIO(const String &storageManagerName)
Create an AipsIO storage manager with the given name.
DataManagerColumn * makeIndArrColumn(const String &name, int dataType, const String &dataTypeID)
Create an indirect array column.
virtual void create64(rownr_t nrrow)
Let the storage manager create files as needed for a new table.
virtual String dataManagerType() const
Get the type name of the data manager (i.e.
uInt uniqueNr()
Get a unique column number for the column (it is only unique for this storage manager).
StManArrayFile * openArrayFile(ByteIO::OpenOption opt)
Open (if needed) the file for indirect arrays with the given mode.
StManAipsIO(const StManAipsIO &)=delete
Forbid copy constructor.
virtual DataManager * clone() const
Clone this object.
DataManagerColumn * makeScalarColumn(const String &name, int dataType, const String &dataTypeID)
Create a column in the storage manager on behalf of a table column.
static DataManager * makeObject(const String &dataManagerType, const Record &spec)
Make the object from the string.
StManAipsIO(const String &storageManagerName, const Record &)
virtual void reopenRW()
Reopen the storage manager files for read/write.
virtual void putFile(rownr_t nrval, AipsIO &)
Write the column data into AipsIO.
virtual ~StManColumnAipsIO()
Frees up the storage.
StManColumnAipsIO(const StManColumnAipsIO &)=delete
Forbid copy constructor.
virtual void getFile(rownr_t nrval, AipsIO &)
Read the column data from AipsIO.
StManColumnAipsIO(StManAipsIO *stMan, int dataType, Bool byPtr)
Create a column of the given type.
virtual void getData(void *datap, uInt index, uInt nrval, AipsIO &, uInt version)
Get data (nrval elements) into an extension (starting at datap plus the given index).
StManColumnAipsIO & operator=(const StManColumnAipsIO &)=delete
Forbid assignment.
virtual void initData(void *datap, rownr_t nrval)
initData does not do anything (only used in MSMColumn).
virtual void putData(void *datap, uInt nrval, AipsIO &)
Put the data (nrval elements) in an extension (starting at datap) into AipsIO.
virtual int dataType() const
Return the data type of the column.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44