casa
$Rev:20696$
|
Base class of the Incremental Storage Manager. More...
#include <ISMBase.h>
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 DataManager * | clone () 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). | |
ISMBucket * | getBucket (uInt rownr, uInt &bucketStartRow, uInt &bucketNrrow) |
Get the bucket containing the given row. | |
ISMBucket * | nextBucket (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) | |
ISMColumn & | getColumn (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. | |
StManArrayFile * | openArrayFile (ByteIO::OpenOption opt) |
Open (if needed) the file for indirect arrays with the given mode. | |
Static Public Member Functions | |
static DataManager * | makeObject (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). | |
ISMBase & | operator= (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 DataManagerColumn * | makeScalarColumn (const String &name, int dataType, const String &dataTypeID) |
Create a column in the storage manager on behalf of a table column. | |
virtual DataManagerColumn * | makeDirArrColumn (const String &name, int dataType, const String &dataTypeID) |
Create a direct array column. | |
virtual DataManagerColumn * | makeIndArrColumn (const String &name, int dataType, const String &dataTypeID) |
Create an indirect array column. | |
BucketCache & | getCache () |
Get the cache object. | |
ISMIndex & | getIndex () |
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. | |
StManArrayFile * | iosfile_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. | |
BucketCache * | cache_p |
The cache with the ISM buckets. | |
BucketFile * | file_p |
The file containing all data. | |
ISMIndex * | index_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). |
Base class of the Incremental Storage Manager.
Internal
ISMBase is the base class of the Incremental Storage Manager.
The behaviour of this class is described in IncrementalStMan .
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 .
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).
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] |
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.
void casa::ISMBase::clearCache | ( | ) |
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] |
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] |
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] |
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.
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.
void casa::ISMBase::setBucketDirty | ( | ) |
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.
uInt casa::ISMBase::uniqueNr | ( | ) | [inline] |
uInt casa::ISMBase::version | ( | ) | const [inline] |
void casa::ISMBase::writeIndex | ( | ) | [private] |
Write the index (at the end of the file).
uInt casa::ISMBase::bucketSize_p [private] |
BucketCache* casa::ISMBase::cache_p [private] |
uInt casa::ISMBase::cacheSize_p [private] |
Bool casa::ISMBase::checkBucketSize_p [private] |
PtrBlock<ISMColumn*> casa::ISMBase::colSet_p [private] |
Bool casa::ISMBase::dataChanged_p [private] |
String casa::ISMBase::dataManName_p [private] |
BucketFile* casa::ISMBase::file_p [private] |
Int casa::ISMBase::firstFree_p [private] |
ISMIndex* casa::ISMBase::index_p [private] |
StManArrayFile* casa::ISMBase::iosfile_p [private] |
uInt casa::ISMBase::nbucketInit_p [private] |
uInt casa::ISMBase::nFreeBucket_p [private] |
uInt casa::ISMBase::nrrow_p [private] |
uInt casa::ISMBase::persCacheSize_p [private] |
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().
uInt casa::ISMBase::uIntSize_p [private] |
The size of a uInt in external format (local or canonical).
Definition at line 358 of file ISMBase.h.
Referenced by uIntSize().
uInt casa::ISMBase::uniqnr_p [private] |
Unique nr for column in this storage manager.
Definition at line 330 of file ISMBase.h.
Referenced by uniqueNr().
uInt casa::ISMBase::version_p [private] |