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