StManAipsIO.h

Classes

StManColumnAipsIO -- AipsIO table column storage manager class (full description)
StManAipsIO -- AipsIO table storage manager class (full description)

class StManColumnAipsIO : public StManColumn

Interface

Public Members
StManColumnAipsIO (StManAipsIO* stMan, int dataType, Bool byPtr)
virtual ~StManColumnAipsIO()
void getBoolV (uInt rownr, Bool* dataPtr)
void getuCharV (uInt rownr, uChar* dataPtr)
void getShortV (uInt rownr, Short* dataPtr)
void getuShortV (uInt rownr, uShort* dataPtr)
void getIntV (uInt rownr, Int* dataPtr)
void getuIntV (uInt rownr, uInt* dataPtr)
void getfloatV (uInt rownr, float* dataPtr)
void getdoubleV (uInt rownr, double* dataPtr)
void getComplexV (uInt rownr, Complex* dataPtr)
void getDComplexV (uInt rownr, DComplex* dataPtr)
void getStringV (uInt rownr, String* dataPtr)
void putBoolV (uInt rownr, const Bool* dataPtr)
void putuCharV (uInt rownr, const uChar* dataPtr)
void putShortV (uInt rownr, const Short* dataPtr)
void putuShortV (uInt rownr, const uShort* dataPtr)
void putIntV (uInt rownr, const Int* dataPtr)
void putuIntV (uInt rownr, const uInt* dataPtr)
void putfloatV (uInt rownr, const float* dataPtr)
void putdoubleV (uInt rownr, const double* dataPtr)
void putComplexV (uInt rownr, const Complex* dataPtr)
void putDComplexV (uInt rownr, const DComplex* dataPtr)
void putStringV (uInt rownr, const String* dataPtr)
uInt getBlockBoolV (uInt rownr, uInt nrmax, Bool* dataPtr)
uInt getBlockuCharV (uInt rownr, uInt nrmax, uChar* dataPtr)
uInt getBlockShortV (uInt rownr, uInt nrmax, Short* dataPtr)
uInt getBlockuShortV (uInt rownr, uInt nrmax, uShort* dataPtr)
uInt getBlockIntV (uInt rownr, uInt nrmax, Int* dataPtr)
uInt getBlockuIntV (uInt rownr, uInt nrmax, uInt* dataPtr)
uInt getBlockfloatV (uInt rownr, uInt nrmax, float* dataPtr)
uInt getBlockdoubleV (uInt rownr, uInt nrmax, double* dataPtr)
uInt getBlockComplexV (uInt rownr, uInt nrmax, Complex* dataPtr)
uInt getBlockDComplexV (uInt rownr, uInt nrmax, DComplex* dataPtr)
uInt getBlockStringV (uInt rownr, uInt nrmax, String* dataPtr)
void putBlockBoolV (uInt rownr, uInt nrmax, const Bool* dataPtr)
void putBlockuCharV (uInt rownr, uInt nrmax, const uChar* dataPtr)
void putBlockShortV (uInt rownr, uInt nrmax, const Short* dataPtr)
void putBlockuShortV (uInt rownr, uInt nrmax, const uShort* dataPtr)
void putBlockIntV (uInt rownr, uInt nrmax, const Int* dataPtr)
void putBlockuIntV (uInt rownr, uInt nrmax, const uInt* dataPtr)
void putBlockfloatV (uInt rownr, uInt nrmax, const float* dataPtr)
void putBlockdoubleV (uInt rownr, uInt nrmax, const double* dataPtr)
void putBlockComplexV (uInt rownr, uInt nrmax, const Complex* dataPtr)
void putBlockDComplexV (uInt rownr, uInt nrmax, const DComplex* dataPtr)
void putBlockStringV (uInt rownr, uInt nrmax, const String* dataPtr)
virtual void getScalarColumnCellsBoolV (const RefRows& rownrs, Vector<Bool>* dataPtr)
virtual void getScalarColumnCellsuCharV (const RefRows& rownrs, Vector<uChar>* dataPtr)
virtual void getScalarColumnCellsShortV (const RefRows& rownrs, Vector<Short>* dataPtr)
virtual void getScalarColumnCellsuShortV (const RefRows& rownrs, Vector<uShort>* dataPtr)
virtual void getScalarColumnCellsIntV (const RefRows& rownrs, Vector<Int>* dataPtr)
virtual void getScalarColumnCellsuIntV (const RefRows& rownrs, Vector<uInt>* dataPtr)
virtual void getScalarColumnCellsfloatV (const RefRows& rownrs, Vector<float>* dataPtr)
virtual void getScalarColumnCellsdoubleV (const RefRows& rownrs, Vector<double>* dataPtr)
virtual void getScalarColumnCellsComplexV (const RefRows& rownrs, Vector<Complex>* dataPtr)
virtual void getScalarColumnCellsDComplexV (const RefRows& rownrs, Vector<DComplex>* dataPtr)
virtual void getScalarColumnCellsStringV (const RefRows& rownrs, Vector<String>* dataPtr)
virtual void addRow (uInt newNrrow, uInt oldNrrow)
void resize (uInt nrval)
virtual void remove (uInt rownr)
virtual void doCreate (uInt nrrow)
virtual void putFile (uInt nrval, AipsIO&)
virtual void getFile (uInt nrval, AipsIO&)
virtual void reopenRW()
virtual Bool ok() const
Protected Members
uInt findExt (uInt rownr, Bool setCache)
uInt nextExt (void*& ext, uInt& extnr, uInt nrmax) const
void* allocData (uInt nrval, Bool byPtr)
void deleteAll()
void deleteData (void* datap, Bool byPtr)
void removeData (void* datap, uInt inx, uInt nrvalAfter)
virtual void putData (void* datap, uInt nrval, AipsIO&)
virtual void getData (void* datap, uInt index, uInt nrval, AipsIO&, uInt version)
void* getArrayPtr (uInt rownr)
void putArrayPtr (uInt rownr, void* dataPtr)
Private Members
StManColumnAipsIO (const StManColumnAipsIO&)
StManColumnAipsIO& operator= (const StManColumnAipsIO&)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Etymology

