casa
$Rev:20696$
|
00001 //# TSMCubeMMap.h: Tiled hypercube in a table 00002 //# Copyright (C) 2009 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: TSMCubeMMap.h 20874 2010-03-30 06:28:34Z gervandiepen $ 00027 00028 #ifndef TABLES_TSMCUBEMMAP_H 00029 #define TABLES_TSMCUBEMMAP_H 00030 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <tables/Tables/TSMCube.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 //# Forward declarations 00039 class BucketMapped; 00040 00041 // <summary> 00042 // Tiled hypercube in a table 00043 // </summary> 00044 00045 // <use visibility=local> 00046 00047 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00048 // </reviewed> 00049 00050 // <prerequisite> 00051 //# Classes you should understand before using this one. 00052 // <li> <linkto class=TiledStMan>TiledStMan</linkto> 00053 // <li> <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto> 00054 // for a discussion of the maximum cache size 00055 // <li> <linkto class=TSMFile>TSMFile</linkto> 00056 // <li> <linkto class=BucketMapped>BucketMapped</linkto> 00057 // </prerequisite> 00058 00059 // <etymology> 00060 // TSMCubeMMap represents a hypercube in the Tiled Storage Manager. 00061 // </etymology> 00062 00063 // <synopsis> 00064 // TSMCubeMMap defines a tiled hypercube. The data is stored in a TSMFile 00065 // object and accessed using a BucketMapped object. The hypercube can 00066 // be extensible in its last dimension to support tables with a size 00067 // which is not known in advance. 00068 // <br> 00069 // Normally hypercubes share the same TSMFile object, but extensible 00070 // hypercubes have their own TSMFile object (to be extensible). 00071 // If the hypercolumn has multiple data columns, their cells share the same 00072 // tiles. Per tile data column A appears first, thereafter B, etc.. 00073 // <br> 00074 // The data in the cache is held in external format and is converted 00075 // when accessed. The alternative would be to hold it in the cache in 00076 // local format and convert it when read/written from the file. It was 00077 // felt that the latter approach would generate more needless conversions. 00078 // <p> 00079 // The possible id and coordinate values are stored in a Record 00080 // object. They are written in the main hypercube AipsIO file. 00081 // <p> 00082 // TSMCubeMMap uses the maximum cache size set for a Tiled Storage manager. 00083 // The description of class 00084 // <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto> 00085 // contains a discussion about the effect of setting the maximum cache size. 00086 // </synopsis> 00087 00088 // <motivation> 00089 // TSMCubeMMap encapsulates all operations on a hypercube. 00090 // </motivation> 00091 00092 //# <todo asof="$DATE:$"> 00093 //# A List of bugs, limitations, extensions or planned refinements. 00094 //# </todo> 00095 00096 00097 class TSMCubeMMap: public TSMCube 00098 { 00099 public: 00100 // Construct the hypercube using the given file with the given shape. 00101 // The record contains the id and possible coordinate values. 00102 // <br>If the cubeshape is empty, the hypercube is still undefined and 00103 // can be added later with setShape. That is only used by TiledCellStMan. 00104 // <br> The fileOffset argument is meant for class TiledFileAccess. 00105 TSMCubeMMap (TiledStMan* stman, TSMFile* file, 00106 const IPosition& cubeShape, 00107 const IPosition& tileShape, 00108 const Record& values, 00109 Int64 fileOffset); 00110 00111 // Reconstruct the hypercube by reading its data from the AipsIO stream. 00112 // It will link itself to the correct TSMFile. The TSMFile objects 00113 // must have been reconstructed in advance. 00114 TSMCubeMMap (TiledStMan* stman, AipsIO& ios); 00115 00116 virtual ~TSMCubeMMap(); 00117 00118 // Flush the data in the cache. 00119 virtual void flushCache(); 00120 00121 // Show the cache statistics. 00122 virtual void showCacheStatistics (ostream& os) const; 00123 00124 // Set the hypercube shape. 00125 // This is only possible if the shape was not defined yet. 00126 virtual void setShape (const IPosition& cubeShape, 00127 const IPosition& tileShape); 00128 00129 // Extend the last dimension of the cube with the given number. 00130 // The record can contain the coordinates of the elements added. 00131 virtual void extend (uInt nr, const Record& coordValues, 00132 const TSMColumn* lastCoordColumn); 00133 00134 // Read or write a section in the cube. 00135 // It is assumed that the section buffer is long enough. 00136 virtual void accessSection (const IPosition& start, const IPosition& end, 00137 char* section, uInt colnr, 00138 uInt localPixelSize, uInt externalPixelSize, 00139 Bool writeFlag); 00140 00141 // Read or write a section in a strided way. 00142 // It is assumed that the section buffer is long enough. 00143 virtual void accessStrided (const IPosition& start, const IPosition& end, 00144 const IPosition& stride, 00145 char* section, uInt colnr, 00146 uInt localPixelSize, uInt externalPixelSize, 00147 Bool writeFlag); 00148 00149 // Set the cache size for the given slice and access path. 00150 virtual void setCacheSize (const IPosition& sliceShape, 00151 const IPosition& windowStart, 00152 const IPosition& windowLength, 00153 const IPosition& axisPath, 00154 Bool forceSmaller, Bool userSet); 00155 00156 // Resize the cache object. 00157 // If forceSmaller is False, the cache will only be resized when it grows. 00158 // If the given size exceeds the maximum size with more 00159 // than 10%, the maximum size will be used. 00160 // The cacheSize has to be given in buckets. 00161 // <br>The flag <src>userSet</src> inidicates if the cache size is set by 00162 // the user (by an Accessor object) or automatically (by TSMDataColumn). 00163 virtual void setCacheSize (uInt cacheSize, Bool forceSmaller, Bool userSet); 00164 00165 private: 00166 // Forbid copy constructor. 00167 TSMCubeMMap (const TSMCubeMMap&); 00168 00169 // Forbid assignment. 00170 TSMCubeMMap& operator= (const TSMCubeMMap&); 00171 00172 // Get the cache object. 00173 // This will construct the cache object if not present yet. 00174 BucketMapped* getCache(); 00175 00176 // Construct the cache object (if not constructed yet). 00177 virtual void makeCache(); 00178 00179 // Resync the cache object. 00180 virtual void resyncCache(); 00181 00182 // Delete the cache object. 00183 virtual void deleteCache(); 00184 00185 //# Declare member variables. 00186 // The bucket cache. 00187 BucketMapped* cache_p; 00188 }; 00189 00190 00191 00192 inline BucketMapped* TSMCubeMMap::getCache() 00193 { 00194 if (cache_p == 0) { 00195 makeCache(); 00196 } 00197 return cache_p; 00198 } 00199 00200 00201 00202 } //# NAMESPACE CASA - END 00203 00204 #endif