casa
$Rev:20696$
|
00001 //# TiledColumnStMan.h: Tiled Column Storage Manager 00002 //# Copyright (C) 1995,1996,1997,1999,2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: TiledColumnStMan.h 21014 2011-01-06 08:57:49Z gervandiepen $ 00027 00028 #ifndef TABLES_TILEDCOLUMNSTMAN_H 00029 #define TABLES_TILEDCOLUMNSTMAN_H 00030 00031 //# Includes 00032 #include <casa/aips.h> 00033 #include <tables/Tables/TiledStMan.h> 00034 #include <casa/Arrays/IPosition.h> 00035 #include <casa/BasicSL/String.h> 00036 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 //# Forward Declarations 00040 00041 00042 // <summary> 00043 // Tiled Column Storage Manager. 00044 // </summary> 00045 00046 // <use visibility=export> 00047 00048 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00049 // </reviewed> 00050 00051 // <prerequisite> 00052 //# Classes you should understand before using this one. 00053 // <li> <linkto class=TiledStMan>TiledStMan</linkto> 00054 // <li> <linkto class=TSMCube>TSMCube</linkto> 00055 // <li> <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto> 00056 // for a discussion of the maximum cache size 00057 // </prerequisite> 00058 00059 // <etymology> 00060 // TiledColumnStMan is the Tiled Storage Manager storing 00061 // an entire column as one hypercube. 00062 // </etymology> 00063 00064 // <synopsis> 00065 // TiledColumnStMan is a derivation from TiledStMan, the abstract 00066 // tiled storage manager class. A description of the basics 00067 // of tiled storage managers is given in the 00068 // <linkto module=Tables:TiledStMan>Tables module</linkto> description. 00069 // <p> 00070 // TiledColumnStMan allows the user to create a tiled hypercube for 00071 // an entire data column and extend it in an automatic way. 00072 // It is meant to be used for fixed shaped data which have to 00073 // be accessed in various directions. 00074 // <p> 00075 // The TiledColumnStMan has the following (extra) properties: 00076 // <ul> 00077 // <li> Addition of a row results in the extension of the hypercube. 00078 // The data cells in all rows have to have the same shape. Therefore 00079 // the columns stored by a TiledColumnStMan storage manager 00080 // have to be fixed shaped (i.e. FixedShape attribute set in their 00081 // column descriptions). 00082 // <li> Coordinates for the hypercubes can be defined and (of course) 00083 // their shapes have to match the hypercube shape. 00084 // Their values have to be put explicitly (so it is not possible 00085 // to define them via an extendHypercube call like in 00086 // <linkto class=TiledDataStMan>TiledDataStMan</linkto>). 00087 // <li> The tile shape of the hypercube has to be defined by means 00088 // of the TiledColumnStMan constructor. 00089 // </ul> 00090 // </synopsis> 00091 00092 // <motivation> 00093 // This tiled storage manager does not require any special action 00094 // (like calling add/extendHypercube) when used with a column 00095 // containing equally shaped arrays. 00096 // </motivation> 00097 00098 // <example> 00099 // <srcblock> 00100 // // Define the table description and the columns in it. 00101 // TableDesc td ("", "1", TableDesc::Scratch); 00102 // td.addColumn (ArrayColumnDesc<float> ("RA", 1)); 00103 // td.addColumn (ArrayColumnDesc<float> ("Dec", 1)); 00104 // td.addColumn (ScalarColumnDesc<float> ("Velocity")); 00105 // td.addColumn (ArrayColumnDesc<float> ("Image", 2)); 00106 // // Define the 3-dim hypercolumn with its data and coordinate columns. 00107 // // Note that its dimensionality must be one higher than the dimensionality 00108 // // of the data cells. 00109 // td.defineHypercolumn ("TSMExample", 00110 // 3, 00111 // stringToVector ("Image"), 00112 // stringToVector ("RA,Dec,Velocity")); 00113 // // Now create a new table from the description. 00114 // SetupNewTable newtab("tTiledColumnStMan_tmp.data", td, Table::New); 00115 // // Create a TiledColumnStMan storage manager for the hypercolumn 00116 // // and bind the columns to it. 00117 // // The tile shape has to be specified for the storage manager. 00118 // TiledColumnStMan sm1 ("TSMExample", IPosition(3,16,32,32)); 00119 // newtab.bindAll (sm1); 00120 // // Create the table. 00121 // Table table(newtab); 00122 // // Define the values for the coordinates of the hypercube. 00123 // Vector<float> raValues(512); 00124 // Vector<float> DecValues(512); 00125 // indgen (raValues); 00126 // indgen (decValues, float(100)); 00127 // ArrayColumn<float> ra (table, "RA"); 00128 // ArrayColumn<float> dec (table, "Dec"); 00129 // ScalarColumn<float> velocity (table, "Velocity"); 00130 // ArrayColumn<float> image (table, "Image"); 00131 // Cube<float> imageValues(IPosition(2,512,512)); 00132 // indgen (imageValues); 00133 // // Write some data into the data columns. 00134 // uInt i; 00135 // for (i=0; i<64; i++) { 00136 // table.addRow(); 00137 // image.put (i, imageValues); 00138 // // The RA and Dec have to be put only once, because they 00139 // // are the same for each row. 00140 // if (i == 0) { 00141 // ra.put (i, raValues); 00142 // dec.put (i, decValues); 00143 // } 00144 // velocity.put (i, float(i)); 00145 // } 00146 // </srcblock> 00147 // </example> 00148 00149 //# <todo asof="$DATE:$"> 00150 //# A List of bugs, limitations, extensions or planned refinements. 00151 //# </todo> 00152 00153 00154 class TiledColumnStMan : public TiledStMan 00155 { 00156 public: 00157 // Create a TiledDataStMan storage manager for the hypercolumn 00158 // with the given name. The columns used should have the FixedShape 00159 // attribute set. 00160 // The hypercolumn name is also the name of the storage manager. 00161 // The given tile shape will be used. 00162 // The given maximum cache size in bytes (default is unlimited) is 00163 // persistent, thus will be reused when the table is read back. 00164 // Note that the class 00165 // <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto> 00166 // allows one to overwrite the maximum cache size temporarily. 00167 // Its description contains a discussion about the effects of 00168 // setting a maximum cache. 00169 // <br>The constructor taking a Record expects fields in the record with 00170 // the name of the arguments in uppercase. If not defined, their 00171 // default value is used. 00172 // <group> 00173 TiledColumnStMan (const String& hypercolumnName, 00174 const IPosition& tileShape, 00175 uInt maximumCacheSize = 0); 00176 TiledColumnStMan (const String& hypercolumnName, 00177 const Record& spec); 00178 // </group> 00179 00180 ~TiledColumnStMan(); 00181 00182 // Clone this object. 00183 // It does not clone TSMColumn objects possibly used. 00184 virtual DataManager* clone() const; 00185 00186 // TiledColumnStMan can always access a column. 00187 virtual Bool canAccessColumn (Bool& reask) const; 00188 00189 // Get the type name of the data manager (i.e. TiledColumnStMan). 00190 virtual String dataManagerType() const; 00191 00192 // Make the object from the type name string. 00193 // This function gets registered in the DataManager "constructor" map. 00194 static DataManager* makeObject (const String& dataManagerType, 00195 const Record& spec); 00196 00197 private: 00198 // Create a TiledColumnStMan. 00199 // This constructor is private, because it should only be used 00200 // by makeObject. 00201 TiledColumnStMan(); 00202 00203 // Forbid copy constructor. 00204 TiledColumnStMan (const TiledColumnStMan&); 00205 00206 // Forbid assignment. 00207 TiledColumnStMan& operator= (const TiledColumnStMan&); 00208 00209 // Get the (default) tile shape. 00210 virtual IPosition defaultTileShape() const; 00211 00212 // Add rows to the storage manager. 00213 // This will extend the hypercube. 00214 void addRow (uInt nrrow); 00215 00216 // Get the hypercube in which the given row is stored. 00217 virtual TSMCube* getHypercube (uInt rownr); 00218 00219 // Get the hypercube in which the given row is stored. 00220 // It also returns the position of the row in that hypercube. 00221 virtual TSMCube* getHypercube (uInt rownr, IPosition& position); 00222 00223 // Check if the hypercolumn definition fits this storage manager. 00224 virtual void setupCheck (const TableDesc& tableDesc, 00225 const Vector<String>& dataNames) const; 00226 00227 // Flush and optionally fsync the data. 00228 // It returns a True status if it had to flush (i.e. if data have changed). 00229 virtual Bool flush (AipsIO&, Bool fsync); 00230 00231 // Let the storage manager create files as needed for a new table. 00232 // This allows a column with an indirect array to create its file. 00233 virtual void create (uInt nrrow); 00234 00235 // Read the header info. 00236 virtual void readHeader (uInt nrrow, Bool firstTime); 00237 00238 00239 //# Declare data members. 00240 IPosition tileShape_p; 00241 }; 00242 00243 00244 00245 00246 } //# NAMESPACE CASA - END 00247 00248 #endif