StManColumnAipsIO handles a column for an AipsIO storage manager.

Synopsis

StManColumnAipsIO is used by StManAipsIO to handle the access to the data in a table column. It is an storage manager based on AipsIO. The entire column is kept in memory and only written when the storage manager closes. When the storage manager gets opened, the entire column gets read back. It fully supports addition and removal of rows.

StManColumnAipsIO serves 2 purposes:

  1. It handles a column containing scalar values.
  2. It serves as a base class for StManArrayColumnAipsIO and StManIndArrayColumnAipsIO. These classes handle arrays and use StManColumnAipsIO to hold a pointer to the array in each row.

StManColumnAipsIO does not hold a column as a consecutive array, because extending the column (i.e. adding rows) proofed be too expensive due to the repeated copying involved when creating a table (this method was used by the old table system). Instead it has a number of data blocks (extensions) indexed to by a super block. Accessing a row means finding the appropriate extension via a binary search. Because there is only 1 extension when a table is read back, the overhead in finding a row is small.

Motivation

StManColumnAipsIO handles the standard data types. The class is not templated, but a switch statement is used instead. Templates would cause too many instantiations.

To Do

Member Description

StManColumnAipsIO (StManAipsIO* stMan, int dataType, Bool byPtr)

Create a column of the given type. It will maintain a pointer to its parent storage manager.

virtual ~StManColumnAipsIO()

Frees up the storage.

void getBoolV (uInt rownr, Bool* dataPtr)
void getuCharV (uInt rownr, uChar* dataPtr)
void getShortV (uInt rownr, Short* dataPtr)
void getuShortV (uInt rownr, uShort* dataPtr)
void getIntV (uInt rownr, Int* dataPtr)
void getuIntV (uInt rownr, uInt* dataPtr)
void getfloatV (uInt rownr, float* dataPtr)
void getdoubleV (uInt rownr, double* dataPtr)
void getComplexV (uInt rownr, Complex* dataPtr)
void getDComplexV (uInt rownr, DComplex* dataPtr)
void getStringV (uInt rownr, String* dataPtr)

