casacore
Loading...
Searching...
No Matches
TiledStMan.h
Go to the documentation of this file.
1//# TiledStMan.h: Base class for Tiled Storage Managers
2//# Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
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_TILEDSTMAN_H
27#define TABLES_TILEDSTMAN_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/tables/DataMan/DataManager.h>
33#include <casacore/casa/Containers/Block.h>
34#include <casacore/casa/Arrays/ArrayFwd.h>
35#include <casacore/casa/Arrays/IPosition.h>
36#include <casacore/casa/OS/Conversion.h>
37#include <casacore/casa/BasicSL/String.h>
38
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41//# Forward Declarations
42class TSMColumn;
43class TSMDataColumn;
44class TSMCube;
45class TSMFile;
46class TableDesc;
47class Record;
48
49// <summary>
50// Base class for Tiled Storage Manager classes
51// </summary>
52
53// <use visibility=export>
54
55// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
56// </reviewed>
57
58// <prerequisite>
59//# Classes you should understand before using this one.
60// <li> Description of Tiled Storage Manager in module file
61// <linkto module=Tables:TiledStMan>Tables.h</linkto>
62// <li> <linkto class=DataManager>DataManager</linkto>
63// <li> <linkto class=TSMColumn>TSMColumn</linkto>
64// <li> <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto>
65// for a discussion of the maximum cache size
66// </prerequisite>
67
68// <synopsis>
69// TiledStMan is the base class for Tiled Storage Managers.
70// A tiled storage manager is capable of storing a hypercolumn
71// (as defined by <linkto file="TableDesc.h#defineHypercolumn">
72// TableDesc::defineHypercolumn</linkto>)
73// in one or more hypercubes.
74// <br>It is not necessary to define a hypercolumn. If not defined,
75// it is assumed that all columns bound to this storage manager are
76// data columns. At least one of the columns must have a fixed
77// dimensionality and is used to determine the hypercube dimnensionality.
78// <br>The general concept of these storage managers is explained in the
79// <linkto module="Tables:TiledStMan">Tables module description</linkto>.
80// <p>
81// TiledStMan contains all common functions for the different tiled
82// storage managers. In particular, it contains functions
83// to check if the definitions of the shapes of hypercubes, coordinates, and
84// data cells are consistent.
85// It also contains various data members and functions to make them
86// persistent by writing them into an AipsIO stream.
87// </synopsis>
88
89// <motivation>
90// This base class contains the common functionality of all
91// tiled storage managers. The base class is still abstract.
92// Only concrete tiled storage managers derived from it can
93// be instantiated.
94// <p>
95// Tiled storage managers make access to array data possible with
96// more or less the same efficiency for access along different axes.
97// </motivation>
98
99//# <todo asof="$DATE:$">
100//# A List of bugs, limitations, extensions or planned refinements.
101//# </todo>
102
103
105{
106public:
107 // Create a TiledStMan.
109
110 // Create a TiledStMan storage manager.
111 // The given maximum cache size (in MibiByte) is persistent,
112 // thus will be reused when the table is read back. Note that the class
113 // <linkto class=ROTiledStManAccessor>ROTiledStManAccessor</linkto>
114 // allows one to overwrite the maximum cache size temporarily.
115 // Its description contains a discussion about the effects of
116 // setting a maximum cache.
117 TiledStMan (const String& hypercolumnName, uInt maximumCacheSizeMiB);
118
119 virtual ~TiledStMan();
120
121 // Forbid copy constructor.
122 TiledStMan (const TiledStMan&) = delete;
123
124 // Forbid assignment.
126
127 // Get the name given to the storage manager.
128 // This is the name of the hypercolumn.
129 virtual String dataManagerName() const;
130
131 void setDataManagerName (const String& newHypercolumnName);
132
133 // Return a record containing data manager specifications.
134 virtual Record dataManagerSpec() const;
135
136 // Get data manager properties that can be modified.
137 // It is only MaxCacheSize (the maximum cache size in MibiByte).
138 // It is a subset of the data manager specification.
139 virtual Record getProperties() const;
140
141 // Modify data manager properties.
142 // Only MaxCacheSize can be used. It is similar to function setCacheSize
143 // with <src>canExceedNrBuckets=False</src>.
144 virtual void setProperties (const Record& spec);
145
146 // Set the flag to "data has changed since last flush".
147 void setDataChanged();
148
149 // Derive the tile shape from the hypercube shape for the given
150 // number of pixels per tile. It is tried to get the same number
151 // of tiles for each dimension.
152 // When a weight vector is given, the number of tiles for a dimension
153 // is proportional to the weight.
154 // <br>After the initial guess it tries to optimize it by trying
155 // to waste as little space as possible, while trying to keep as close
156 // to the initial guess. The given tolerance (possibly per axis)
157 // gives the minimum and maximum possible length of a tile axis
158 // (minimum = initial_guess*tolerance; maximum = initial_guess/tolerance).
159 // The heuristic is such that a tile axis length dividing the cube length
160 // exactly is always favoured.
161 // The test program <src>tTiledStMan</src> can be used to see how
162 // the algorithm works out for a given tile size and cube shape.
163 // <group>
165 Double tolerance = 0.5,
166 uInt64 maxNrPixelsPerTile = 4*1024*1024);
168 const Vector<double>& weight,
169 const Vector<double>& tolerance,
170 uInt64 maxNrPixelsPerTile = 4*1024*1024);
171 // </group>
172
173 // Set the maximum cache size (in MiB) in a non-persistent way.
174 virtual void setMaximumCacheSize (uInt nMiB);
175
176 // Get the current maximum cache size (in MiB (MibiByte)).
177 uInt maximumCacheSize() const;
178
179 // Get the current cache size (in buckets) for the hypercube in
180 // the given row.
181 uInt cacheSize (rownr_t rownr) const;
182
183 // Get the hypercube shape of the data in the given row.
184 const IPosition& hypercubeShape (rownr_t rownr) const;
185
186 // Get the tile shape of the data in the given row.
187 const IPosition& tileShape (rownr_t rownr) const;
188
189 // Get the bucket size (in bytes) of the hypercube in the given row.
190 uInt64 bucketSize (rownr_t rownr) const;
191
192 // Can the tiled storage manager handle changing array shapes?
193 // The default is no (but TiledCellStMan can).
194 virtual Bool canChangeShape() const;
195
196 // Can the tiled storage manager access an entire column.
197 // TiledColumnStMan can always do that.
198 // The others might be able to do it (for this time).
199 // The default implementation returns True if there is only 1 hypercube.
200 virtual Bool canAccessColumn() const;
201
202 // The data manager supports use of MultiFile.
203 virtual Bool hasMultiFileSupport() const;
204
205 // Calculate the cache size (in buckets) for accessing the hypercube
206 // containing the given row. It takes the maximum cache size into
207 // account (allowing an overdraft of 10%).
208 // It uses the given axisPath (i.e. traversal order) to determine
209 // the optimum size. A window can be specified to indicate that only
210 // the given subset of the hypercube will be accessed.
211 // <br>
212 // The length of the slice and window arguments and <src>axisPath</src>
213 // must be less or equal to the dimensionality of the hypercube.
214 // The non-specified <src>windowStart</src> parts default to 0.
215 // The non-specified <src>windowLength</src> parts default to
216 // the hypercube shape.
217 // The non-specified <src>sliceShape</src> parts default to 1.
218 // <br>
219 // Axispath = [2,0,1] indicates that the z-axis changes most rapidly,
220 // thereafter x and y. An axis can occur only once in the axisPath.
221 // The non-specified <src>axisPath</src> parts get the natural order.
222 // E.g. in the previous example axisPath=[2] defines the same path.
223 // <br>When forceSmaller is False, the cache is not resized when the
224 // new size is smaller.
225 // <br>A flag is set indicating that the TSMDataColumn
226 // access functions do not need to size the cache.
227 uInt calcCacheSize (rownr_t rownr, const IPosition& sliceShape,
228 const IPosition& windowStart,
229 const IPosition& windowLength,
230 const IPosition& axisPath) const;
231
232 // Set the cache size using the <src>calcCacheSize</src>
233 // function mentioned above.
234 void setCacheSize (rownr_t rownr, const IPosition& sliceShape,
235 const IPosition& windowStart,
236 const IPosition& windowLength,
237 const IPosition& axisPath,
238 Bool forceSmaller);
239
240 // Set the cache size for accessing the hypercube containing the given row.
241 // When the give cache size exceeds the maximum cache size with more
242 // than 10%, the maximum cache size is used instead.
243 // <br>When forceSmaller is False, the cache is not resized when the
244 // new size is smaller.
245 // <br>A flag is set indicating that the TSMDataColumn
246 // access functions do not need to size the cache.
247 void setCacheSize (rownr_t rownr, uInt nbuckets, Bool forceSmaller);
248
249 // Sets the cache size using the hypercube instead of the row number.
250 // Useful for iterating over all hypercubes.
251 void setHypercubeCacheSize (uInt hypercube, uInt nbuckets, Bool forceSmaller);
252
253 // Determine if the user set the cache size (using setCacheSize).
254 Bool userSetCache (rownr_t rownr) const;
255
256 // Empty the caches used by the hypercubes in this storage manager.
257 // It will flush the caches as needed and remove all buckets from them
258 // resulting in a possibly large drop in memory used.
259 // It also clears the userSetCache flag.
261
262 // Show the statistics of all caches used.
263 void showCacheStatistics (ostream& os) const;
264
265 // Get the length of the data for the given number of pixels.
266 // This can be used to calculate the length of a tile.
267 uInt64 getLengthOffset (uInt64 nrPixels, Block<uInt>& dataOffset,
268 Block<uInt>& localOffset,
269 uInt& localTileLength) const;
270
271 // Get the number of coordinate vectors.
272 uInt nrCoordVector() const;
273
274 // Get the nr of rows in this storage manager.
275 rownr_t nrow() const;
276
277 // Does the storage manager allow to add rows? (yes)
279
280 // Get the default tile shape.
281 // By default it returns a zero-length IPosition.
283
284 // Return the number of hypercubes.
285 uInt nhypercubes() const;
286
287 // Test if only one hypercube is used by this storage manager.
288 // If not, throw an exception. Otherwise return the hypercube.
290
291 // Get the given hypercube.
292 // <group>
293 const TSMCube* getTSMCube (uInt hypercube) const;
294 TSMCube* getTSMCube (uInt hypercube);
295 // </group>
296
297 // Get the hypercube in which the given row is stored.
298 // <group>
299 const TSMCube* getHypercube (rownr_t rownr) const;
300 virtual TSMCube* getHypercube (rownr_t rownr) = 0;
301 // </group>
302
303 // Get the hypercube in which the given row is stored.
304 // It also returns the position of the row in that hypercube.
305 virtual TSMCube* getHypercube (rownr_t rownr, IPosition& position) = 0;
306
307 // Make the correct TSMCube type (depending on tsmOption()).
308 TSMCube* makeTSMCube (TSMFile* file, const IPosition& cubeShape,
309 const IPosition& tileShape,
310 const Record& values, Int64 fileOffset=-1);
311
312 // Read a tile and convert the data to local format.
313 void readTile (char* local, const Block<uInt>& localOffset,
314 const char* external, const Block<uInt>& externalOffset,
315 uInt nrpixels);
316
317 // Write a tile after converting the data to external format.
318 void writeTile (char* external, const Block<uInt>& externalOffset,
319 const char* local, const Block<uInt>& localOffset,
320 uInt nrpixels);
321
322 // Get the TSMFile object with the given sequence number.
323 TSMFile* getFile (uInt sequenceNumber);
324
325 // Open the storage manager for an existing table.
326 virtual rownr_t open64 (rownr_t nrrow, AipsIO&);
327
328 // Resync the storage manager with the new file contents.
329 virtual rownr_t resync64 (rownr_t nrrow);
330
331 // Reopen all files used in this storage manager for read/write access.
332 virtual void reopenRW();
333
334 // The data manager will be deleted (because all its columns are
335 // requested to be deleted).
336 // So clean up the things needed (e.g. delete files).
337 virtual void deleteManager();
338
339 // Create a column in the storage manager on behalf of a table column.
340 // <group>
341 // Create a scalar column.
342 DataManagerColumn* makeScalarColumn (const String& name, int dataType,
343 const String& dataTypeID);
344 // Create a direct array column.
345 DataManagerColumn* makeDirArrColumn (const String& name, int dataType,
346 const String& dataTypeID);
347 // Create an indirect array column.
348 DataManagerColumn* makeIndArrColumn (const String& name, int dataType,
349 const String& dataTypeID);
350 // </group>
351
352 // The TiledStMan wants to do reallocateColumn.
354
355 // Reallocate the column object if it is part of this data manager.
356 // It returns a pointer to the new column object.
357 // It is used to remove the indirection of the TSMColumn objects
358 // resulting in only one iso. two virtual column calls to get the data.
360
361 // Set the shape and tile shape of a hypercube.
362 // By default it throws an "impossible" exception.
363 virtual void setShape (rownr_t rownr, TSMCube* hypercube,
364 const IPosition& shape,
365 const IPosition& tileShape);
366
367 // Check the shape to be set for a hypercube.
368 // It checks if it matches predefined (fixed shape) columns
369 // and the shape of already defined coordinate columns.
370 void checkCubeShape (const TSMCube* hypercube,
371 const IPosition& cubeShape) const;
372
373 // Get the data type of the coordinate column with the given name.
374 // An exception is thrown when the column is unknown.
375 int coordinateDataType (const String& columnName) const;
376
377 // Initialize the new coordinates for the given cube.
378 void initCoordinates (TSMCube* hypercube);
379
380 // Get pointer to data column object.
381 const TSMDataColumn* getDataColumn (uInt colnr) const
382 { return dataCols_p[colnr]; }
383
384protected:
385 // Set the persistent maximum cache size (in MiB).
386 void setPersMaxCacheSize (uInt nMiB);
387
388 // Get the bindings of the columns with the given names.
389 // If bound, the pointer to the TSMColumn object is stored in the block.
390 // If mustExist is True, an exception is thrown if the column
391 // is not bound.
392 // It returns the number of bound columns.
393 uInt getBindings (const Vector<String>& columnNames,
394 PtrBlock<TSMColumn*>& colSet,
395 Bool mustExist) const;
396
397 // Function setup calls this function to allow the derived class
398 // to check specific information. In case of errors, an exception
399 // should be thrown.
400 // By default it does nothing.
401 virtual void setupCheck (const TableDesc& tableDesc,
402 const Vector<String>& dataNames) const;
403
404 // Get the table description needed for the hypercolumn description.
405 virtual const TableDesc& getDesc() const;
406
407 // Check if values are given in the record for all columns in
408 // the block. Also check if the data types are correct.
409 // An exception is thrown if something is incorrect.
411 const Record& values) const;
412
413 // Check if the coordinate values are correct.
414 // This calls checkValues and checks if their shapes match the
415 // hypercube shape.
416 // An exception is thrown if invalid.
417 void checkCoordinates (const PtrBlock<TSMColumn*>& coordColSet,
418 const IPosition& cubeShape,
419 const Record& values) const;
420
421 // Check if the shapes of FixedShape data and coordinate columns match.
422 // An exception is thrown if not.
423 void checkShapeColumn (const IPosition& shape) const;
424
425 // Check if the cube shape matches that of defined coordinates.
426 void checkCoordinatesShapes (const TSMCube* hypercube,
427 const IPosition& cubeShape) const;
428
429 // Check if the hypercube to be added is correctly defined.
430 void checkAddHypercube (const IPosition& cubeShape,
431 const Record& values) const;
432
433 // Make a new TSMCube object.
434 TSMCube* makeHypercube (const IPosition& cubeShape,
435 const IPosition& tileShape,
436 const Record& values);
437
438 // Get the index of the hypercube with the given id-values.
439 // If not found, -1 is returned.
440 Int getCubeIndex (const Record& idValues) const;
441
442 // Determine how many rows need to be added for an extension
443 // (in the last dimension) of a hypercube with the given shape.
444 rownr_t addedNrrow (const IPosition& shape, uInt incrInLastDim) const;
445
446 // Flush the caches of all hypercubes.
447 // If data have put and fsync is set, fsync all files.
449
450 // Let a derived class read the header info.
451 // This is used by the open and resync function.
452 virtual void readHeader (rownr_t nrrow, Bool firstTime) = 0;
453
454 // Create the TSM header file.
455 // It creates an AipsIO object for it.
457
458 // Open the TSM header file.
459 // It creates an AipsIO object for it.
461
462 // Write the data into the header file.
463 // The given number of TSMCube objects have to be written.
464 void headerFilePut (AipsIO& headerFile, uInt64 nrCube);
465
466 // Read the data from the header file.
467 // When done for the first time, setup() is called to initialize
468 // the various variables (using the extraNdim variable).
469 // It returns the version of the AipsIO object in the header.
470 uInt headerFileGet (AipsIO& headerFile, rownr_t tabNrrow, Bool firstTime,
471 Int extraNdim);
472
473 // Close the header file.
474 // It deletes the AipsIO object.
475 void headerFileClose (AipsIO* headerFile);
476
477 // Set up the TiledStMan variables from the table description.
478 // The argument specifies the number of extra dimensions for the
479 // hypercube compared to the data array (usually 0 or 1).
480 // It is only used if no hypercolumn definition exists.
481 // -1 means that the hypercolumn definition has to be present.
482 void setup (Int extraNdim=-1);
483
484 // Create a TSMFile object and store its pointer at the given index
485 // in the block.
486 void createFile (uInt index);
487
488 // Convert the scalar data type to an array data type.
489 // This function is temporary and can disappear when the ColumnDesc
490 // classes use type TpArray*.
491 int arrayDataType (int dataType) const;
492
493
494 //# Declare all data members.
495 // The name of the hypercolumn.
497 // The number of rows in the columns.
499 // The assembly of all columns.
501 // The assembly of all data columns.
504 // The assembly of all id columns.
506 // The assembly of all coordinate columns.
508 // The assembly of all TSMFile objects.
509 // The first file is for all non-extensible cubes, while the others
510 // are for one file per extensible cube.
512 // The assembly of all TSMCube objects.
514 // The persistent maximum cache size (in MiB) for a hypercube.
516 // The actual maximum cache size for a hypercube (in MiB).
518 // The dimensionality of the hypercolumn.
520 // The number of vector coordinates.
522 // The fixed cell shape.
524 // Has any data changed since the last flush?
526};
527
528
530 { return maxCacheSize_p; }
531
533 { return nrCoordVector_p; }
534
536 { return nrrow_p; }
537
539 { return cubeSet_p.nelements(); }
540
543
544inline const TSMCube* TiledStMan::getTSMCube (uInt hypercube) const
545 { return const_cast<TiledStMan*>(this)->getTSMCube (hypercube); }
546
547inline const TSMCube* TiledStMan::getHypercube (rownr_t rownr) const
548 { return const_cast<TiledStMan*>(this)->getHypercube (rownr); }
549
551{
552 persMaxCacheSize_p = nMiB;
553 maxCacheSize_p = nMiB;
554}
555
556
557
558
559} //# NAMESPACE CASACORE - END
560
561#endif
simple 1-D array
Definition Block.h:198
Abstract base class for a data manager.
A drop-in replacement for Block<T*>.
Definition Block.h:812
String: the storage and methods of handling collections of characters.
Definition String.h:223
virtual void setMaximumCacheSize(uInt nMiB)
Set the maximum cache size (in MiB) in a non-persistent way.
int coordinateDataType(const String &columnName) const
Get the data type of the coordinate column with the given name.
uInt nhypercubes() const
Return the number of hypercubes.
Definition TiledStMan.h:538
uInt headerFileGet(AipsIO &headerFile, rownr_t tabNrrow, Bool firstTime, Int extraNdim)
Read the data from the header file.
IPosition fixedCellShape_p
The fixed cell shape.
Definition TiledStMan.h:523
void setPersMaxCacheSize(uInt nMiB)
Set the persistent maximum cache size (in MiB).
Definition TiledStMan.h:550
virtual void deleteManager()
The data manager will be deleted (because all its columns are requested to be deleted).
uInt getBindings(const Vector< String > &columnNames, PtrBlock< TSMColumn * > &colSet, Bool mustExist) const
Get the bindings of the columns with the given names.
virtual rownr_t open64(rownr_t nrrow, AipsIO &)
Open the storage manager for an existing table.
void setCacheSize(rownr_t rownr, uInt nbuckets, Bool forceSmaller)
Set the cache size for accessing the hypercube containing the given row.
virtual String dataManagerName() const
Get the name given to the storage manager.
void headerFileClose(AipsIO *headerFile)
Close the header file.
uInt calcCacheSize(rownr_t rownr, const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath) const
Calculate the cache size (in buckets) for accessing the hypercube containing the given row.
TSMCube * makeTSMCube(TSMFile *file, const IPosition &cubeShape, const IPosition &tileShape, const Record &values, Int64 fileOffset=-1)
Make the correct TSMCube type (depending on tsmOption()).
uInt64 bucketSize(rownr_t rownr) const
Get the bucket size (in bytes) of the hypercube in the given row.
virtual Bool canAccessColumn() const
Can the tiled storage manager access an entire column.
uInt nrCoordVector() const
Get the number of coordinate vectors.
Definition TiledStMan.h:532
void readTile(char *local, const Block< uInt > &localOffset, const char *external, const Block< uInt > &externalOffset, uInt nrpixels)
Read a tile and convert the data to local format.
TiledStMan()
Create a TiledStMan.
AipsIO * headerFileOpen()
Open the TSM header file.
Int getCubeIndex(const Record &idValues) const
Get the index of the hypercube with the given id-values.
void setHypercubeCacheSize(uInt hypercube, uInt nbuckets, Bool forceSmaller)
Sets the cache size using the hypercube instead of the row number.
Bool userSetCache(rownr_t rownr) const
Determine if the user set the cache size (using setCacheSize).
PtrBlock< TSMColumn * > coordColSet_p
The assembly of all coordinate columns.
Definition TiledStMan.h:507
virtual Bool canChangeShape() const
Can the tiled storage manager handle changing array shapes? The default is no (but TiledCellStMan can...
virtual void reopenRW()
Reopen all files used in this storage manager for read/write access.
String hypercolumnName_p
The name of the hypercolumn.
Definition TiledStMan.h:496
const IPosition & tileShape(rownr_t rownr) const
Get the tile shape of the data in the given row.
uInt64 getLengthOffset(uInt64 nrPixels, Block< uInt > &dataOffset, Block< uInt > &localOffset, uInt &localTileLength) const
Get the length of the data for the given number of pixels.
virtual IPosition defaultTileShape() const
Get the default tile shape.
static IPosition makeTileShape(const IPosition &hypercubeShape, Double tolerance=0.5, uInt64 maxNrPixelsPerTile=4 *1024 *1024)
Derive the tile shape from the hypercube shape for the given number of pixels per tile.
void checkValues(const PtrBlock< TSMColumn * > &colSet, const Record &values) const
Check if values are given in the record for all columns in the block.
TiledStMan & operator=(const TiledStMan &)=delete
Forbid assignment.
rownr_t nrrow_p
The number of rows in the columns.
Definition TiledStMan.h:498
void setup(Int extraNdim=-1)
Set up the TiledStMan variables from the table description.
uInt nrdim_p
The dimensionality of the hypercolumn.
Definition TiledStMan.h:519
uInt persMaxCacheSize_p
The persistent maximum cache size (in MiB) for a hypercube.
Definition TiledStMan.h:515
DataManagerColumn * makeIndArrColumn(const String &name, int dataType, const String &dataTypeID)
Create an indirect array column.
void emptyCaches()
Empty the caches used by the hypercubes in this storage manager.
virtual void setProperties(const Record &spec)
Modify data manager properties.
Bool flushCaches(Bool fsync)
Flush the caches of all hypercubes.
uInt maxCacheSize_p
The actual maximum cache size for a hypercube (in MiB).
Definition TiledStMan.h:517
TSMCube * getTSMCube(uInt hypercube)
void checkCoordinatesShapes(const TSMCube *hypercube, const IPosition &cubeShape) const
Check if the cube shape matches that of defined coordinates.
void checkShapeColumn(const IPosition &shape) const
Check if the shapes of FixedShape data and coordinate columns match.
PtrBlock< TSMColumn * > colSet_p
The assembly of all columns.
Definition TiledStMan.h:500
void setCacheSize(rownr_t rownr, const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath, Bool forceSmaller)
Set the cache size using the calcCacheSize function mentioned above.
virtual Record dataManagerSpec() const
Return a record containing data manager specifications.
Bool dataChanged_p
Has any data changed since the last flush?
Definition TiledStMan.h:525
void setDataManagerName(const String &newHypercolumnName)
void showCacheStatistics(ostream &os) const
Show the statistics of all caches used.
void writeTile(char *external, const Block< uInt > &externalOffset, const char *local, const Block< uInt > &localOffset, uInt nrpixels)
Write a tile after converting the data to external format.
TiledStMan(const String &hypercolumnName, uInt maximumCacheSizeMiB)
Create a TiledStMan storage manager.
void createFile(uInt index)
Create a TSMFile object and store its pointer at the given index in the block.
PtrBlock< TSMCube * > cubeSet_p
The assembly of all TSMCube objects.
Definition TiledStMan.h:513
TSMFile * getFile(uInt sequenceNumber)
Get the TSMFile object with the given sequence number.
virtual void readHeader(rownr_t nrrow, Bool firstTime)=0
Let a derived class read the header info.
virtual TSMCube * getHypercube(rownr_t rownr, IPosition &position)=0
Get the hypercube in which the given row is stored.
uInt cacheSize(rownr_t rownr) const
Get the current cache size (in buckets) for the hypercube in the given row.
Bool canReallocateColumns() const
The TiledStMan wants to do reallocateColumn.
const TSMCube * getTSMCube(uInt hypercube) const
Get the given hypercube.
Definition TiledStMan.h:544
PtrBlock< TSMDataColumn * > dataCols_p
The assembly of all data columns.
Definition TiledStMan.h:502
rownr_t nrow() const
Get the nr of rows in this storage manager.
Definition TiledStMan.h:535
virtual TSMCube * getHypercube(rownr_t rownr)=0
DataManagerColumn * reallocateColumn(DataManagerColumn *column)
Reallocate the column object if it is part of this data manager.
PtrBlock< TSMColumn * > idColSet_p
The assembly of all id columns.
Definition TiledStMan.h:505
TiledStMan(const TiledStMan &)=delete
Forbid copy constructor.
const TSMDataColumn * getDataColumn(uInt colnr) const
Get pointer to data column object.
Definition TiledStMan.h:381
TSMCube * makeHypercube(const IPosition &cubeShape, const IPosition &tileShape, const Record &values)
Make a new TSMCube object.
DataManagerColumn * makeScalarColumn(const String &name, int dataType, const String &dataTypeID)
Create a column in the storage manager on behalf of a table column.
void setDataChanged()
Set the flag to "data has changed since last flush".
Definition TiledStMan.h:541
const TSMCube * getHypercube(rownr_t rownr) const
Get the hypercube in which the given row is stored.
Definition TiledStMan.h:547
uInt nrCoordVector_p
The number of vector coordinates.
Definition TiledStMan.h:521
int arrayDataType(int dataType) const
Convert the scalar data type to an array data type.
virtual const TableDesc & getDesc() const
Get the table description needed for the hypercolumn description.
Bool canAddRow() const
Does the storage manager allow to add rows? (yes)
static IPosition makeTileShape(const IPosition &hypercubeShape, const Vector< double > &weight, const Vector< double > &tolerance, uInt64 maxNrPixelsPerTile=4 *1024 *1024)
void headerFilePut(AipsIO &headerFile, uInt64 nrCube)
Write the data into the header file.
virtual TSMCube * singleHypercube()
Test if only one hypercube is used by this storage manager.
uInt maximumCacheSize() const
Get the current maximum cache size (in MiB (MibiByte)).
Definition TiledStMan.h:529
virtual Record getProperties() const
Get data manager properties that can be modified.
virtual void setShape(rownr_t rownr, TSMCube *hypercube, const IPosition &shape, const IPosition &tileShape)
Set the shape and tile shape of a hypercube.
AipsIO * headerFileCreate()
Create the TSM header file.
void checkAddHypercube(const IPosition &cubeShape, const Record &values) const
Check if the hypercube to be added is correctly defined.
PtrBlock< TSMColumn * > dataColSet_p
Definition TiledStMan.h:503
DataManagerColumn * makeDirArrColumn(const String &name, int dataType, const String &dataTypeID)
Create a direct array column.
virtual Bool hasMultiFileSupport() const
The data manager supports use of MultiFile.
rownr_t addedNrrow(const IPosition &shape, uInt incrInLastDim) const
Determine how many rows need to be added for an extension (in the last dimension) of a hypercube with...
const IPosition & hypercubeShape(rownr_t rownr) const
Get the hypercube shape of the data in the given row.
void checkCubeShape(const TSMCube *hypercube, const IPosition &cubeShape) const
Check the shape to be set for a hypercube.
PtrBlock< TSMFile * > fileSet_p
The assembly of all TSMFile objects.
Definition TiledStMan.h:511
void checkCoordinates(const PtrBlock< TSMColumn * > &coordColSet, const IPosition &cubeShape, const Record &values) const
Check if the coordinate values are correct.
virtual void setupCheck(const TableDesc &tableDesc, const Vector< String > &dataNames) const
Function setup calls this function to allow the derived class to check specific information.
void initCoordinates(TSMCube *hypercube)
Initialize the new coordinates for the given cube.
virtual rownr_t resync64(rownr_t nrrow)
Resync the storage manager with the new file contents.
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition ExprNode.h:1991
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition aipsxtype.h:36
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44
unsigned long long uInt64
Definition aipsxtype.h:37