Loading...
Searching...
No Matches
casacore::ROTiledStManAccessor Class Reference
tables package (libcasa_tables) » DataMan_module » DataMan_module_internal_classes

More...

`#include <TiledStManAccessor.h>`

## Public Member Functions

| ROTiledStManAccessor ()
| Default constructor should be used with care.
| ROTiledStManAccessor (const Table &table, const String &name, Bool byColumn=False)
| Construct the object for a data manager in the table given the name of the data manager or the column.
virtual | ~ROTiledStManAccessor ()
| ROTiledStManAccessor (const ROTiledStManAccessor &that)
| Copy constructor (reference semantics).
ROTiledStManAccessor & | operator= (const ROTiledStManAccessor &that)
| Assignment (reference semantics).
void | setMaximumCacheSize (uInt nMiB)
| Set the maximum cache size (in MibiByte) to be used by a hypercube in the storage manager.
uInt | maximumCacheSize () const
| Get the maximum cache size (in MiB).
uInt | cacheSize (rownr_t rownr) const
| Get the current cache size (in buckets) for the hypercube in the given row.
const IPosition & | hypercubeShape (rownr_t rownr) const
| Get the hypercube shape of the data in the given row.
const IPosition & | tileShape (rownr_t rownr) const
| Get the tile shape of the data in the given row.
uInt | bucketSize (rownr_t rownr) const
| Get the bucket size (in bytes) of the hypercube in the given row.
const Record & | valueRecord (rownr_t rownr) const
| Get coordinate and id values of the hypercube in the given row.
uInt | nhypercubes () const
| Return the number of hypercubes.
uInt | getCacheSize (uInt hypercube) const
| Get the current cache size (in buckets) for the given hypercube.
const IPosition & | getHypercubeShape (uInt hypercube) const
| Get the shape of the given hypercube.
const IPosition & | getTileShape (uInt hypercube) const
| Get the tile shape of the given hypercube.
uInt | getBucketSize (uInt hypercube) const
| Get the bucket size (in bytes) of the given hypercube.
const Record & | getValueRecord (uInt hypercube) const
| Get coordinate and id values of the given hypercube.
uInt | calcCacheSize (rownr_t rownr, const IPosition &sliceShape, const IPosition &axisPath) const
| Calculate the cache size (in buckets) for accessing the hypercube containing the given row.
uInt | calcCacheSize (rownr_t rownr, const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath) const
void | setCacheSize (rownr_t rownr, const IPosition &sliceShape, const IPosition &axisPath, Bool forceSmaller=True)
| Set the cache size using the corresponding calcCacheSize function mentioned above.
void | setCacheSize (rownr_t rownr, const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath, Bool forceSmaller=True)
void | setCacheSize (rownr_t rownr, uInt nbuckets, Bool forceSmaller=True)
| Set the cache size for accessing the hypercube containing the given row.
void | setHypercubeCacheSize (uInt hypercube, uInt nbuckets, Bool forceSmaller=True)
| This version allows setting the tile cache for a particular hypercube.
void | clearCaches ()
| Clear the caches used by the hypercubes in this storage manager.
Public Member Functions inherited from casacore::RODataManAccessor
| RODataManAccessor ()
| Construct an empty object.
| RODataManAccessor (const Table &table, const String &name, Bool byColumn)
| Construct the accessor object for a data manager in the table.
virtual | ~RODataManAccessor ()
void | setProperties (const Record &) const
| Set data manager properties using the fields in the record.
Record | getProperties () const
| Get data manager properties as a record.
String | dataManagerType () const
| Get the data manager type.
String | dataManagerName () const
| Get the data manager name.
uInt | dataManagerSeqNr () const
| Get the data manager sequence nr.
void | showCacheStatistics (ostream &os) const
| Show IO statistics.

## Protected Member Functions

DataManager * | getDataManager () const
| Get the data manager.
Protected Member Functions inherited from casacore::RODataManAccessor
DataManager * | baseDataManager () const
| Get the data manager for the given data manager or column name.