Get a scalar value in the given row. The buffer pointed to by dataPtr has to have the correct length (which is guaranteed by the Scalar/ArrayColumn get function).

void putBoolV (uInt rownr, const Bool* dataPtr)
void putuCharV (uInt rownr, const uChar* dataPtr)
void putShortV (uInt rownr, const Short* dataPtr)
void putuShortV (uInt rownr, const uShort* dataPtr)
void putIntV (uInt rownr, const Int* dataPtr)
void putuIntV (uInt rownr, const uInt* dataPtr)
void putfloatV (uInt rownr, const float* dataPtr)
void putdoubleV (uInt rownr, const double* dataPtr)
void putComplexV (uInt rownr, const Complex* dataPtr)
void putDComplexV (uInt rownr, const DComplex* dataPtr)
void putStringV (uInt rownr, const String* dataPtr)

Put a scalar value into the given row. The buffer pointed to by dataPtr has to have the correct length (which is guaranteed by the Scalar/ArrayColumn put function).

uInt getBlockBoolV (uInt rownr, uInt nrmax, Bool* dataPtr)
uInt getBlockuCharV (uInt rownr, uInt nrmax, uChar* dataPtr)
uInt getBlockShortV (uInt rownr, uInt nrmax, Short* dataPtr)
uInt getBlockuShortV (uInt rownr, uInt nrmax, uShort* dataPtr)
uInt getBlockIntV (uInt rownr, uInt nrmax, Int* dataPtr)
uInt getBlockuIntV (uInt rownr, uInt nrmax, uInt* dataPtr)
uInt getBlockfloatV (uInt rownr, uInt nrmax, float* dataPtr)
uInt getBlockdoubleV (uInt rownr, uInt nrmax, double* dataPtr)
uInt getBlockComplexV (uInt rownr, uInt nrmax, Complex* dataPtr)
uInt getBlockDComplexV (uInt rownr, uInt nrmax, DComplex* dataPtr)
uInt getBlockStringV (uInt rownr, uInt nrmax, String* dataPtr)

Get scalars from the given row on with a maximum of nrmax values. This can be used to get an entire column of scalars or to get a part of a column (for a cache for example). The buffer pointed to by dataPtr has to have the correct length (which is guaranteed by the ScalarColumn get function).

void putBlockBoolV (uInt rownr, uInt nrmax, const Bool* dataPtr)
void putBlockuCharV (uInt rownr, uInt nrmax, const uChar* dataPtr)
void putBlockShortV (uInt rownr, uInt nrmax, const Short* dataPtr)
void putBlockuShortV (uInt rownr, uInt nrmax, const uShort* dataPtr)
void putBlockIntV (uInt rownr, uInt nrmax, const Int* dataPtr)
void putBlockuIntV (uInt rownr, uInt nrmax, const uInt* dataPtr)
void putBlockfloatV (uInt rownr, uInt nrmax, const float* dataPtr)
void putBlockdoubleV (uInt rownr, uInt nrmax, const double* dataPtr)
void putBlockComplexV (uInt rownr, uInt nrmax, const Complex* dataPtr)
void putBlockDComplexV (uInt rownr, uInt nrmax, const DComplex* dataPtr)
void putBlockStringV (uInt rownr, uInt nrmax, const String* dataPtr)

Put nrmax scalars from the given row on. This can be used to put an entire column of scalars or to put a part of a column (for a cache for example). The buffer pointed to by dataPtr has to have the correct length (which is guaranteed by the ScalarColumn put function).

virtual void getScalarColumnCellsBoolV (const RefRows& rownrs, Vector<Bool>* dataPtr)
virtual void getScalarColumnCellsuCharV (const RefRows& rownrs, Vector<uChar>* dataPtr)
virtual void getScalarColumnCellsShortV (const RefRows& rownrs, Vector<Short>* dataPtr)
virtual void getScalarColumnCellsuShortV (const RefRows& rownrs, Vector<uShort>* dataPtr)
virtual void getScalarColumnCellsIntV (const RefRows& rownrs, Vector<Int>* dataPtr)
virtual void getScalarColumnCellsuIntV (const RefRows& rownrs, Vector<uInt>* dataPtr)
virtual void getScalarColumnCellsfloatV (const RefRows& rownrs, Vector<float>* dataPtr)
virtual void getScalarColumnCellsdoubleV (const RefRows& rownrs, Vector<double>* dataPtr)
virtual void getScalarColumnCellsComplexV (const RefRows& rownrs, Vector<Complex>* dataPtr)
virtual void getScalarColumnCellsDComplexV (const RefRows& rownrs, Vector<DComplex>* dataPtr)
virtual void getScalarColumnCellsStringV (const RefRows& rownrs, Vector<String>* dataPtr)

