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