## Private Attributes

TiledStMan * | dataManPtr_p

## Detailed Description

Give access to some TiledStMan functions

### Intended use:

Internal

### Review Status

Reviewed By:
  Gareth Hunt
Date Reviewed:
  94Nov17

### Prerequisite

- TiledStMan

### Synopsis

The Table system has one or more storage managers underneath. These storage managers are invisible and there is no way to get access to them. However, the TiledStMan -type storage managers are quite specific. This class ROTiledStManAccessor gives the user the means to access a TiledStMan-type object and to control it in some way.

The actions that can be performed deal with the caches used in a tiled storage manager. Per hypercube a cache is used to keep as many tiles in memory as needed for efficient access to the data. The cache size needed is calculated automatically. However, it may be possible that a cache uses too much memory. Therefore a maximum cache size can be specified, which can be done in 2 ways:

1. To the constructor of a tiled storage manager. This is persistent and acts as the default maximum cache size.
2. Using the function setMaximumCacheSize in this accessor class. This is not persistent and acts as a temporary overwrite of the default maximum cache size.

It is recommended to set the maximum cache size only when the tiled storage manager may use too much memory. Setting a maximum could have the effect that the optimal number of tiles does not fit in memory leading to excessive read/write activity.
For example:
A hypercube has shape [12,20,30,42] and tile shape [4,5,6,7]. The hypercube contains doubles, so the tilesize is 6720 bytes. The number of tiles per dimension is [3,4,5,6] resulting in 360 tiles. Iterating through that hypercube requires that some tiles are kept in memory to avoid too many read operations. When iterating like

for (uInt i3=0; i3<42; i3++)
for (uInt i2=0; i2<30; i2++)
for (uInt i1=0; i1<20; i1++)
for (uInt i0=0; i0<12; i0++)
do something with data[i0,i1,i2,i3]
casacore::uInt
unsigned int uInt
Definition aipstype.h:49

it is clear that it is best to have a cache which can contain at least 3*4*5 tiles. In that way each tile is read only once resulting in 360 reads.
When the cache can hold 3*4 tiles, the first tiles of the 3rd dimension have been flushed out when the second step in the 4th dimension gets executed. So the tiles have to be reread for each step in the 4th dimension, resulting in 3*4*5*42 = 2520 reads.
When the cache can hold only one tile, the situation is dramatic. A tile has to be read for every 4 pixels, resulting in 75600 reads.

Apart from setting the maximum cache size, one can also clear the caches. This can be useful to free memory when an iteration through the data in the tiled storage manager has been done completely. Clearing the caches also clears their statistics (see below).

Showing the statistics of the caches used by a tiled storage manager is possible. Per cache it shows the number of tiles accessed and the number of tiles actually read, written, or initialized. The hit ratio gives a good idea of the cache behaviour.

Note that the maximum cache size is not an absolute maximum. When the optimal number of tiles do not fit, it is tried if they fit when using an overdrawn of maximum 10%. If so, it uses that overdrawn. If not, it uses the maximum cache size.

A few functions exist to get information about a hypercube. The 'get' functions get the information for the given hypercube, while similar functions without the 'get' prefix do the same for the given row.

### Motivation

In principle a pointer to TiledStMan could be used. However, that would give access to all public functions. Furthermore it could not distinguish between read/write and readonly tables.

### Example

This example shows how to set the maximum cache size for the tiled storage manager with the name "TSMExample". The cache size is not persistent, i.e. when the same table is reopened at a later time, this cache size is not remembered.

// Open a table.
Table table("someName.data");
// Set the maximum cache size of its tiled hypercube storage
// manager TSMExample to 0.5 MiB.
ROTiledStManAccessor accessor(table, "TSMExample");
accessor.setMaximumCacheSize (512*1024);
casacore::ROTiledStManAccessor::ROTiledStManAccessor
ROTiledStManAccessor()
Default constructor should be used with care.
casacore::Table
Definition Table.h:157

