casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
casa::ISMBase Class Reference

Base class of the Incremental Storage Manager. More...

#include <ISMBase.h>

Inheritance diagram for casa::ISMBase:
casa::DataManager casa::IncrementalStMan

List of all members.

Public Member Functions

 ISMBase (uInt bucketSize=0, Bool checkBucketSize=True, uInt cacheSize=1)
 Create an incremental storage manager without a name.
 ISMBase (const String &dataManagerName, uInt bucketSize, Bool checkBucketSize, uInt cacheSize)
 Create an incremental storage manager with the given name.
 ISMBase (const String &aDataManName, const Record &spec)
 Create an incremental storage manager with the given name.
 ~ISMBase ()
virtual DataManagerclone () const
 Clone this object.
virtual String dataManagerType () const
 Get the type name of the data manager (i.e.
virtual String dataManagerName () const
 Get the name given to the storage manager (in the constructor).
virtual Record dataManagerSpec () const
 Record a record containing data manager specifications.
virtual Record getProperties () const
 Get data manager properties that can be modified.
virtual void setProperties (const Record &spec)
 Modify data manager properties.
uInt version () const
 Get the version of the class.
void setCacheSize (uInt cacheSize, Bool canExceedNrBuckets)
 Set the cache size (in buckets).
uInt cacheSize () const
 Get the current cache size (in buckets).
void clearCache ()
 Clear the cache used by this storage manager.
void showCacheStatistics (ostream &os) const
 Show the statistics of all caches used.
uInt bucketSize () const
 Get the bucket size (in bytes).
uInt uIntSize () const
 Get the size of a uInt in external format (can be canonical or local).
ISMBucketgetBucket (uInt rownr, uInt &bucketStartRow, uInt &bucketNrrow)
 Get the bucket containing the given row.
ISMBucketnextBucket (uInt &cursor, uInt &bucketStartRow, uInt &bucketNrrow)
 Get the next bucket.
char * tempBuffer () const
 Get access to the temporary buffer.
uInt uniqueNr ()
 Get a unique column number for the column (it is only unique for this storage manager).
uInt nrow () const
 Get the number of rows in this storage manager.
virtual Bool canAddRow () const
 Can the storage manager add rows? (yes)
virtual Bool canRemoveRow () const
 Can the storage manager delete rows? (yes)
virtual Bool canAddColumn () const
 Can the storage manager add columns? (not yet)
virtual Bool canRemoveColumn () const
 Can the storage manager delete columns? (not yet)
ISMColumngetColumn (uInt colnr)
 Get access to the given column.
void addBucket (uInt rownr, ISMBucket *bucket)
 Add a bucket to the storage manager (i.e.
void setBucketDirty ()
 Make the current bucket in the cache dirty (i.e.
StManArrayFileopenArrayFile (ByteIO::OpenOption opt)
 Open (if needed) the file for indirect arrays with the given mode.

Static Public Member Functions

static DataManagermakeObject (const String &dataManagerType, const Record &spec)
 Make the object from the type name string.

Private Member Functions

 ISMBase (const ISMBase &that)
 Copy constructor (only meant for clone function).
ISMBaseoperator= (const ISMBase &that)
 Assignment cannot be used.
void recreate ()
 (Re)create the index, file, and cache object.
virtual Bool flush (AipsIO &, Bool fsync)
 Flush and optionally fsync the data.
virtual void create (uInt nrrow)
 Let the storage manager create files as needed for a new table.
virtual void open (uInt nrrow, AipsIO &)
 Open the storage manager file for an existing table, read in the data, and let the ISMColumn objects read their data.
virtual void resync (uInt nrrow)
 Resync the storage manager with the new file contents.
virtual void reopenRW ()
 Reopen the storage manager files for read/write.
virtual void deleteManager ()
 The data manager will be deleted (because all its columns are requested to be deleted).
void init ()
 Let the storage manager initialize itself.
virtual void addRow (uInt nrrow)
 Add rows to the storage manager.
virtual void removeRow (uInt rownr)
 Delete a row from all columns.
virtual void addColumn (DataManagerColumn *)
 Do the final addition of a column.
virtual void removeColumn (DataManagerColumn *)
 Remove a column from the data file and the colSet_p.
virtual DataManagerColumnmakeScalarColumn (const String &name, int dataType, const String &dataTypeID)
 Create a column in the storage manager on behalf of a table column.
virtual DataManagerColumnmakeDirArrColumn (const String &name, int dataType, const String &dataTypeID)
 Create a direct array column.
virtual DataManagerColumnmakeIndArrColumn (const String &name, int dataType, const String &dataTypeID)
 Create an indirect array column.
BucketCachegetCache ()
 Get the cache object.
ISMIndexgetIndex ()
 Get the index object.
void makeCache ()
 Construct the cache object (if not constructed yet).
void makeIndex ()
 Construct the index object (if not constructed yet) and read it.
void readIndex ()
 Read the index (at the end of the file).
void writeIndex ()
 Write the index (at the end of the file).

Private Attributes

String dataManName_p
 Name of data manager.
uInt version_p
 The version of the class.
StManArrayFileiosfile_p
 The file containing the indirect arrays.
uInt uniqnr_p
 Unique nr for column in this storage manager.
uInt nrrow_p
 The number of rows in the columns.
PtrBlock< ISMColumn * > colSet_p
 The assembly of all columns.
BucketCachecache_p
 The cache with the ISM buckets.
BucketFilefile_p
 The file containing all data.
ISMIndexindex_p
 The ISM bucket index.
uInt persCacheSize_p
 The persistent cache size.
uInt cacheSize_p
 The actual cache size.
uInt nbucketInit_p
 The initial number of buckets in the cache.
uInt nFreeBucket_p
 The nr of free buckets.
Int firstFree_p
 The first free bucket.
uInt bucketSize_p
 The bucket size.
Bool checkBucketSize_p
 Check a positive bucketsize?
Bool dataChanged_p
 Has the data changed since the last flush?
uInt uIntSize_p
 The size of a uInt in external format (local or canonical).
char * tempBuffer_p
 A temporary read/write buffer (also for other classes).

Detailed Description

Base class of the Incremental Storage Manager.

Intended use:

Internal

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Test programs:
tIncrementalStMan

Prerequisite

Etymology

ISMBase is the base class of the Incremental Storage Manager.

Synopsis

The behaviour of this class is described in IncrementalStMan .

Motivation

The public interface of ISMBase is quite large, because the other internal ISM classes need these functions. To have a class with a minimal interface for the normal user, class IncrementalStMan is derived from it.
IncrementalStMan needs an isA- instead of hasA-relation to be able to bind columns to it in class SetupNewTable .

To Do

Definition at line 87 of file ISMBase.h.


Constructor & Destructor Documentation

casa::ISMBase::ISMBase ( uInt  bucketSize = 0,
Bool  checkBucketSize = True,
uInt  cacheSize = 1 
) [explicit]

Create an incremental storage manager without a name.

The bucket size has to be given in bytes and the cache size in buckets. The bucket size is checked or calculated as described in IncrementalStMan.h.

casa::ISMBase::ISMBase ( const String dataManagerName,
uInt  bucketSize,
Bool  checkBucketSize,
uInt  cacheSize 
)

Create an incremental storage manager with the given name.

The bucket size has to be given in bytes and the cache size in buckets. The bucket size is checked or calculated as described in IncrementalStMan.h.

casa::ISMBase::ISMBase ( const String aDataManName,
const Record spec 
)

Create an incremental storage manager with the given name.

The specifications are in the record (as created by dataManagerSpec).

casa::ISMBase::ISMBase ( const ISMBase that) [private]

Copy constructor (only meant for clone function).


Member Function Documentation

void casa::ISMBase::addBucket ( uInt  rownr,
ISMBucket bucket 
)

Add a bucket to the storage manager (i.e.

to the cache). The pointer is taken over.

virtual void casa::ISMBase::addColumn ( DataManagerColumn ) [private, virtual]

Do the final addition of a column.

The DataManagerColumn object has already been created (by the makeXXColumn function) and added to colSet_p. However, it still has to be added to the data files, which is done by this function. It uses the pointer to find the correct column in the colSet_p.

Reimplemented from casa::DataManager.

virtual void casa::ISMBase::addRow ( uInt  nrrow) [private, virtual]

Add rows to the storage manager.

Per column it extends the interval for which the last value written is valid.

Reimplemented from casa::DataManager.

uInt casa::ISMBase::bucketSize ( ) const [inline]

Get the bucket size (in bytes).

Definition at line 384 of file ISMBase.h.

References bucketSize_p.

uInt casa::ISMBase::cacheSize ( ) const [inline]

Get the current cache size (in buckets).

Definition at line 369 of file ISMBase.h.

References cacheSize_p.

virtual Bool casa::ISMBase::canAddColumn ( ) const [virtual]

Can the storage manager add columns? (not yet)

Reimplemented from casa::DataManager.

virtual Bool casa::ISMBase::canAddRow ( ) const [virtual]

Can the storage manager add rows? (yes)

Reimplemented from casa::DataManager.

virtual Bool casa::ISMBase::canRemoveColumn ( ) const [virtual]

Can the storage manager delete columns? (not yet)

Reimplemented from casa::DataManager.

virtual Bool casa::ISMBase::canRemoveRow ( ) const [virtual]

Can the storage manager delete rows? (yes)

Reimplemented from casa::DataManager.

Clear the cache used by this storage manager.

It will flush the cache as needed and remove all buckets from it.

virtual DataManager* casa::ISMBase::clone ( ) const [virtual]

Clone this object.

It does not clone ISMColumn objects possibly used. The caller has to delete the newly created object.

Implements casa::DataManager.

virtual void casa::ISMBase::create ( uInt  nrrow) [private, virtual]

Let the storage manager create files as needed for a new table.

This allows a column with an indirect array to create its file.

Implements casa::DataManager.

virtual String casa::ISMBase::dataManagerName ( ) const [virtual]

Get the name given to the storage manager (in the constructor).

Reimplemented from casa::DataManager.

virtual Record casa::ISMBase::dataManagerSpec ( ) const [virtual]

Record a record containing data manager specifications.

Reimplemented from casa::DataManager.

virtual String casa::ISMBase::dataManagerType ( ) const [virtual]

Get the type name of the data manager (i.e.

IncrementalStMan).

Implements casa::DataManager.

virtual void casa::ISMBase::deleteManager ( ) [private, virtual]

The data manager will be deleted (because all its columns are requested to be deleted).

So clean up the things needed (e.g. delete files).

Implements casa::DataManager.

virtual Bool casa::ISMBase::flush ( AipsIO ,
Bool  fsync 
) [private, virtual]

Flush and optionally fsync the data.

It returns a True status if it had to flush (i.e. if data have changed).

Implements casa::DataManager.

ISMBucket* casa::ISMBase::getBucket ( uInt  rownr,
uInt bucketStartRow,
uInt bucketNrrow 
)

Get the bucket containing the given row.

Also return the first and last row of that bucket. The bucket object is created and deleted by the caching mechanism.

BucketCache & casa::ISMBase::getCache ( ) [inline, private]

Get the cache object.

This will construct the cache object if not present yet. The cache object will be deleted by the destructor.

Definition at line 399 of file ISMBase.h.

References cache_p, and makeCache().

ISMColumn & casa::ISMBase::getColumn ( uInt  colnr) [inline]

Get access to the given column.

Definition at line 415 of file ISMBase.h.

References colSet_p.

ISMIndex & casa::ISMBase::getIndex ( ) [inline, private]

Get the index object.

This will construct the index object if not present yet. The index object will be deleted by the destructor.

Definition at line 407 of file ISMBase.h.

References index_p, and makeIndex().

virtual Record casa::ISMBase::getProperties ( ) const [virtual]

Get data manager properties that can be modified.

It is only ActualCacheSize (the actual cache size in buckets). It is a subset of the data manager specification.

Reimplemented from casa::DataManager.

void casa::ISMBase::init ( ) [private]

Let the storage manager initialize itself.

It is used by create and open.

void casa::ISMBase::makeCache ( ) [private]

Construct the cache object (if not constructed yet).

Referenced by getCache().

virtual DataManagerColumn* casa::ISMBase::makeDirArrColumn ( const String name,
int  dataType,
const String dataTypeID 
) [private, virtual]

Create a direct array column.

Implements casa::DataManager.

virtual DataManagerColumn* casa::ISMBase::makeIndArrColumn ( const String name,
int  dataType,
const String dataTypeID 
) [private, virtual]

Create an indirect array column.

Implements casa::DataManager.

void casa::ISMBase::makeIndex ( ) [private]

Construct the index object (if not constructed yet) and read it.

Referenced by getIndex().

static DataManager* casa::ISMBase::makeObject ( const String dataManagerType,
const Record spec 
) [static]

Make the object from the type name string.

This function gets registered in the DataManager "constructor" map. The caller has to delete the object.

virtual DataManagerColumn* casa::ISMBase::makeScalarColumn ( const String name,
int  dataType,
const String dataTypeID 
) [private, virtual]

Create a column in the storage manager on behalf of a table column.

The caller has to delete the newly created object.

Create a scalar column.

Implements casa::DataManager.

ISMBucket* casa::ISMBase::nextBucket ( uInt cursor,
uInt bucketStartRow,
uInt bucketNrrow 
)

Get the next bucket.

cursor=0 indicates the start of the iteration. The first bucket returned is the bucket containing the rownr given in bucketStartRow. After each iteration BucketStartRow and bucketNrrow are set. A 0 is returned when no more buckets. The bucket object is created and deleted by the caching mechanism.

uInt casa::ISMBase::nrow ( ) const [inline]

Get the number of rows in this storage manager.

Definition at line 379 of file ISMBase.h.

References nrrow_p.

virtual void casa::ISMBase::open ( uInt  nrrow,
AipsIO  
) [private, virtual]

Open the storage manager file for an existing table, read in the data, and let the ISMColumn objects read their data.

Implements casa::DataManager.

Open (if needed) the file for indirect arrays with the given mode.

Return a pointer to the object.

ISMBase& casa::ISMBase::operator= ( const ISMBase that) [private]

Assignment cannot be used.

void casa::ISMBase::readIndex ( ) [private]

Read the index (at the end of the file).

void casa::ISMBase::recreate ( ) [private]

(Re)create the index, file, and cache object.

virtual void casa::ISMBase::removeColumn ( DataManagerColumn ) [private, virtual]

Remove a column from the data file and the colSet_p.

The DataManagerColumn object gets deleted..

Reimplemented from casa::DataManager.

virtual void casa::ISMBase::removeRow ( uInt  rownr) [private, virtual]

Delete a row from all columns.

Reimplemented from casa::DataManager.

virtual void casa::ISMBase::reopenRW ( ) [private, virtual]

Reopen the storage manager files for read/write.

Reimplemented from casa::DataManager.

virtual void casa::ISMBase::resync ( uInt  nrrow) [private, virtual]

Resync the storage manager with the new file contents.

This is done by clearing the cache.

Implements casa::DataManager.

Make the current bucket in the cache dirty (i.e.

something has been changed in it and it needs to be written when removed from the cache). (used by ISMColumn::putValue).

void casa::ISMBase::setCacheSize ( uInt  cacheSize,
Bool  canExceedNrBuckets 
)

Set the cache size (in buckets).

If canExceedNrBuckets=True, the given cache size can be larger than the nr of buckets in the file. In this way the cache can be made large enough for a future file extnsion. Otherwise, it is limited to the actual number of buckets. This is useful if one wants the entire file to be cached.

virtual void casa::ISMBase::setProperties ( const Record spec) [virtual]

Modify data manager properties.

Only ActualCacheSize can be used. It is similar to function setCacheSize with canExceedNrBuckets=False.

Reimplemented from casa::DataManager.

void casa::ISMBase::showCacheStatistics ( ostream &  os) const

Show the statistics of all caches used.

char * casa::ISMBase::tempBuffer ( ) const [inline]

Get access to the temporary buffer.

Definition at line 394 of file ISMBase.h.

References tempBuffer_p.

uInt casa::ISMBase::uIntSize ( ) const [inline]

Get the size of a uInt in external format (can be canonical or local).

Definition at line 389 of file ISMBase.h.

References uIntSize_p.

Get a unique column number for the column (it is only unique for this storage manager).

This is used by ISMColumnIndArr to create a unique file name.

Definition at line 374 of file ISMBase.h.

References uniqnr_p.

uInt casa::ISMBase::version ( ) const [inline]

Get the version of the class.

Definition at line 364 of file ISMBase.h.

References version_p.

void casa::ISMBase::writeIndex ( ) [private]

Write the index (at the end of the file).


Member Data Documentation

The bucket size.

Definition at line 352 of file ISMBase.h.

Referenced by bucketSize().

The cache with the ISM buckets.

Definition at line 336 of file ISMBase.h.

Referenced by getCache().

The actual cache size.

Definition at line 344 of file ISMBase.h.

Referenced by cacheSize().

Check a positive bucketsize?

Definition at line 354 of file ISMBase.h.

The assembly of all columns.

Definition at line 334 of file ISMBase.h.

Referenced by getColumn().

Has the data changed since the last flush?

Definition at line 356 of file ISMBase.h.

Name of data manager.

Definition at line 324 of file ISMBase.h.

The file containing all data.

Definition at line 338 of file ISMBase.h.

The first free bucket.

Definition at line 350 of file ISMBase.h.

The ISM bucket index.

Definition at line 340 of file ISMBase.h.

Referenced by getIndex().

The file containing the indirect arrays.

Definition at line 328 of file ISMBase.h.

The initial number of buckets in the cache.

Definition at line 346 of file ISMBase.h.

The nr of free buckets.

Definition at line 348 of file ISMBase.h.

The number of rows in the columns.

Definition at line 332 of file ISMBase.h.

Referenced by nrow().

The persistent cache size.

Definition at line 342 of file ISMBase.h.

char* casa::ISMBase::tempBuffer_p [private]

A temporary read/write buffer (also for other classes).

Definition at line 360 of file ISMBase.h.

Referenced by tempBuffer().

The size of a uInt in external format (local or canonical).

Definition at line 358 of file ISMBase.h.

Referenced by uIntSize().

Unique nr for column in this storage manager.

Definition at line 330 of file ISMBase.h.

Referenced by uniqueNr().

The version of the class.

Definition at line 326 of file ISMBase.h.

Referenced by version().


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