ForwardColRow.h

Classes

ForwardColumnIndexedRow -- Virtual column forwarding to another row/column (full description)
ForwardColumnIndexedRowEngine -- Virtual column engine forwarding to other columns/rows. (full description)

class ForwardColumnIndexedRow : public ForwardColumn

Interface

Public Members
ForwardColumnIndexedRow (ForwardColumnIndexedRowEngine* enginePtr, const String& columnName, int dataType, const String& dataTypeId, const Table& referencedTable)
~ForwardColumnIndexedRow()
void prepare (const Table& thisTable)
Private Members
ForwardColumnIndexedRow (const ForwardColumnIndexedRow&)
ForwardColumnIndexedRow& operator= (const ForwardColumnIndexedRow&)
Bool canChangeShape() const
Bool canAccessScalarColumn (Bool& reask) const
Bool canAccessArrayColumn (Bool& reask) const
Bool canAccessColumnSlice (Bool& reask) const
void setShape (uInt rownr, const IPosition& shape)
Bool isShapeDefined (uInt rownr)
uInt ndim (uInt rownr)
IPosition shape (uInt rownr)
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 getOtherV (uInt rownr, void* 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)
void putOtherV (uInt rownr, const void* dataPtr)
void getArrayV (uInt rownr, void* dataPtr)
void putArrayV (uInt rownr, const void* dataPtr)
void getSliceV (uInt rownr, const Slicer& slicer, void* dataPtr)
void putSliceV (uInt rownr, const Slicer& slicer, const void* dataPtr)
uInt convertRownr (uInt rownr)

Description

Review Status

Reviewed By:
Paul Shannon
Date Reviewed:
1995/05/22
Programs:
Tests:

Prerequisite

Etymology

ForwardColumnIndexedRow handles the forwarding of the gets and puts for an individual row/column on behalf of the virtual column engine ForwardColumnIndexedRowEngine. It forwards them to a row/column in another table. The row forwarding is done using a special column containing row numbers indexing the referenced table.

Synopsis

ForwardColumnIndexedRow represents a virtual column which forwards the gets and puts to a column with the same name in another table. It is, in fact, a reference to the other column. The row numbers in the column are mapped to row numbers in the referenced column using a special column containing the mapping. The name of the other table is stored as a keyword in the forwarding column. When the referenced column is in its turn a ForwardColumn (note: not a ForwardColumnIndexedRow), the table mentioned in there will be used. In this way, the length of the forwarding chain is kept to a minimum.

An object of this class is created (and deleted) by the virtual column engine ForwardColumnIndexedRowEngine which creates a ForwardColumnIndexedRow object for each column being forwarded.

Member Description

ForwardColumnIndexedRow (ForwardColumnIndexedRowEngine* enginePtr, const String& columnName, int dataType, const String& dataTypeId, const Table& referencedTable)

Construct it for the given column.

~ForwardColumnIndexedRow()

Destructor is mandatory.

void prepare (const Table& thisTable)

Initialize the object. This means binding the column to the column with the same name in the original table. It checks if the description of both columns is the same.

ForwardColumnIndexedRow (const ForwardColumnIndexedRow&)

Copy constructor is not needed and therefore forbidden (so make it private).

ForwardColumnIndexedRow& operator= (const ForwardColumnIndexedRow&)

Assignment is not needed and therefore forbidden (so make it private).

Bool canChangeShape() const

This data manager cannot handle changing array shapes.

Bool canAccessScalarColumn (Bool& reask) const

This data manager cannot do get/putColumn.

Bool canAccessArrayColumn (Bool& reask) const

This data manager cannot do get/putColumn.

Bool canAccessColumnSlice (Bool& reask) const

This data manager cannot do get/putColumn.

void setShape (uInt rownr, const IPosition& shape)

Set the shape of an (indirect) array in the given row. This throws an exception, because putting is not supported.

Bool isShapeDefined (uInt rownr)

Is the value shape defined in the given row?

uInt ndim (uInt rownr)

Get the dimensionality of the item in the given row.

IPosition shape (uInt rownr)

Get the shape of the item in the given row.

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 the scalar value with a standard data type in the given row.

void getOtherV (uInt rownr, void* dataPtr)

Get the scalar value with a non-standard data type in the given row.

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 the scalar value with a standard data type into the given row. This throws an exception, because putting is not supported.

void putOtherV (uInt rownr, const void* dataPtr)

Put the scalar value with a non-standard data type into the given row. This throws an exception, because putting is not supported.

void getArrayV (uInt rownr, void* dataPtr)

Get the array value in the given row. The argument dataPtr is in fact a Array*, but a void* is needed to be generic. The array pointed to by dataPtr has to have the correct shape (which is guaranteed by the ArrayColumn get function).

void putArrayV (uInt rownr, const void* dataPtr)

Put the array value into the given row. This throws an exception, because putting is not supported.

void getSliceV (uInt rownr, const Slicer& slicer, void* dataPtr)

Get a section of the array in the given row. The argument dataPtr is in fact a Array*, but a void* is needed to be generic. The array pointed to by dataPtr has to have the correct shape (which is guaranteed by the ArrayColumn getSlice function).

void putSliceV (uInt rownr, const Slicer& slicer, const void* dataPtr)

Put into a section of the array in the given row. This throws an exception, because putting is not supported.

uInt convertRownr (uInt rownr)

Convert the rownr to the rownr in the underlying table.


class ForwardColumnIndexedRowEngine : public ForwardColumnEngine

Interface