Get the scalar values in some cells of the column. The buffer pointed to by dataPtr has to have the correct length. (which is guaranteed by the ScalarColumn getColumnCells function). The default implementation loops through all rows.

virtual void addRow (uInt newNrrow, uInt oldNrrow)

Add (newNrrow-oldNrrow) rows to the column.

void resize (uInt nrval)

Resize the data blocks. This adds an extension when needed.

virtual void remove (uInt rownr)

Remove the given row. If no rows remain in the extension, the extension is also removed.

virtual void doCreate (uInt nrrow)

Create the number of rows in a new table. This is used when a table gets created.

virtual void putFile (uInt nrval, AipsIO&)

Write the column data into AipsIO. It will successively write all extensions using putData.

virtual void getFile (uInt nrval, AipsIO&)

Read the column data from AipsIO. One extension gets allocated to hold all rows in the column.

virtual void reopenRW()

Reopen the storage manager files for read/write.

virtual Bool ok() const

Check if the class invariants still hold.

uInt findExt (uInt rownr, Bool setCache)

Find the extension in which the row number is. If the flag is true, it also sets the columnCache object.

uInt nextExt (void*& ext, uInt& extnr, uInt nrmax) const

Get the next extension. For the first iteration extnr should be zero. It returns the number of values in it until the maximum is reached. Zero means no more extensions.

void* allocData (uInt nrval, Bool byPtr)

Allocate an extension with the data type of the column.

void deleteAll()

Delete all extensions. Possible underlying data (as used by StManArrayColumnAipsIO) will not be deleted and should have been deleted beforehand.

void deleteData (void* datap, Bool byPtr)

Delete an extension.

void removeData (void* datap, uInt inx, uInt nrvalAfter)

Remove an entry (i.e. a row) from an extension at the given index. It will do this by shifting the rest (nrvalAfter elements) one position to the left.

virtual void putData (void* datap, uInt nrval, AipsIO&)

Put the data (nrval elements) in an extension (starting at datap) into AipsIO.

virtual void getData (void* datap, uInt index, uInt nrval, AipsIO&, uInt version)

Get data (nrval elements) into an extension (starting at datap plus the given index).

void* getArrayPtr (uInt rownr)

Get the pointer for the given row. This is for the derived classes like StManArrayColumnAipsIO.

void putArrayPtr (uInt rownr, void* dataPtr)

Put the pointer for the given row. This is for the derived classes like StManArrayColumnAipsIO.

StManColumnAipsIO (const StManColumnAipsIO&)

Forbid copy constructor.

StManColumnAipsIO& operator= (const StManColumnAipsIO&)

Forbid assignment.


class StManAipsIO : public DataManager

Interface

Public Members
StManAipsIO()
StManAipsIO (const String& storageManagerName)
StManAipsIO (const String& storageManagerName, const Record&)
~StManAipsIO()
DataManager* clone() const
String dataManagerType() const
String dataManagerName() const
uInt uniqueNr()
uInt nrow() const
void setHasPut()
Bool canAddRow() const
Bool canRemoveRow() const
Bool canAddColumn() const
Bool canRemoveColumn() const
static DataManager* makeObject (const String& dataManagerType, const Record& spec)
StManArrayFile* openArrayFile (ByteIO::OpenOption opt)
Private Members
StManAipsIO (const StManAipsIO&)
StManAipsIO& operator= (const StManAipsIO&)
virtual Bool flush (AipsIO&, Bool fsync)
virtual void create (uInt nrrow)
virtual void open (uInt nrrow, AipsIO&)
virtual void resync (uInt nrrow)
virtual void reopenRW()
virtual void deleteManager()
void addRow (uInt nrrow)
void removeRow (uInt rownr)
DataManagerColumn* makeScalarColumn (const String& name, int dataType, const String& dataTypeID)
DataManagerColumn* makeDirArrColumn (const String& name, int dataType, const String& dataTypeID)
DataManagerColumn* makeIndArrColumn (const String& name, int dataType, const String& dataTypeID)
void addColumn (DataManagerColumn*)
void removeColumn (DataManagerColumn*)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Etymology