Definition at line 154 of file TiledStManAccessor.h.

## Constructor & Destructor Documentation

## ROTiledStManAccessor() [1/3]

casacore::ROTiledStManAccessor::ROTiledStManAccessor | ( |  | ) |

Default constructor should be used with care.

The resulting object cannot be used for any other operation until a 'true' ROTiledStManAccessor object is assigned to it.

Referenced by operator=(), and ROTiledStManAccessor().

## ROTiledStManAccessor() [2/3]

casacore::ROTiledStManAccessor::ROTiledStManAccessor | ( | const Table & | table,
|  | const String & | name,
|  | Bool | byColumn = False )

Construct the object for a data manager in the table given the name of the data manager or the column.

An exception is thrown if the data manager type is not any tiled storage manager.

References casacore::False, and casacore::name().

## ~ROTiledStManAccessor()

virtual casacore::ROTiledStManAccessor::~ROTiledStManAccessor | ( |  | ) |

virtual

## ROTiledStManAccessor() [3/3]

casacore::ROTiledStManAccessor::ROTiledStManAccessor | ( | const ROTiledStManAccessor & | that | ) |

Copy constructor (reference semantics).

References ROTiledStManAccessor().

## Member Function Documentation

## bucketSize()

uInt casacore::ROTiledStManAccessor::bucketSize | ( | rownr_t | rownr | ) | const

Get the bucket size (in bytes) of the hypercube in the given row.

## cacheSize()

uInt casacore::ROTiledStManAccessor::cacheSize | ( | rownr_t | rownr | ) | const

Get the current cache size (in buckets) for the hypercube in the given row.

## calcCacheSize() [1/2]

uInt casacore::ROTiledStManAccessor::calcCacheSize | ( | rownr_t | rownr,
|  | const IPosition & | sliceShape,
|  | const IPosition & | axisPath ) const

Calculate the cache size (in buckets) for accessing the hypercube containing the given row.

It takes the maximum cache size into account (allowing an overdraft of 10%). It uses the given axisPath (i.e. traversal order) to determine the optimum size. A window can be specified to indicate that only the given subset of the hypercube will be accessed. The window defaults to the entire hypercube.
The length of the slice and window arguments and axisPath must be less or equal to the dimensionality of the hypercube. The non-specified windowStart parts default to 0. The non-specified windowLength parts default to the hypercube shape. The non-specified sliceShape parts default to 1.
Axispath = [2,0,1] indicates that the z-axis changes most rapidly, thereafter x and y. An axis can occur only once in the axisPath. The non-specified axisPath parts get the natural order. E.g. in the previous example axisPath=[2] defines the same path.

## calcCacheSize() [2/2]

uInt casacore::ROTiledStManAccessor::calcCacheSize | ( | rownr_t | rownr,
|  | const IPosition & | sliceShape,
|  | const IPosition & | windowStart,
|  | const IPosition & | windowLength,
|  | const IPosition & | axisPath ) const

## clearCaches()

void casacore::ROTiledStManAccessor::clearCaches | ( |  | ) |

Clear the caches used by the hypercubes in this storage manager.

It will flush the caches as needed and remove all buckets from them resulting in a possibly large drop in memory used.

## getBucketSize()

uInt casacore::ROTiledStManAccessor::getBucketSize | ( | uInt | hypercube | ) | const

Get the bucket size (in bytes) of the given hypercube.

## getCacheSize()

uInt casacore::ROTiledStManAccessor::getCacheSize | ( | uInt | hypercube | ) | const

Get the current cache size (in buckets) for the given hypercube.

## getDataManager()

DataManager * casacore::ROTiledStManAccessor::getDataManager | ( |  | ) | const

protected

Get the data manager.

## getHypercubeShape()

const IPosition & casacore::ROTiledStManAccessor::getHypercubeShape | ( | uInt | hypercube | ) | const

