casacore
Loading...
Searching...
No Matches
TiledCellStMan.h
Go to the documentation of this file.
1// # TiledCellStMan.h: Tiled Cell Storage Manager
2// # Copyright (C) 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_TILEDCELLSTMAN_H
27#define TABLES_TILEDCELLSTMAN_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 Cell 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// TiledCellStMan is the Tiled Storage Manager storing
58// each cell as a separate hypercube.
59// </etymology>
60
61// <synopsis>
62// TiledCellStMan 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// TiledCellStMan allows the user to create a tiled hypercube for
68// each data cell in an automatic way. It is meant to be used for
69// storing regularly shaped data like images (where the table contains
70// a possibly differently shaped image in each row).
71// <p>
72// The TiledCellStMan has the following (extra) properties:
73// <ul>
74// <li> Addition of a row results in the addition of a hypercube in
75// which the data cells in that row will be stored. Thus each row
76// of the hypercolumn is stored in its own hypercube.
77// Note that a hypercolumn has a given dimensionality, so each
78// data cell in the hypercolumn has to match that dimensionality.
79// <li> Although there are multiple hypercubes, an id value is not needed.
80// The row number serves as the id value.
81// <li> Coordinates for the hypercubes can be defined and (of course)
82// their shapes have to match the hypercube shape.
83// Their values have to be put explicitly (so it is not possible
84// to define them via an addHypercube call like in
85// <linkto class=TiledDataStMan>TiledDataStMan</linkto>).
86// <li> It is possible to define a (default) tile shape in the
87// TiledCellStMan constructor. When setting the shape of the
88// array in a row (using <linkto class=ArrayColumn>
89// ArrayColumn::setShape</linkto>), it is possible to override
90// that default for the hypercube in this particular row.
91// </ul>
92// </synopsis>
93
94// <motivation>
95// This tiled storage manager does not require any special action
96// (like calling add/extendHypercube) when used with a column
97// containing variable shaped arrays.
98// </motivation>
99
100// <example>
101// <srcblock>
102// // Define the table description and the columns in it.
103// TableDesc td ("", "1", TableDesc::Scratch);
104// td.addColumn (ArrayColumnDesc<float> ("RA", 1));
105// td.addColumn (ArrayColumnDesc<float> ("Dec", 1));
106// td.addColumn (ArrayColumnDesc<float> ("Velocity", 1));
107// td.addColumn (ArrayColumnDesc<float> ("Image", 3));
108// // Define the 3-dim hypercolumn with its data and coordinate columns.
109// // Note that its dimensionality must match the dimensionality
110// // of the data cells.
111// td.defineHypercolumn ("TSMExample",
112// 3,
113// stringToVector ("Image"),
114// stringToVector ("RA,Dec,Velocity"));
115// // Now create a new table from the description.
116// SetupNewTable newtab("tTiledCellStMan_tmp.data", td, Table::New);
117// // Create a TiledCellStMan storage manager for the hypercolumn
118// // and bind the columns to it.
119// TiledCellStMan sm1 ("TSMExample");
120// newtab.bindAll (sm1);
121// // Create the table.
122// Table table(newtab);
123// // Define the values for the coordinates of the hypercube.
124// Vector<float> raValues(512);
125// Vector<float> DecValues(512);
126// Vector<float> VelocityValues(64);
127// indgen (raValues);
128// indgen (decValues, float(100));
129// indgen (velocityValues, float(200));
130// ArrayColumn<float> ra (table, "RA");
131// ArrayColumn<float> dec (table, "Dec");
132// ArrayColumn<float> velocity (table, "Velocity");
133// ArrayColumn<float> image (table, "Image");
134// Cube<float> imageValues(IPosition(3,512,512,64));
135// indgen (imageValues);
136// // Write some data into the data columns.
137// for (uInt i=0; i<4; i++) {
138// table.addRow();
139// image.put (i, imageValues);
140// ra.put (i, raValues);
141// dec.put (i, decValues);
142// velocity.put (i, velocityValues);
143// }
144// </srcblock>
145// </example>
146
147// # <todo asof="$DATE:$">
148// # A List of bugs, limitations, extensions or planned refinements.
149// # </todo>
150
152 public:
153 // Create a TiledDataStMan storage manager for the hypercolumn
154 // with the given name. The columns used should have the FixedShape
155 // attribute set.
156 // The hypercolumn name is also the name of the storage manager.
157 // The given tile shape will be used as the default for the hypercube
158 // in each cell. Per cell it can be redefined via ArrayColumn::setShape.
159 // The given maximum cache size (default is unlimited) is persistent,
160 // thus will be reused when the table is read back. Note that the class
161 // <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto>
162 // allows one to overwrite the maximum cache size temporarily.
163 // Its description contains a discussion about the effects of
164 // setting a maximum cache.
165 // <br>The constructor taking a Record expects fields in the record with
166 // the name of the arguments in uppercase. If not defined, their
167 // default value is used.
168 // <group>
169 TiledCellStMan(const String& hypercolumnName, const IPosition& defaultTileShape,
171 TiledCellStMan(const String& hypercolumnName, const Record& spec);
172 // </group>
173
175
176 // Forbid copy constructor.
178
179 // Forbid assignment.
181
182 // Clone this object.
183 // It does not clone TSMColumn objects possibly used.
185
186 // Get the type name of the data manager (i.e. TiledCellStMan).
188
189 // This tiled storage manager can handle changing array shapes.
191
192 // Set the shape and tile shape of the hypercube.
193 virtual void setShape(rownr_t rownr, TSMCube* hypercube, const IPosition& shape,
194 const IPosition& tileShape);
195
196 // Make the object from the type name string.
197 // This function gets registered in the DataManager "constructor" map.
198 static DataManager* makeObject(const String& dataManagerType, const Record& spec);
199
200 private:
201 // Create a TiledCellStMan.
202 // This constructor is private, because it should only be used
203 // by makeObject.
205
206 // Get the default tile shape.
208
209 // Add rows to the storage manager.
210 void addRow64(rownr_t nrrow);
211
212 // Get the hypercube in which the given row is stored.
213 virtual TSMCube* getHypercube(rownr_t rownr);
214
215 // Get the hypercube in which the given row is stored.
216 // It also returns the position of the row in that hypercube.
217 virtual TSMCube* getHypercube(rownr_t rownr, IPosition& position);
218
219 // Check if the hypercolumn definition fits this storage manager.
220 virtual void setupCheck(const TableDesc& tableDesc, const Vector<String>& dataNames) const;
221
222 // Flush and optionally fsync the data.
223 // It returns a True status if it had to flush (i.e. if data have changed).
224 virtual Bool flush(AipsIO&, Bool fsync);
225
226 // Let the storage manager create files as needed for a new table.
227 // This allows a column with an indirect array to create its file.
228 virtual void create64(rownr_t nrrow);
229
230 // Read the header info.
231 virtual void readHeader(rownr_t nrrow, Bool firstTime);
232
233 // # Declare the data members.
235};
236
237} // namespace casacore
238
239#endif
Abstract base class for a data manager.
String: the storage and methods of handling collections of characters.
Definition String.h:355
virtual Bool flush(AipsIO &, Bool fsync)
Flush and optionally fsync the data.
virtual TSMCube * getHypercube(rownr_t rownr, IPosition &position)
Get the hypercube in which the given row is stored.
static DataManager * makeObject(const String &dataManagerType, const Record &spec)
Make the object from the type name string.
virtual void setupCheck(const TableDesc &tableDesc, const Vector< String > &dataNames) const
Check if the hypercolumn definition fits this storage manager.
virtual void create64(rownr_t nrrow)
Let the storage manager create files as needed for a new table.
TiledCellStMan & operator=(const TiledCellStMan &)=delete
Forbid assignment.
TiledCellStMan(const String &hypercolumnName, const Record &spec)
virtual IPosition defaultTileShape() const
Get the default tile shape.
virtual TSMCube * getHypercube(rownr_t rownr)
Get the hypercube in which the given row is stored.
TiledCellStMan()
Create a TiledCellStMan.
void addRow64(rownr_t nrrow)
Add rows to the storage manager.
TiledCellStMan(const String &hypercolumnName, const IPosition &defaultTileShape, uInt64 maximumCacheSize=0)
Create a TiledDataStMan storage manager for the hypercolumn with the given name.
String dataManagerType() const
Get the type name of the data manager (i.e.
virtual void readHeader(rownr_t nrrow, Bool firstTime)
Read the header info.
Bool canChangeShape() const
This tiled storage manager can handle changing array shapes.
DataManager * clone() const
Clone this object.
TiledCellStMan(const TiledCellStMan &)=delete
Forbid copy constructor.
virtual void setShape(rownr_t rownr, TSMCube *hypercube, const IPosition &shape, const IPosition &tileShape)
Set the shape and tile shape of the hypercube.
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
IPosition shape(const RecordFieldId &) const
Get the actual shape of this 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
unsigned long long uInt64
Definition aipsxtype.h:37