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