Get the shape of the given hypercube.

## getTileShape()

const IPosition & casacore::ROTiledStManAccessor::getTileShape | ( | uInt | hypercube | ) | const

Get the tile shape of the given hypercube.

## getValueRecord()

const Record & casacore::ROTiledStManAccessor::getValueRecord | ( | uInt | hypercube | ) | const

Get coordinate and id values of the given hypercube.

References casacore::Record().

## hypercubeShape()

const IPosition & casacore::ROTiledStManAccessor::hypercubeShape | ( | rownr_t | rownr | ) | const

Get the hypercube shape of the data in the given row.

## maximumCacheSize()

uInt casacore::ROTiledStManAccessor::maximumCacheSize | ( |  | ) | const

Get the maximum cache size (in MiB).

## nhypercubes()

uInt casacore::ROTiledStManAccessor::nhypercubes | ( |  | ) | const

Return the number of hypercubes.

## operator=()

ROTiledStManAccessor & casacore::ROTiledStManAccessor::operator= | ( | const ROTiledStManAccessor & | that | ) |

Assignment (reference semantics).

References ROTiledStManAccessor().

## setCacheSize() [1/3]

void casacore::ROTiledStManAccessor::setCacheSize | ( | rownr_t | rownr,
|  | const IPosition & | sliceShape,
|  | const IPosition & | axisPath,
|  | Bool | forceSmaller = True )

Set the cache size using the corresponding calcCacheSize function mentioned above.

When forceSmaller is False, the cache is not resized when the new size is smaller.

References casacore::True.

## setCacheSize() [2/3]

void casacore::ROTiledStManAccessor::setCacheSize | ( | rownr_t | rownr,
|  | const IPosition & | sliceShape,
|  | const IPosition & | windowStart,
|  | const IPosition & | windowLength,
|  | const IPosition & | axisPath,
|  | Bool | forceSmaller = True )

References casacore::True.

## setCacheSize() [3/3]

void casacore::ROTiledStManAccessor::setCacheSize | ( | rownr_t | rownr,
|  | uInt | nbuckets,
|  | Bool | forceSmaller = True )

Set the cache size for accessing the hypercube containing the given row.

When the give cache size exceeds the maximum cache size with more than 10%, the maximum cache size is used instead.
When forceSmaller is False, the cache is not resized when the new size is smaller.

References casacore::True.

## setHypercubeCacheSize()

void casacore::ROTiledStManAccessor::setHypercubeCacheSize | ( | uInt | hypercube,
|  | uInt | nbuckets,
|  | Bool | forceSmaller = True )

This version allows setting the tile cache for a particular hypercube.

This is useful when iterating over the hypercubes in an StMan.

References casacore::True.

## setMaximumCacheSize()

void casacore::ROTiledStManAccessor::setMaximumCacheSize | ( | uInt | nMiB | ) |

Set the maximum cache size (in MibiByte) to be used by a hypercube in the storage manager.

Note that each hypercube has its own cache. 0 means unlimited. The initial maximum cache size is unlimited. The maximum cache size given in this way is not persistent. Only the maximum cache size given to the constructors of the tiled storage managers, is persistent.

## tileShape()

const IPosition & casacore::ROTiledStManAccessor::tileShape | ( | rownr_t | rownr | ) | const

Get the tile shape of the data in the given row.

Referenced by casacore::TiledDataStManAccessor::addHypercube().

## valueRecord()

const Record & casacore::ROTiledStManAccessor::valueRecord | ( | rownr_t | rownr | ) | const

Get coordinate and id values of the hypercube in the given row.

References casacore::Record().

## Member Data Documentation

## dataManPtr_p

TiledStMan* casacore::ROTiledStManAccessor::dataManPtr_p

private

Definition at line 290 of file TiledStManAccessor.h.

The documentation for this class was generated from the following file:

- tables/DataMan/TiledStManAccessor.h