Public Members
ForwardColumnIndexedRowEngine (const String& dataManagerName, const Record& spec)
ForwardColumnIndexedRowEngine (const Table& referencedTable, const String& rowColumnName, const String& dataManagerName)
ForwardColumnIndexedRowEngine (const Table& referencedTable, const String& rowColumnName)
~ForwardColumnIndexedRowEngine()
DataManager* clone() const
String dataManagerType() const
virtual Record dataManagerSpec() const
static void registerClass()
Private Members
ForwardColumnIndexedRowEngine (const ForwardColumnIndexedRowEngine&)
ForwardColumnIndexedRowEngine& operator= (const ForwardColumnIndexedRowEngine&)
DataManagerColumn* makeScalarColumn (const String& columnName, int dataType, const String& dataTypeId)
DataManagerColumn* makeIndArrColumn (const String& columnName, int dataType, const String& dataTypeId)
void create (uInt initialNrrow)
void prepare()
void reopenRW()
Public Members
static DataManager* makeObject (const String& dataManagerName, const Record& spec)
uInt convertRownr (uInt rownr)

Description

Prerequisite

Etymology

ForwardColumnIndexedRowEngine is a virtual column engine which forwards the gets and puts of columns to corresponding columns in another table. Furthermore it maps the row number by indexing the row number in the referenced table.

Synopsis

ForwardColumnIndexedRowEngine is a data manager which forwards the gets and puts of columns to columns with the same names in another table. In that sense it is the same as the virtual column engine ForwardColumnEngine. However, it also forwards the row number. That is, it uses a column containing row numbers to index the correct row in the referenced table. The name of this column and the name of the referenced table have to be given when constructing the engine.

For example:
Table TABA contains columns A, B and C and consists of N rows. Table TABF uses ForwardColumnIndexedRowEngine to forward its columns A, B and C to the corresponding columns in TABA. Furthermore it contains a column ROW containing row numbers in TABA. This column is the mapping of row numbers in TABF to rows in TABA. E.g. if ROW has the value 25 in row 10, row 10 of TABF is forwarded to row 25 in TABA.

Actually, puts are not possible. When multiple rows map to the same row in the referenced table, putting a value in one row would also change the value in another row referencing the same underlying row. This could result in unexpected behaviour.

The engine consists of a set of ForwardColumnIndexedRow objects, which handle the actual gets.

Motivation

In some ways it overlaps the functionality of the storage manager StManMirAIO. They both allow to have the same value used by multiple rows. However, StManMirAIO only allows that for consecutive rows, while this engine allows it for any row. On the other side, StManMirAIO is faster.

Example

    // The original table.
    Table tab("someTable");
    // Create another table with the same description.
    SetupNewTable newtab("tForwardColRow.data", tab.tableDesc(), Table::New);
    // Create an engine which forwards to the original table and uses
    // column rowColumn to get the row number in the referenced table.
    // Bind all columns in the new table to the forwarding engine.
    ForwardColumnIndexedRowEngine fce(tab, "rowColumn");
    newtab.bindAll (fce);
    // Create the new table.
    // Every get and put on this table is forwarded to the original table.
    // NB. Puts cannot be done here, because the original table was
    //     opened as readonly.
    // Of course, some columns could have been bound to another
    // data manager (storage manager, calibration engine, ...).
    Table forwTab(newtab);

Member Description

ForwardColumnIndexedRowEngine (const String& dataManagerName, const Record& spec)

The default constructor is required for reconstruction of the engine when a table is read back.

ForwardColumnIndexedRowEngine (const Table& referencedTable, const String& rowColumnName, const String& dataManagerName)

Create the engine. The columns using this engine will reference the given table. The column with the given name contains the row number mapping, i.e. a row number in a get or put is converted to a row number in the referenced table using the value in this column. The data manager gets the given name.

ForwardColumnIndexedRowEngine (const Table& referencedTable, const String& rowColumnName)

Create the engine. The columns using this engine will reference the given table. The column with the given name contains the row number mapping, i.e. a row number in a get or put is converted to a row number in the referenced table using the value in this column. The data manager has no name.

~ForwardColumnIndexedRowEngine()

Destructor is mandatory.

DataManager* clone() const

Clone the engine object.

String dataManagerType() const

Return the type name of the engine (i.e. its class name ForwardColumnIndexedRowEngine).

virtual Record dataManagerSpec() const

Record a record containing data manager specifications.

static void registerClass()

Register the class name and the static makeObject "constructor". This will make the engine known to the table system.

ForwardColumnIndexedRowEngine (const ForwardColumnIndexedRowEngine&)

The copy constructor is forbidden (so it is private).

ForwardColumnIndexedRowEngine& operator= (const ForwardColumnIndexedRowEngine&)

Assignment is forbidden (so it is private).

DataManagerColumn* makeScalarColumn (const String& columnName, int dataType, const String& dataTypeId)

Create the column object for the scalar column in this engine.

DataManagerColumn* makeIndArrColumn (const String& columnName, int dataType, const String& dataTypeId)

Create the column object for the indirect array column in this engine.

void create (uInt initialNrrow)

Initialize the object for a new table. It defines the column keywords containing the name of the original table, which can be the parent of the referenced table. It also defines a keyword containing the row column name.

void prepare()

Initialize the engine. It gets the name of the original table(s) from the column keywords, opens those tables and attaches the ForwardColumnIndexedRow objects to the columns in those tables.

void reopenRW()

Reopen the engine for read/write access. This cannot be done, so all columns remain readonly. The function is needed to override the behaviour of its base class.

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

Define the "constructor" to construct this engine when a table is read back. This "constructor" has to be registered by the user of the engine. If the engine is commonly used, its registration can be added into the registerAllCtor function in DataManReg.cc. This function gets automatically invoked by the table system.

uInt convertRownr (uInt rownr)

Convert the rownr to the rownr in the underlying table.