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// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/DataMan/MSMBase.h>
32#include <casacore/tables/DataMan/MSMColumn.h>
33#include <casacore/casa/Containers/Block.h>
34#include <casacore/casa/BasicSL/Complex.h>
35#include <casacore/casa/Arrays/IPosition.h>
36#include <casacore/casa/BasicSL/String.h>
37#include <casacore/casa/Utilities/DataType.h>
38#include <casacore/casa/IO/ByteIO.h>
39
40namespace casacore { // # NAMESPACE CASACORE - BEGIN
41
42// # Forward clarations
43class AipsIO;
44class StManAipsIO;
45class StManArrayFile;
46
47// <summary>
48// AipsIO table column storage manager class
49// </summary>
50
51// <use visibility=local>
52
53// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
54// </reviewed>
55
56// <prerequisite>
57// # Classes you should understand before using this one.
58// <li> DataManagerColumn
59// </prerequisite>
60
61// <etymology>
62// StManColumnAipsIO handles a column for an AipsIO storage manager.
63// </etymology>
64
65// <synopsis>
66// StManColumnAipsIO is used by StManAipsIO to handle the access to
67// the data in a table column.
68// It is an storage manager based on AipsIO. The entire column is
69// kept in memory and only written when the storage manager closes.
70// When the storage manager gets opened, the entire column gets
71// read back.
72// It fully supports addition and removal of rows.
73//
74// StManColumnAipsIO serves 2 purposes:
75// <ol>
76// <li> It handles a column containing scalar values.
77// <li> It serves as a base class for StManArrayColumnAipsIO and
78// StManIndArrayColumnAipsIO. These classes handle arrays and
79// use StManColumnAipsIO to hold a pointer to the array in each row.
80// </ol>
81//
82// StManColumnAipsIO does not hold a column as a consecutive array,
83// because extending the column (i.e. adding rows) proofed be too
84// expensive due to the repeated copying involved when creating a table
85// (this method was used by the old table system).
86// Instead it has a number of data blocks (extensions) indexed to by a
87// super block. Accessing a row means finding the appropriate extension
88// via a binary search. Because there is only 1 extension when a table is
89// read back, the overhead in finding a row is small.
90// </synopsis>
91
92// <motivation>
93// StManColumnAipsIO handles the standard data types. The class
94// is not templated, but a switch statement is used instead.
95// Templates would cause too many instantiations.
96// </motivation>
97
98// <todo asof="$DATE:$">
99// # A List of bugs, limitations, extensions or planned refinements.
100// </todo>
101
103 public:
104 // Create a column of the given type.
105 // It will maintain a pointer to its parent storage manager.
107
108 // Frees up the storage.
110
111 // Forbid copy constructor.
113
114 // Forbid assignment.
116
117 // Write the column data into AipsIO.
118 // It will successively write all extensions using putData.
119 virtual void putFile(rownr_t nrval, AipsIO&);
120
121 // Read the column data from AipsIO.
122 // One extension gets allocated to hold all rows in the column.
123 virtual void getFile(rownr_t nrval, AipsIO&);
124
125 protected:
126 // initData does not do anything (only used in MSMColumn).
127 virtual void initData(void* datap, rownr_t nrval);
128
129 // Put the data (nrval elements) in an extension (starting at datap)
130 // into AipsIO.
131 virtual void putData(void* datap, uInt nrval, AipsIO&);
132
133 // Get data (nrval elements) into an extension (starting at datap
134 // plus the given index).
135 virtual void getData(void* datap, uInt index, uInt nrval, AipsIO&, uInt version);
136};
137
138// <summary>
139// AipsIO table storage manager class
140// </summary>
141
142// <use visibility=export>
143
144// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
145// </reviewed>
146
147// <prerequisite>
148// # Classes you should understand before using this one.
149// <li> DataManager
150// <li> StManColumnAipsIO
151// </prerequisite>
152
153// <etymology>
154// StManAipsIO is the storage manager using AipsIO.
155// </etymology>
156
157// <synopsis>
158// StManAipsIO is a table storage manager based on AipsIO.
159// It holds the data in the columns in memory and writes them to
160// a file when the table gets closed. Only the data of indirect arrays
161// are directly read/written from/to a file.
162// It contains pointers to the underlying StManColumnAipsIO objects,
163// which do the actual data handling.
164//
165// The AipsIO storage manager does fully support addition and removal
166// of rows and columns.
167//
168// All data, except indirect columns, for this storage manager are kept
169// in one file. The file name is the table name appended with
170// .N_AipsIO, where N is the (unique) storage manager sequence number.
171// Each column containing indirect arrays is stored in a separate file
172// using class StManIndArrayColumnAipsIO. The name of such a file is
173// the storage manager file name appended with _cM, where M is a unique
174// column sequence number acquired using function uniqueNr().
175// </synopsis>
176
177// <todo asof="$DATE:$">
178// # A List of bugs, limitations, extensions or planned refinements.
179// </todo>
180
181class StManAipsIO : public MSMBase {
182 public:
183 // Create an AipsIO storage manager.
184 // Its name will be blank.
186
187 // Create an AipsIO storage manager with the given name.
188 // Its name can be used later in e.g. Table::addColumn to
189 // add a column to this storage manager.
190 // <br> Note that the 2nd constructor is needed for table creation
191 // from a record specification.
192 // <group>
193 StManAipsIO(const String& storageManagerName);
194 StManAipsIO(const String& storageManagerName, const Record&);
195 // </group>
196
197 virtual ~StManAipsIO();
198
199 // Forbid copy constructor.
200 StManAipsIO(const StManAipsIO&) = delete;
201
202 // Forbid assignment.
204
205 // Clone this object.
206 // It does not clone StManAipsIOColumn objects possibly used.
207 virtual DataManager* clone() const;
208
209 // Get the type name of the data manager (i.e. StManAipsIO).
210 virtual String dataManagerType() const;
211
212 // Get a unique column number for the column
213 // (it is only unique for this storage manager).
214 // This is used by StManIndArrayColumnAipsIO to create a unique file name.
215 uInt uniqueNr() { return uniqnr_p++; }
216
217 // Make the object from the string.
218 // This function gets registered in the DataManager "constructor" map.
219 static DataManager* makeObject(const String& dataManagerType, const Record& spec);
220
221 // Open (if needed) the file for indirect arrays with the given mode.
222 // Return a pointer to the object.
224
225 private:
226 // Flush and optionally fsync the data.
227 // It returns a True status if it had to flush (i.e. if data have changed).
228 virtual Bool flush(AipsIO&, Bool fsync);
229
230 // Let the storage manager create files as needed for a new table.
231 // This allows a column with an indirect array to create its file.
232 virtual void create64(rownr_t nrrow);
233
234 // Open the storage manager file for an existing table and read in
235 // the data and let the StManColumnAipsIO objects read their data.
236 virtual rownr_t open64(rownr_t nrrow, AipsIO&);
237
238 // Resync the storage manager with the new file contents.
239 // This is done by clearing the cache.
240 virtual rownr_t resync64(rownr_t nrrow);
241
242 // Reopen the storage manager files for read/write.
243 virtual void reopenRW();
244
245 // The data manager will be deleted (because all its columns are
246 // requested to be deleted).
247 // So clean up the things needed (e.g. delete files).
248 virtual void deleteManager();
249
250 // Create a column in the storage manager on behalf of a table column.
251 // <group>
252 // Create a scalar column.
254 // Create a direct array column.
256 // Create an indirect array column.
258 // </group>
259
260 // Unique nr for column in this storage manager.
262 // The file containing the indirect arrays.
264};
265
266} // namespace casacore
267
268#endif
OpenOption
Define the possible ByteIO open options.
Definition ByteIO.h:60
Abstract base class for a data manager.
MSMBase()
Create a memory storage manager.
MSMColumn(MSMBase *smptr, int dataType, Bool byPtr)
Create a column of the given type.
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.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
String name() const
Return the name of the field.
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
DataType dataType(const RecordFieldId &) const