casacore
Loading...
Searching...
No Matches
TiledColumnStMan.h
Go to the documentation of this file.
1// # TiledColumnStMan.h: Tiled Column Storage Manager
2// # Copyright (C) 1995,1996,1997,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_TILEDCOLUMNSTMAN_H
27#define TABLES_TILEDCOLUMNSTMAN_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/DataMan/TiledStMan.h>
32#include <casacore/casa/Arrays/IPosition.h>
33#include <casacore/casa/BasicSL/String.h>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// # Forward Declarations
38
39// <summary>
40// Tiled Column Storage Manager.
41// </summary>
42
43// <use visibility=export>
44
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
46// </reviewed>
47
48// <prerequisite>
49// # Classes you should understand before using this one.
50// <li> <linkto class=TiledStMan>TiledStMan</linkto>
51// <li> <linkto class=TSMCube>TSMCube</linkto>
52// <li> <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto>
53// for a discussion of the maximum cache size
54// </prerequisite>
55
56// <etymology>
57// TiledColumnStMan is the Tiled Storage Manager storing
58// an entire column as one hypercube.
59// </etymology>
60
61// <synopsis>
62// TiledColumnStMan is a derivation from TiledStMan, the abstract
63// tiled storage manager class. A description of the basics
64// of tiled storage managers is given in the
65// <linkto module=Tables:TiledStMan>Tables module</linkto> description.
66// <p>
67// TiledColumnStMan allows the user to create a tiled hypercube for
68// an entire data column and extend it in an automatic way.
69// It is meant to be used for fixed shaped data which have to
70// be accessed in various directions.
71// <p>
72// The TiledColumnStMan has the following (extra) properties:
73// <ul>
74// <li> Addition of a row results in the extension of the hypercube.
75// The data cells in all rows have to have the same shape. Therefore
76// the columns stored by a TiledColumnStMan storage manager
77// have to be fixed shaped (i.e. FixedShape attribute set in their
78// column descriptions).
79// <li> Coordinates for the hypercubes can be defined and (of course)
80// their shapes have to match the hypercube shape.
81// Their values have to be put explicitly (so it is not possible
82// to define them via an extendHypercube call like in
83// <linkto class=TiledDataStMan>TiledDataStMan</linkto>).
84// <li> The tile shape of the hypercube has to be defined by means
85// of the TiledColumnStMan constructor.
86// </ul>
87// </synopsis>
88
89// <motivation>
90// This tiled storage manager does not require any special action
91// (like calling add/extendHypercube) when used with a column
92// containing equally shaped arrays.
93// </motivation>
94
95// <example>
96// <srcblock>
97// // Define the table description and the columns in it.
98// TableDesc td ("", "1", TableDesc::Scratch);
99// td.addColumn (ArrayColumnDesc<float> ("RA", 1));
100// td.addColumn (ArrayColumnDesc<float> ("Dec", 1));
101// td.addColumn (ScalarColumnDesc<float> ("Velocity"));
102// td.addColumn (ArrayColumnDesc<float> ("Image", 2));
103// // Define the 3-dim hypercolumn with its data and coordinate columns.
104// // Note that its dimensionality must be one higher than the dimensionality
105// // of the data cells.
106// td.defineHypercolumn ("TSMExample",
107// 3,
108// stringToVector ("Image"),
109// stringToVector ("RA,Dec,Velocity"));
110// // Now create a new table from the description.
111// SetupNewTable newtab("tTiledColumnStMan_tmp.data", td, Table::New);
112// // Create a TiledColumnStMan storage manager for the hypercolumn
113// // and bind the columns to it.
114// // The tile shape has to be specified for the storage manager.
115// TiledColumnStMan sm1 ("TSMExample", IPosition(3,16,32,32));
116// newtab.bindAll (sm1);
117// // Create the table.
118// Table table(newtab);
119// // Define the values for the coordinates of the hypercube.
120// Vector<float> raValues(512);
121// Vector<float> DecValues(512);
122// indgen (raValues);
123// indgen (decValues, float(100));
124// ArrayColumn<float> ra (table, "RA");
125// ArrayColumn<float> dec (table, "Dec");
126// ScalarColumn<float> velocity (table, "Velocity");
127// ArrayColumn<float> image (table, "Image");
128// Cube<float> imageValues(IPosition(2,512,512));
129// indgen (imageValues);
130// // Write some data into the data columns.
131// for (uInt i=0; i<64; i++) {
132// table.addRow();
133// image.put (i, imageValues);
134// // The RA and Dec have to be put only once, because they
135// // are the same for each row.
136// if (i == 0) {
137// ra.put (i, raValues);
138// dec.put (i, decValues);
139// }
140// velocity.put (i, float(i));
141// }
142// </srcblock>
143// </example>
144
145// # <todo asof="$DATE:$">
146// # A List of bugs, limitations, extensions or planned refinements.
147// # </todo>
148
150 public:
151 // Create a TiledDataStMan storage manager for the hypercolumn
152 // with the given name. The columns used should have the FixedShape
153 // attribute set.
154 // The hypercolumn name is also the name of the storage manager.
155 // The given tile shape will be used.
156 // The given maximum cache size in bytes (default is unlimited) is
157 // persistent, thus will be reused when the table is read back.
158 // Note that the class
159 // <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto>
160 // allows one to overwrite the maximum cache size temporarily.
161 // Its description contains a discussion about the effects of
162 // setting a maximum cache.
163 // <br>The constructor taking a Record expects fields in the record with
164 // the name of the arguments in uppercase. If not defined, their
165 // default value is used.
166 // <group>
167 TiledColumnStMan(const String& hypercolumnName, const IPosition& tileShape,
169 TiledColumnStMan(const String& hypercolumnName, const Record& spec);
170 // </group>
171
173
174 // Forbid copy constructor.
176
177 // Forbid assignment.
179
180 // Clone this object.
181 // It does not clone TSMColumn objects possibly used.
182 virtual DataManager* clone() const;
183
184 // TiledColumnStMan can always access a column.
185 virtual Bool canAccessColumn() const;
186
187 // Get the type name of the data manager (i.e. TiledColumnStMan).
188 virtual String dataManagerType() const;
189
190 // Make the object from the type name string.
191 // This function gets registered in the DataManager "constructor" map.
192 static DataManager* makeObject(const String& dataManagerType, const Record& spec);
193
194 private:
195 // Create a TiledColumnStMan.
196 // This constructor is private, because it should only be used
197 // by makeObject.
199
200 // Get the (default) tile shape.
202
203 // Add rows to the storage manager.
204 // This will extend the hypercube.
205 void addRow64(rownr_t nrrow);
206
207 // Get the hypercube in which the given row is stored.
208 virtual TSMCube* getHypercube(rownr_t rownr);
209
210 // Get the hypercube in which the given row is stored.
211 // It also returns the position of the row in that hypercube.
212 virtual TSMCube* getHypercube(rownr_t rownr, IPosition& position);
213
214 // Check if the hypercolumn definition fits this storage manager.
215 virtual void setupCheck(const TableDesc& tableDesc, const Vector<String>& dataNames) const;
216
217 // Flush and optionally fsync the data.
218 // It returns a True status if it had to flush (i.e. if data have changed).
219 virtual Bool flush(AipsIO&, Bool fsync);
220
221 // Let the storage manager create files as needed for a new table.
222 // This allows a column with an indirect array to create its file.
223 virtual void create64(rownr_t nrrow);
224
225 // Read the header info.
226 virtual void readHeader(rownr_t nrrow, Bool firstTime);
227
228 // # Declare data members.
230};
231
232} // namespace casacore
233
234#endif
Abstract base class for a data manager.
String: the storage and methods of handling collections of characters.
Definition String.h:355
virtual void create64(rownr_t nrrow)
Let the storage manager create files as needed for a new table.
virtual TSMCube * getHypercube(rownr_t rownr)
Get the hypercube in which the given row is stored.
TiledColumnStMan(const String &hypercolumnName, const IPosition &tileShape, uInt64 maximumCacheSize=0)
Create a TiledDataStMan storage manager for the hypercolumn with the given name.
TiledColumnStMan(const TiledColumnStMan &)=delete
Forbid copy constructor.
virtual Bool canAccessColumn() const
TiledColumnStMan can always access a column.
TiledColumnStMan(const String &hypercolumnName, const Record &spec)
virtual void readHeader(rownr_t nrrow, Bool firstTime)
Read the header info.
virtual Bool flush(AipsIO &, Bool fsync)
Flush and optionally fsync the data.
virtual void setupCheck(const TableDesc &tableDesc, const Vector< String > &dataNames) const
Check if the hypercolumn definition fits this storage manager.
virtual DataManager * clone() const
Clone this object.
virtual TSMCube * getHypercube(rownr_t rownr, IPosition &position)
Get the hypercube in which the given row is stored.
virtual IPosition defaultTileShape() const
Get the (default) tile shape.
TiledColumnStMan()
Create a TiledColumnStMan.
TiledColumnStMan & operator=(const TiledColumnStMan &)=delete
Forbid assignment.
static DataManager * makeObject(const String &dataManagerType, const Record &spec)
Make the object from the type name string.
virtual String dataManagerType() const
Get the type name of the data manager (i.e.
void addRow64(rownr_t nrrow)
Add rows to the storage manager.
TiledStMan()
Create a TiledStMan.
const IPosition & tileShape(rownr_t rownr) const
Get the tile shape of the data in the given row.
uInt maximumCacheSize() const
Get the current maximum cache size (in MiB (MibiByte)).
Definition TiledStMan.h:499
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
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
unsigned long long uInt64
Definition aipsxtype.h:37