StManAipsIO is the storage manager using AipsIO.

Synopsis

StManAipsIO is a table storage manager based on AipsIO. It holds the data in the columns in memory and writes them to a file when the table gets closed. Only the data of indirect arrays are directly read/written from/to a file. It contains pointers to the underlying StManColumnAipsIO objects, which do the actual data handling.

The AipsIO storage manager does fully support addition and removal of rows and columns.

All data, except indirect columns, for this storage manager are kept in one file. The file name is the table name appended with .N_AipsIO, where N is the (unique) storage manager sequence number. Each column containing indirect arrays is stored in a separate file using class StManIndArrayColumnAipsIO. The name of such a file is the storage manager file name appended with _cM, where M is a unique column sequence number acquired using function uniqueNr().

To Do

Member Description

StManAipsIO()

Create an AipsIO storage manager. Its name will be blank.

StManAipsIO (const String& storageManagerName)
StManAipsIO (const String& storageManagerName, const Record&)

Create an AipsIO storage manager with the given name. Its name can be used later in e.g. Table::addColumn to add a column to this storage manager.
Note that the 2nd constructor is needed for table creation from a record specification.

~StManAipsIO()

DataManager* clone() const

Clone this object. It does not clone StManAipsIOColumn objects possibly used.

String dataManagerType() const

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

String dataManagerName() const

Get the name given to this storage manager.

uInt uniqueNr()

Get a unique column number for the column (it is only unique for this storage manager). This is used by StManIndArrayColumnAipsIO to create a unique file name.

uInt nrow() const

Get the nr of rows in this storage manager.

void setHasPut()

Set the hasPut_p flag. In this way the StManAipsIOColumn objects can indicate that data have been put.

Bool canAddRow() const

Does the storage manager allow to add rows? (yes)

Bool canRemoveRow() const

Does the storage manager allow to delete rows? (yes)

Bool canAddColumn() const

Does the storage manager allow to add columns? (yes)

Bool canRemoveColumn() const

Does the storage manager allow to delete columns? (yes)

static DataManager* makeObject (const String& dataManagerType, const Record& spec)

Make the object from the string. This function gets registered in the DataManager "constructor" map.

StManArrayFile* openArrayFile (ByteIO::OpenOption opt)

Open (if needed) the file for indirect arrays with the given mode. Return a pointer to the object.

StManAipsIO (const StManAipsIO&)

Forbid copy constructor.

StManAipsIO& operator= (const StManAipsIO&)

Forbid assignment.

virtual Bool flush (AipsIO&, Bool fsync)

Flush and optionally fsync the data. It returns a True status if it had to flush (i.e. if data have changed).

virtual void create (uInt nrrow)

Let the storage manager create files as needed for a new table. This allows a column with an indirect array to create its file.

virtual void open (uInt nrrow, AipsIO&)

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

virtual void resync (uInt nrrow)

Resync the storage manager with the new file contents. This is done by clearing the cache.

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). So clean up the things needed (e.g. delete files).

void addRow (uInt nrrow)

Add rows to all columns.

void removeRow (uInt rownr)

Delete a row from all columns.

DataManagerColumn* makeScalarColumn (const String& name, int dataType, const String& dataTypeID)

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

Create a scalar column.

DataManagerColumn* makeDirArrColumn (const String& name, int dataType, const String& dataTypeID)

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

Create a direct array column.

DataManagerColumn* makeIndArrColumn (const String& name, int dataType, const String& dataTypeID)

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

Create an indirect array column.

void addColumn (DataManagerColumn*)

Add a column.

void removeColumn (DataManagerColumn*)

Delete a column.