casacore
Loading...
Searching...
No Matches
TSMCubeMMap.h
Go to the documentation of this file.
1//# TSMCubeMMap.h: Tiled hypercube in a table
2//# Copyright (C) 2009
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_TSMCUBEMMAP_H
27#define TABLES_TSMCUBEMMAP_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/tables/DataMan/TSMCube.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward declarations
37class BucketMapped;
38
39// <summary>
40// Tiled hypercube in a table
41// </summary>
42
43// <use visibility=local>
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=ROTiledStManAccessor>ROTiledStManAccessor</linkto>
52// for a discussion of the maximum cache size
53// <li> <linkto class=TSMFile>TSMFile</linkto>
54// <li> <linkto class=BucketMapped>BucketMapped</linkto>
55// </prerequisite>
56
57// <etymology>
58// TSMCubeMMap represents a hypercube in the Tiled Storage Manager.
59// </etymology>
60
61// <synopsis>
62// TSMCubeMMap defines a tiled hypercube. The data is stored in a TSMFile
63// object and accessed using a BucketMapped object. The hypercube can
64// be extensible in its last dimension to support tables with a size
65// which is not known in advance.
66// <br>
67// Normally hypercubes share the same TSMFile object, but extensible
68// hypercubes have their own TSMFile object (to be extensible).
69// If the hypercolumn has multiple data columns, their cells share the same
70// tiles. Per tile data column A appears first, thereafter B, etc..
71// <br>
72// The data in the cache is held in external format and is converted
73// when accessed. The alternative would be to hold it in the cache in
74// local format and convert it when read/written from the file. It was
75// felt that the latter approach would generate more needless conversions.
76// <p>
77// The possible id and coordinate values are stored in a Record
78// object. They are written in the main hypercube AipsIO file.
79// <p>
80// TSMCubeMMap uses the maximum cache size set for a Tiled Storage manager.
81// The description of class
82// <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto>
83// contains a discussion about the effect of setting the maximum cache size.
84// </synopsis>
85
86// <motivation>
87// TSMCubeMMap encapsulates all operations on a hypercube.
88// </motivation>
89
90//# <todo asof="$DATE:$">
91//# A List of bugs, limitations, extensions or planned refinements.
92//# </todo>
93
94
95class TSMCubeMMap: public TSMCube
96{
97public:
98 // Construct the hypercube using the given file with the given shape.
99 // The record contains the id and possible coordinate values.
100 // <br>If the cubeshape is empty, the hypercube is still undefined and
101 // can be added later with setShape. That is only used by TiledCellStMan.
102 // <br> The fileOffset argument is meant for class TiledFileAccess.
104 const IPosition& cubeShape,
105 const IPosition& tileShape,
106 const Record& values,
107 Int64 fileOffset);
108
109 // Reconstruct the hypercube by reading its data from the AipsIO stream.
110 // It will link itself to the correct TSMFile. The TSMFile objects
111 // must have been reconstructed in advance.
113
114 virtual ~TSMCubeMMap();
115
116 // Forbid copy constructor.
117 TSMCubeMMap (const TSMCubeMMap&) = delete;
118
119 // Forbid assignment.
121
122 // Flush the data in the cache.
123 virtual void flushCache();
124
125 // Show the cache statistics.
126 virtual void showCacheStatistics (ostream& os) const;
127
128 // Set the hypercube shape.
129 // This is only possible if the shape was not defined yet.
130 virtual void setShape (const IPosition& cubeShape,
131 const IPosition& tileShape);
132
133 // Extend the last dimension of the cube with the given number.
134 // The record can contain the coordinates of the elements added.
135 virtual void extend (uInt64 nr, const Record& coordValues,
136 const TSMColumn* lastCoordColumn);
137
138 // Read or write a section in the cube.
139 // It is assumed that the section buffer is long enough.
140 virtual void accessSection (const IPosition& start, const IPosition& end,
141 char* section, uInt colnr,
142 uInt localPixelSize, uInt externalPixelSize,
143 Bool writeFlag);
144
145 // Read or write a section in a strided way.
146 // It is assumed that the section buffer is long enough.
147 virtual void accessStrided (const IPosition& start, const IPosition& end,
148 const IPosition& stride,
149 char* section, uInt colnr,
150 uInt localPixelSize, uInt externalPixelSize,
151 Bool writeFlag);
152
153 // Set the cache size for the given slice and access path.
154 virtual void setCacheSize (const IPosition& sliceShape,
155 const IPosition& windowStart,
156 const IPosition& windowLength,
157 const IPosition& axisPath,
158 Bool forceSmaller, Bool userSet);
159
160 // Resize the cache object.
161 // If forceSmaller is False, the cache will only be resized when it grows.
162 // If the given size exceeds the maximum size with more
163 // than 10%, the maximum size will be used.
164 // The cacheSize has to be given in buckets.
165 // <br>The flag <src>userSet</src> inidicates if the cache size is set by
166 // the user (by an Accessor object) or automatically (by TSMDataColumn).
167 virtual void setCacheSize (uInt cacheSize, Bool forceSmaller, Bool userSet);
168
169private:
170 // Get the cache object.
171 // This will construct the cache object if not present yet.
173
174 // Construct the cache object (if not constructed yet).
175 virtual void makeCache();
176
177 // Resync the cache object.
178 virtual void resyncCache();
179
180 // Delete the cache object.
181 virtual void deleteCache();
182
183 //# Declare member variables.
184 // The bucket cache.
186};
187
188
189
191{
192 if (cache_p == 0) {
193 makeCache();
194 }
195 return cache_p;
196}
197
198
199
200} //# NAMESPACE CASACORE - END
201
202#endif
virtual void setShape(const IPosition &cubeShape, const IPosition &tileShape)
Set the hypercube shape.
BucketMapped * cache_p
The bucket cache.
virtual void showCacheStatistics(ostream &os) const
Show the cache statistics.
virtual void extend(uInt64 nr, const Record &coordValues, const TSMColumn *lastCoordColumn)
Extend the last dimension of the cube with the given number.
virtual void setCacheSize(const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath, Bool forceSmaller, Bool userSet)
Set the cache size for the given slice and access path.
virtual void resyncCache()
Resync the cache object.
TSMCubeMMap(TiledStMan *stman, AipsIO &ios)
Reconstruct the hypercube by reading its data from the AipsIO stream.
TSMCubeMMap(TiledStMan *stman, TSMFile *file, const IPosition &cubeShape, const IPosition &tileShape, const Record &values, Int64 fileOffset)
Construct the hypercube using the given file with the given shape.
virtual void flushCache()
Flush the data in the cache.
virtual void accessStrided(const IPosition &start, const IPosition &end, const IPosition &stride, char *section, uInt colnr, uInt localPixelSize, uInt externalPixelSize, Bool writeFlag)
Read or write a section in a strided way.
BucketMapped * getCache()
Get the cache object.
virtual void accessSection(const IPosition &start, const IPosition &end, char *section, uInt colnr, uInt localPixelSize, uInt externalPixelSize, Bool writeFlag)
Read or write a section in the cube.
virtual void makeCache()
Construct the cache object (if not constructed yet).
virtual void deleteCache()
Delete the cache object.
TSMCubeMMap & operator=(const TSMCubeMMap &)=delete
Forbid assignment.
virtual void setCacheSize(uInt cacheSize, Bool forceSmaller, Bool userSet)
Resize the cache object.
TSMCubeMMap(const TSMCubeMMap &)=delete
Forbid copy constructor.
uInt cacheSize() const
Get the current cache size (in buckets).
const IPosition & tileShape() const
Get the shape of the tiles.
Definition TSMCube.h:440
const IPosition & cubeShape() const
Get the shape of the hypercube.
Definition TSMCube.h:436
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition aipsxtype.h:36
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
unsigned long long uInt64
Definition aipsxtype.h:37