casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id$
27 
28 #ifndef TABLES_TILEDCOLUMNSTMAN_H
29 #define TABLES_TILEDCOLUMNSTMAN_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 
41 
42 // <summary>
43 // Tiled Column Storage Manager.
44 // </summary>
45 
46 // <use visibility=export>
47 
48 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
49 // </reviewed>
50 
51 // <prerequisite>
52 //# Classes you should understand before using this one.
53 // <li> <linkto class=TiledStMan>TiledStMan</linkto>
54 // <li> <linkto class=TSMCube>TSMCube</linkto>
55 // <li> <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto>
56 // for a discussion of the maximum cache size
57 // </prerequisite>
58 
59 // <etymology>
60 // TiledColumnStMan is the Tiled Storage Manager storing
61 // an entire column as one hypercube.
62 // </etymology>
63 
64 // <synopsis>
65 // TiledColumnStMan is a derivation from TiledStMan, the abstract
66 // tiled storage manager class. A description of the basics
67 // of tiled storage managers is given in the
68 // <linkto module=Tables:TiledStMan>Tables module</linkto> description.
69 // <p>
70 // TiledColumnStMan allows the user to create a tiled hypercube for
71 // an entire data column and extend it in an automatic way.
72 // It is meant to be used for fixed shaped data which have to
73 // be accessed in various directions.
74 // <p>
75 // The TiledColumnStMan has the following (extra) properties:
76 // <ul>
77 // <li> Addition of a row results in the extension of the hypercube.
78 // The data cells in all rows have to have the same shape. Therefore
79 // the columns stored by a TiledColumnStMan storage manager
80 // have to be fixed shaped (i.e. FixedShape attribute set in their
81 // column descriptions).
82 // <li> Coordinates for the hypercubes can be defined and (of course)
83 // their shapes have to match the hypercube shape.
84 // Their values have to be put explicitly (so it is not possible
85 // to define them via an extendHypercube call like in
86 // <linkto class=TiledDataStMan>TiledDataStMan</linkto>).
87 // <li> The tile shape of the hypercube has to be defined by means
88 // of the TiledColumnStMan constructor.
89 // </ul>
90 // </synopsis>
91 
92 // <motivation>
93 // This tiled storage manager does not require any special action
94 // (like calling add/extendHypercube) when used with a column
95 // containing equally shaped arrays.
96 // </motivation>
97 
98 // <example>
99 // <srcblock>
100 // // Define the table description and the columns in it.
101 // TableDesc td ("", "1", TableDesc::Scratch);
102 // td.addColumn (ArrayColumnDesc<float> ("RA", 1));
103 // td.addColumn (ArrayColumnDesc<float> ("Dec", 1));
104 // td.addColumn (ScalarColumnDesc<float> ("Velocity"));
105 // td.addColumn (ArrayColumnDesc<float> ("Image", 2));
106 // // Define the 3-dim hypercolumn with its data and coordinate columns.
107 // // Note that its dimensionality must be one higher than the dimensionality
108 // // of the data cells.
109 // td.defineHypercolumn ("TSMExample",
110 // 3,
111 // stringToVector ("Image"),
112 // stringToVector ("RA,Dec,Velocity"));
113 // // Now create a new table from the description.
114 // SetupNewTable newtab("tTiledColumnStMan_tmp.data", td, Table::New);
115 // // Create a TiledColumnStMan storage manager for the hypercolumn
116 // // and bind the columns to it.
117 // // The tile shape has to be specified for the storage manager.
118 // TiledColumnStMan sm1 ("TSMExample", IPosition(3,16,32,32));
119 // newtab.bindAll (sm1);
120 // // Create the table.
121 // Table table(newtab);
122 // // Define the values for the coordinates of the hypercube.
123 // Vector<float> raValues(512);
124 // Vector<float> DecValues(512);
125 // indgen (raValues);
126 // indgen (decValues, float(100));
127 // ArrayColumn<float> ra (table, "RA");
128 // ArrayColumn<float> dec (table, "Dec");
129 // ScalarColumn<float> velocity (table, "Velocity");
130 // ArrayColumn<float> image (table, "Image");
131 // Cube<float> imageValues(IPosition(2,512,512));
132 // indgen (imageValues);
133 // // Write some data into the data columns.
134 // uInt i;
135 // for (i=0; i<64; i++) {
136 // table.addRow();
137 // image.put (i, imageValues);
138 // // The RA and Dec have to be put only once, because they
139 // // are the same for each row.
140 // if (i == 0) {
141 // ra.put (i, raValues);
142 // dec.put (i, decValues);
143 // }
144 // velocity.put (i, float(i));
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 {
156 public:
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.
162  // The given maximum cache size in bytes (default is unlimited) is
163  // persistent, thus will be reused when the table is read back.
164  // 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  TiledColumnStMan (const String& hypercolumnName,
174  const IPosition& tileShape,
175  uInt maximumCacheSize = 0);
176  TiledColumnStMan (const String& hypercolumnName,
177  const Record& spec);
178  // </group>
179 
181 
182  // Clone this object.
183  // It does not clone TSMColumn objects possibly used.
184  virtual DataManager* clone() const;
185 
186  // TiledColumnStMan can always access a column.
187  virtual Bool canAccessColumn (Bool& reask) const;
188 
189  // Get the type name of the data manager (i.e. TiledColumnStMan).
190  virtual String dataManagerType() const;
191 
192  // Make the object from the type name string.
193  // This function gets registered in the DataManager "constructor" map.
194  static DataManager* makeObject (const String& dataManagerType,
195  const Record& spec);
196 
197 private:
198  // Create a TiledColumnStMan.
199  // This constructor is private, because it should only be used
200  // by makeObject.
202 
203  // Forbid copy constructor.
205 
206  // Forbid assignment.
208 
209  // Get the (default) tile shape.
210  virtual IPosition defaultTileShape() const;
211 
212  // Add rows to the storage manager.
213  // This will extend the hypercube.
214  void addRow (uInt nrrow);
215 
216  // Get the hypercube in which the given row is stored.
217  virtual TSMCube* getHypercube (uInt rownr);
218 
219  // Get the hypercube in which the given row is stored.
220  // It also returns the position of the row in that hypercube.
221  virtual TSMCube* getHypercube (uInt rownr, IPosition& position);
222 
223  // Check if the hypercolumn definition fits this storage manager.
224  virtual void setupCheck (const TableDesc& tableDesc,
225  const Vector<String>& dataNames) const;
226 
227  // Flush and optionally fsync the data.
228  // It returns a True status if it had to flush (i.e. if data have changed).
229  virtual Bool flush (AipsIO&, Bool fsync);
230 
231  // Let the storage manager create files as needed for a new table.
232  // This allows a column with an indirect array to create its file.
233  virtual void create (uInt nrrow);
234 
235  // Read the header info.
236  virtual void readHeader (uInt nrrow, Bool firstTime);
237 
238 
239  //# Declare data members.
241 };
242 
243 
244 
245 
246 } //# NAMESPACE CASACORE - END
247 
248 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
A 1-D Specialization of the Array class.
Tiled hypercube in a table.
Definition: TSMCube.h:105
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
virtual void readHeader(uInt nrrow, Bool firstTime)
Read the header info.
Base class for Tiled Storage Manager classes.
Definition: TiledStMan.h:107
virtual IPosition defaultTileShape() const
Get the (default) tile shape.
TiledColumnStMan()
Create a TiledColumnStMan.
void addRow(uInt nrrow)
Add rows to the storage manager.
virtual String dataManagerType() const
Get the type name of the data manager (i.e.
virtual TSMCube * getHypercube(uInt rownr)
Get the hypercube in which the given row is stored.
TiledColumnStMan & operator=(const TiledColumnStMan &)
Forbid assignment.
virtual Bool canAccessColumn(Bool &reask) const
TiledColumnStMan can always access a column.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual Bool flush(AipsIO &, Bool fsync)
Flush and optionally fsync the data.
virtual DataManager * clone() const
Clone this object.
virtual void setupCheck(const TableDesc &tableDesc, const Vector< String > &dataNames) const
Check if the hypercolumn definition fits this storage manager.
Abstract base class for a data manager.
Definition: DataManager.h:224
static DataManager * makeObject(const String &dataManagerType, const Record &spec)
Make the object from the type name string.
virtual void create(uInt nrrow)
Let the storage manager create files as needed for a new table.
uInt maximumCacheSize() const
Get the current maximum cache size (in MiB (MibiByte)).
Definition: TiledStMan.h:533
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Define the structure of a Casacore table.
Definition: TableDesc.h:187
const IPosition & tileShape(uInt rownr) const
Get the tile shape of the data in the given row.
Tiled Column Storage Manager.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42