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
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/tables/DataMan/TiledStMan.h>
33#include <casacore/casa/Arrays/IPosition.h>
34#include <casacore/casa/BasicSL/String.h>
35
36namespace casacore { //# NAMESPACE CASACORE - BEGIN
37
38//# Forward Declarations
39
40
41// <summary>
42// Tiled Cell Storage Manager.
43// </summary>
44
45// <use visibility=export>
46
47// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
48// </reviewed>
49
50// <prerequisite>
51//# Classes you should understand before using this one.
52// <li> <linkto class=TiledStMan>TiledStMan</linkto>
53// <li> <linkto class=TSMCube>TSMCube</linkto>
54// <li> <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto>
55// for a discussion of the maximum cache size
56// </prerequisite>
57
58// <etymology>
59// TiledCellStMan is the Tiled Storage Manager storing
60// each cell as a separate hypercube.
61// </etymology>
62
63// <synopsis>
64// TiledCellStMan is a derivation from TiledStMan, the abstract
65// tiled storage manager class. A description of the basics
66// of tiled storage managers is given in the
67// <linkto module=Tables:TiledStMan>Tables module</linkto> description.
68// <p>
69// TiledCellStMan allows the user to create a tiled hypercube for
70// each data cell in an automatic way. It is meant to be used for
71// storing regularly shaped data like images (where the table contains
72// a possibly differently shaped image in each row).
73// <p>
74// The TiledCellStMan has the following (extra) properties:
75// <ul>
76// <li> Addition of a row results in the addition of a hypercube in
77// which the data cells in that row will be stored. Thus each row
78// of the hypercolumn is stored in its own hypercube.
79// Note that a hypercolumn has a given dimensionality, so each
80// data cell in the hypercolumn has to match that dimensionality.
81// <li> Although there are multiple hypercubes, an id value is not needed.
82// The row number serves as the id value.
83// <li> Coordinates for the hypercubes can be defined and (of course)
84// their shapes have to match the hypercube shape.
85// Their values have to be put explicitly (so it is not possible
86// to define them via an addHypercube call like in
87// <linkto class=TiledDataStMan>TiledDataStMan</linkto>).
88// <li> It is possible to define a (default) tile shape in the
89// TiledCellStMan constructor. When setting the shape of the
90// array in a row (using <linkto class=ArrayColumn>
91// ArrayColumn::setShape</linkto>), it is possible to override
92// that default for the hypercube in this particular row.
93// </ul>
94// </synopsis>
95
96// <motivation>
97// This tiled storage manager does not require any special action
98// (like calling add/extendHypercube) when used with a column
99// containing variable shaped arrays.
100// </motivation>
101
102// <example>
103// <srcblock>
104// // Define the table description and the columns in it.
105// TableDesc td ("", "1", TableDesc::Scratch);
106// td.addColumn (ArrayColumnDesc<float> ("RA", 1));
107// td.addColumn (ArrayColumnDesc<float> ("Dec", 1));
108// td.addColumn (ArrayColumnDesc<float> ("Velocity", 1));
109// td.addColumn (ArrayColumnDesc<float> ("Image", 3));
110// // Define the 3-dim hypercolumn with its data and coordinate columns.
111// // Note that its dimensionality must match the dimensionality
112// // of the data cells.
113// td.defineHypercolumn ("TSMExample",
114// 3,
115// stringToVector ("Image"),
116// stringToVector ("RA,Dec,Velocity"));
117// // Now create a new table from the description.
118// SetupNewTable newtab("tTiledCellStMan_tmp.data", td, Table::New);
119// // Create a TiledCellStMan storage manager for the hypercolumn
120// // and bind the columns to it.
121// TiledCellStMan sm1 ("TSMExample");
122// newtab.bindAll (sm1);
123// // Create the table.
124// Table table(newtab);
125// // Define the values for the coordinates of the hypercube.
126// Vector<float> raValues(512);
127// Vector<float> DecValues(512);
128// Vector<float> VelocityValues(64);
129// indgen (raValues);
130// indgen (decValues, float(100));
131// indgen (velocityValues, float(200));
132// ArrayColumn<float> ra (table, "RA");
133// ArrayColumn<float> dec (table, "Dec");
134// ArrayColumn<float> velocity (table, "Velocity");
135// ArrayColumn<float> image (table, "Image");
136// Cube<float> imageValues(IPosition(3,512,512,64));
137// indgen (imageValues);
138// // Write some data into the data columns.
139// for (uInt i=0; i<4; i++) {
140// table.addRow();
141// image.put (i, imageValues);
142// ra.put (i, raValues);
143// dec.put (i, decValues);
144// velocity.put (i, velocityValues);
145// }
146// </srcblock>
147// </example>
148
149//# <todo asof="$DATE:$">
150//# A List of bugs, limitations, extensions or planned refinements.
151//# </todo>
152
153
155{
156public:
157 // Create a TiledDataStMan storage manager for the hypercolumn
158 // with the given name. The columns used should have the FixedShape
159 // attribute set.
160 // The hypercolumn name is also the name of the storage manager.
161 // The given tile shape will be used as the default for the hypercube
162 // in each cell. Per cell it can be redefined via ArrayColumn::setShape.
163 // The given maximum cache size (default is unlimited) is persistent,
164 // thus will be reused when the table is read back. Note that the class
165 // <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto>
166 // allows one to overwrite the maximum cache size temporarily.
167 // Its description contains a discussion about the effects of
168 // setting a maximum cache.
169 // <br>The constructor taking a Record expects fields in the record with
170 // the name of the arguments in uppercase. If not defined, their
171 // default value is used.
172 // <group>
173 TiledCellStMan (const String& hypercolumnName,
176 TiledCellStMan (const String& hypercolumnName,
177 const Record& spec);
178 // </group>
179
181
182 // Forbid copy constructor.
184
185 // Forbid assignment.
187
188 // Clone this object.
189 // It does not clone TSMColumn objects possibly used.
191
192 // Get the type name of the data manager (i.e. TiledCellStMan).
194
195 // This tiled storage manager can handle changing array shapes.
197
198 // Set the shape and tile shape of the hypercube.
199 virtual void setShape (rownr_t rownr, TSMCube* hypercube,
200 const IPosition& shape,
201 const IPosition& tileShape);
202
203 // Make the object from the type name string.
204 // This function gets registered in the DataManager "constructor" map.
206 const Record& spec);
207
208private:
209 // Create a TiledCellStMan.
210 // This constructor is private, because it should only be used
211 // by makeObject.
213
214 // Get the default tile shape.
216
217 // Add rows to the storage manager.
218 void addRow64 (rownr_t nrrow);
219
220 // Get the hypercube in which the given row is stored.
221 virtual TSMCube* getHypercube (rownr_t rownr);
222
223 // Get the hypercube in which the given row is stored.
224 // It also returns the position of the row in that hypercube.
225 virtual TSMCube* getHypercube (rownr_t rownr, IPosition& position);
226
227 // Check if the hypercolumn definition fits this storage manager.
228 virtual void setupCheck (const TableDesc& tableDesc,
229 const Vector<String>& dataNames) const;
230
231 // Flush and optionally fsync the data.
232 // It returns a True status if it had to flush (i.e. if data have changed).
233 virtual Bool flush (AipsIO&, Bool fsync);
234
235 // Let the storage manager create files as needed for a new table.
236 // This allows a column with an indirect array to create its file.
237 virtual void create64 (rownr_t nrrow);
238
239 // Read the header info.
240 virtual void readHeader (rownr_t nrrow, Bool firstTime);
241
242
243 //# Declare the data members.
245};
246
247
248
249
250} //# NAMESPACE CASACORE - END
251
252#endif
Abstract base class for a data manager.
String: the storage and methods of handling collections of characters.
Definition String.h:223
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.
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:529
this file contains all the compiler specific defines
Definition mainpage.dox:28
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition ExprNode.h:1991
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