casa
$Rev:20696$
|
Templated virtual column engine to scale a complex table array. More...
#include <ScaledComplexData.h>
Public Member Functions | |
ScaledComplexData (const String &virtualColumnName, const String &storedColumnName, VirtualType scale, VirtualType offset=0) | |
Construct an engine to scale all arrays in a column with the given offset and scale factor. | |
ScaledComplexData (const String &virtualColumnName, const String &storedColumnName, const String &scaleColumnName, VirtualType offset=0) | |
Construct an engine to scale the arrays in a column. | |
ScaledComplexData (const String &virtualColumnName, const String &storedColumnName, const String &scaleColumnName, const String &offsetColumnName) | |
ScaledComplexData (const Record &spec) | |
Construct from a record specification as created by getmanagerSpec(). | |
~ScaledComplexData () | |
Destructor is mandatory. | |
String | dataManagerType () const |
Return the type name of the engine (i.e. | |
virtual Record | dataManagerSpec () const |
Record a record containing data manager specifications. | |
virtual Bool | canAccessArrayColumnCells (Bool &reask) const |
The engine can access column cells. | |
Static Public Member Functions | |
static String | className () |
Return the name of the class. | |
static void | registerClass () |
Register the class name and the static makeObject "constructor". | |
static DataManager * | makeObject (const String &dataManagerType, const Record &spec) |
Define the "constructor" to construct this engine when a table is read back. | |
Private Member Functions | |
ScaledComplexData () | |
The default constructor is required for reconstruction of the engine when a table is read back. | |
ScaledComplexData (const ScaledComplexData< VirtualType, StoredType > &) | |
Copy constructor is only used by clone(). | |
ScaledComplexData< VirtualType, StoredType > & | operator= (const ScaledComplexData< VirtualType, StoredType > &) |
Assignment is not needed and therefore forbidden (so it is made private and not implemented). | |
virtual DataManager * | clone () const |
Clone the engine object. | |
virtual void | create (uInt initialNrrow) |
Initialize the object for a new table. | |
virtual void | prepare () |
Preparing consists of setting the writable switch and adding the initial number of rows in case of create. | |
virtual void | setShapeColumn (const IPosition &shape) |
Set the shape of the FixedShape arrays in the column. | |
virtual void | setShape (uInt rownr, const IPosition &shape) |
Define the shape of the array in the given row. | |
virtual uInt | ndim (uInt rownr) |
Get the dimensionality of the array in the given row. | |
virtual IPosition | shape (uInt rownr) |
Get the shape of the array in the given row. | |
virtual void | getArray (uInt rownr, Array< VirtualType > &array) |
Get an array in the given row. | |
virtual void | putArray (uInt rownr, const Array< VirtualType > &array) |
Put an array in the given row. | |
virtual void | getSlice (uInt rownr, const Slicer &slicer, Array< VirtualType > &array) |
Get a section of the array in the given row. | |
virtual void | putSlice (uInt rownr, const Slicer &slicer, const Array< VirtualType > &array) |
Put into a section of the array in the given row. | |
virtual void | getArrayColumn (Array< VirtualType > &array) |
Get an entire column. | |
virtual void | putArrayColumn (const Array< VirtualType > &array) |
Put an entire column. | |
virtual void | getArrayColumnCells (const RefRows &rownrs, Array< VirtualType > &data) |
Get some array values in the column. | |
virtual void | putArrayColumnCells (const RefRows &rownrs, const Array< VirtualType > &data) |
Put some array values in the column. | |
virtual void | getColumnSlice (const Slicer &slicer, Array< VirtualType > &array) |
Get a section of all arrays in the column. | |
virtual void | putColumnSlice (const Slicer &slicer, const Array< VirtualType > &array) |
Put a section of all arrays in the column. | |
virtual void | getColumnSliceCells (const RefRows &rownrs, const Slicer &slicer, Array< VirtualType > &data) |
Get a section of some arrays in the column. | |
virtual void | putColumnSliceCells (const RefRows &rownrs, const Slicer &slicer, const Array< VirtualType > &data) |
Put into a section of some arrays in the column. | |
void | scaleOnGet (VirtualType scale, VirtualType offset, Array< VirtualType > &array, const Array< StoredType > &stored) |
Scale and/or offset stored to array. | |
void | scaleOnPut (VirtualType scale, VirtualType offset, const Array< VirtualType > &array, Array< StoredType > &stored) |
Scale and/or offset array to stored. | |
void | scaleColumnOnGet (Array< VirtualType > &array, const Array< StoredType > &stored) |
Scale and/or offset stored to array for the entire column. | |
void | scaleColumnOnPut (const Array< VirtualType > &array, Array< StoredType > &stored) |
Scale and/or offset array to stored for the entire column. | |
void | scaleCellsOnGet (Array< VirtualType > &array, const Array< StoredType > &stored, const RefRows &rownrs) |
Scale and/or offset stored to array for some cells in the column. | |
void | scaleCellsOnPut (const Array< VirtualType > &array, Array< StoredType > &stored, const RefRows &rownrs) |
Scale and/or offset array to stored for some cells in the column. | |
IPosition | storedShape (const IPosition &virtualShape) const |
Determine the shape of an array in the stored column. | |
Slicer | storedSlicer (const Slicer &virtualSlicer) const |
Convert the Slicer for a virtual to a Slicer for the stored. | |
VirtualType | getScale (uInt rownr) |
Get the scale value for this row. | |
VirtualType | getOffset (uInt rownr) |
Get the offset value for this row. | |
Private Attributes | |
String | scaleName_p |
String | offsetName_p |
VirtualType | scale_p |
VirtualType | offset_p |
Bool | fixedScale_p |
Bool | fixedOffset_p |
ScalarColumn< VirtualType > * | scaleColumn_p |
ScalarColumn< VirtualType > * | offsetColumn_p |
Templated virtual column engine to scale a complex table array.
Public interface
ScaledComplexData is a virtual column engine which scales an array of a complex type to 2 values of another type (to save disk storage). For example, ScaledComplexData<Complex,Short>
resembles the classic AIPS compress method which scales the data from float to short. The (complex) scale factor and offset value can be given in two ways:
It is also possible to have a variable scale factor with a fixed offset value. As in FITS the scale and offset values are used as:
True_value = Stored_value * scale + offset;
An engine object should be used for one column only, because the stored column name is part of the engine. If it would be used for more than one column, they would all share the same stored column. When the engine is bound to a column, it is checked if the name of that column matches the given virtual column name.
The engine can be used for a column containing any kind of array (thus direct or indirect, fixed or variable shaped)) as long as the virtual array can be stored in the stored array. Thus a fixed shaped virtual can use a variable shaped stored, but not vice versa. A fixed shape indirect virtual can use a stored with direct arrays.
This class can also serve as an example of how to implement a virtual column engine.
This class allows to store data in a smaller representation. It is needed to resemble the classic AIPS compress option. It adds the scale and offset value on a per row basis.
Because the engine can serve only one column, it was possible to combine the engine and the column functionality in one class. This has been achieved using multiple inheritance. The advantage of this is that only one templated class is used, so less template instantiations are needed.
Class ScaledArrayEngine could not be used, because complex integer types are not supported in the tabe system.
// Create the table description and 2 columns with indirect arrays in it. // The Int column will be stored, while the double will be // used as virtual. TableDesc tableDesc ("", TableDesc::Scratch); tableDesc.addColumn (ArrayColumnDesc<Short> ("storedArray")); tableDesc.addColumn (ArrayColumnDesc<Complex> ("virtualArray")); // Create a new table using the table description. SetupNewTable newtab (tableDesc, "tab.data", Table::New); // Create the array scaling engine to scale from double to Int // and bind it to the double column. // Create the table. ScaledComplexData<Complex,Short> scalingEngine("virtualArray", "storedArray", 10); newtab.bindColumn ("virtualArray", scalingEngine); Table table (newtab); // Store a 2-D array (with dim. 3,4) into each row of the column. // The shape of each array in the column is implicitly set by the put // function. This will also set the shape of the underlying Int array // (as a 3-D array with shape 2,3,4). ArrayColumn data (table, "virtualArray"); Array<DComplex> someArray(IPosition(2,3,4)); someArray = 0; for (uInt i=0, i<10; i++) { // table will have 10 rows table.addRow(); data.put (i, someArray) }
Definition at line 147 of file ScaledComplexData.h.
casa::ScaledComplexData< VirtualType, StoredType >::ScaledComplexData | ( | const String & | virtualColumnName, |
const String & | storedColumnName, | ||
VirtualType | scale, | ||
VirtualType | offset = 0 |
||
) |
Construct an engine to scale all arrays in a column with the given offset and scale factor.
StoredColumnName is the name of the column where the scaled data will be put and must have data type StoredType. The virtual column using this engine must have data type VirtualType.
casa::ScaledComplexData< VirtualType, StoredType >::ScaledComplexData | ( | const String & | virtualColumnName, |
const String & | storedColumnName, | ||
const String & | scaleColumnName, | ||
VirtualType | offset = 0 |
||
) |
Construct an engine to scale the arrays in a column.
The scale and offset values are taken from a column with the given names. In that way each array has its own scale factor and offset value. An exception is thrown if these columns do not exist. VirtualColumnName is the name of the virtual column and is used to check if the engine gets bound to the correct column. StoredColumnName is the name of the column where the scaled data will be put and must have data type StoredType. The virtual column using this engine must have data type VirtualType.
casa::ScaledComplexData< VirtualType, StoredType >::ScaledComplexData | ( | const String & | virtualColumnName, |
const String & | storedColumnName, | ||
const String & | scaleColumnName, | ||
const String & | offsetColumnName | ||
) |
casa::ScaledComplexData< VirtualType, StoredType >::ScaledComplexData | ( | const Record & | spec | ) |
Construct from a record specification as created by getmanagerSpec().
casa::ScaledComplexData< VirtualType, StoredType >::~ScaledComplexData | ( | ) |
Destructor is mandatory.
casa::ScaledComplexData< VirtualType, StoredType >::ScaledComplexData | ( | ) | [private] |
The default constructor is required for reconstruction of the engine when a table is read back.
casa::ScaledComplexData< VirtualType, StoredType >::ScaledComplexData | ( | const ScaledComplexData< VirtualType, StoredType > & | ) | [private] |
Copy constructor is only used by clone().
(so it is made private).
virtual Bool casa::ScaledComplexData< VirtualType, StoredType >::canAccessArrayColumnCells | ( | Bool & | reask | ) | const [virtual] |
The engine can access column cells.
Reimplemented from casa::DataManagerColumn.
static String casa::ScaledComplexData< VirtualType, StoredType >::className | ( | ) | [static] |
Return the name of the class.
This includes the names of the template arguments.
virtual DataManager* casa::ScaledComplexData< VirtualType, StoredType >::clone | ( | ) | const [private, virtual] |
Clone the engine object.
Implements casa::DataManager.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::create | ( | uInt | initialNrrow | ) | [private, virtual] |
Initialize the object for a new table.
It defines the keywords containing the engine parameters.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual Record casa::ScaledComplexData< VirtualType, StoredType >::dataManagerSpec | ( | ) | const [virtual] |
Record a record containing data manager specifications.
Reimplemented from casa::DataManager.
String casa::ScaledComplexData< VirtualType, StoredType >::dataManagerType | ( | ) | const [virtual] |
virtual void casa::ScaledComplexData< VirtualType, StoredType >::getArray | ( | uInt | rownr, |
Array< VirtualType > & | array | ||
) | [private, virtual] |
Get an array in the given row.
This will scale and offset from the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::getArrayColumn | ( | Array< VirtualType > & | array | ) | [private, virtual] |
Get an entire column.
This will scale and offset from the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::getArrayColumnCells | ( | const RefRows & | rownrs, |
Array< VirtualType > & | data | ||
) | [private, virtual] |
Get some array values in the column.
This will scale and offset from the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::getColumnSlice | ( | const Slicer & | slicer, |
Array< VirtualType > & | array | ||
) | [private, virtual] |
Get a section of all arrays in the column.
This will scale and offset from the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::getColumnSliceCells | ( | const RefRows & | rownrs, |
const Slicer & | slicer, | ||
Array< VirtualType > & | data | ||
) | [private, virtual] |
Get a section of some arrays in the column.
This will scale and offset from the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
VirtualType casa::ScaledComplexData< VirtualType, StoredType >::getOffset | ( | uInt | rownr | ) | [private] |
Get the offset value for this row.
VirtualType casa::ScaledComplexData< VirtualType, StoredType >::getScale | ( | uInt | rownr | ) | [private] |
Get the scale value for this row.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::getSlice | ( | uInt | rownr, |
const Slicer & | slicer, | ||
Array< VirtualType > & | array | ||
) | [private, virtual] |
Get a section of the array in the given row.
This will scale and offset from the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
static DataManager* casa::ScaledComplexData< VirtualType, StoredType >::makeObject | ( | const String & | dataManagerType, |
const Record & | spec | ||
) | [static] |
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 to the registerAllCtor function in DataManReg.cc. That function gets automatically invoked by the table system.
virtual uInt casa::ScaledComplexData< VirtualType, StoredType >::ndim | ( | uInt | rownr | ) | [private, virtual] |
Get the dimensionality of the array in the given row.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
ScaledComplexData<VirtualType,StoredType>& casa::ScaledComplexData< VirtualType, StoredType >::operator= | ( | const ScaledComplexData< VirtualType, StoredType > & | ) | [private] |
Assignment is not needed and therefore forbidden (so it is made private and not implemented).
virtual void casa::ScaledComplexData< VirtualType, StoredType >::prepare | ( | ) | [private, virtual] |
Preparing consists of setting the writable switch and adding the initial number of rows in case of create.
Furthermore it reads the keywords containing the engine parameters.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::putArray | ( | uInt | rownr, |
const Array< VirtualType > & | array | ||
) | [private, virtual] |
Put an array in the given row.
This will scale and offset to the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::putArrayColumn | ( | const Array< VirtualType > & | array | ) | [private, virtual] |
Put an entire column.
This will scale and offset to the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::putArrayColumnCells | ( | const RefRows & | rownrs, |
const Array< VirtualType > & | data | ||
) | [private, virtual] |
Put some array values in the column.
This will scale and offset to the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::putColumnSlice | ( | const Slicer & | slicer, |
const Array< VirtualType > & | array | ||
) | [private, virtual] |
Put a section of all arrays in the column.
This will scale and offset to the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::putColumnSliceCells | ( | const RefRows & | rownrs, |
const Slicer & | slicer, | ||
const Array< VirtualType > & | data | ||
) | [private, virtual] |
Put into a section of some arrays in the column.
This will scale and offset to the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::putSlice | ( | uInt | rownr, |
const Slicer & | slicer, | ||
const Array< VirtualType > & | array | ||
) | [private, virtual] |
Put into a section of the array in the given row.
This will scale and offset to the underlying array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
static void casa::ScaledComplexData< VirtualType, StoredType >::registerClass | ( | ) | [static] |
Register the class name and the static makeObject "constructor".
This will make the engine known to the table system. The automatically invoked registration function in DataManReg.cc contains ScaledComplexData<double,Int>. Any other instantiation of this class must be registered "manually" (or added to DataManReg.cc).
void casa::ScaledComplexData< VirtualType, StoredType >::scaleCellsOnGet | ( | Array< VirtualType > & | array, |
const Array< StoredType > & | stored, | ||
const RefRows & | rownrs | ||
) | [private] |
Scale and/or offset stored to array for some cells in the column.
When the scale and offset are fixed, it will do the entire array. Otherwise it iterates through the array and applies the scale and offset per row.
void casa::ScaledComplexData< VirtualType, StoredType >::scaleCellsOnPut | ( | const Array< VirtualType > & | array, |
Array< StoredType > & | stored, | ||
const RefRows & | rownrs | ||
) | [private] |
Scale and/or offset array to stored for some cells in the column.
When the scale and offset are fixed, it will do the entire array. Otherwise it iterates through the array and applies the scale and offset per row.
void casa::ScaledComplexData< VirtualType, StoredType >::scaleColumnOnGet | ( | Array< VirtualType > & | array, |
const Array< StoredType > & | stored | ||
) | [private] |
Scale and/or offset stored to array for the entire column.
When the scale and offset are fixed, it will do the entire array. Otherwise it iterates through the array and applies the scale and offset per row.
void casa::ScaledComplexData< VirtualType, StoredType >::scaleColumnOnPut | ( | const Array< VirtualType > & | array, |
Array< StoredType > & | stored | ||
) | [private] |
Scale and/or offset array to stored for the entire column.
When the scale and offset are fixed, it will do the entire array. Otherwise it iterates through the array and applies the scale and offset per row.
void casa::ScaledComplexData< VirtualType, StoredType >::scaleOnGet | ( | VirtualType | scale, |
VirtualType | offset, | ||
Array< VirtualType > & | array, | ||
const Array< StoredType > & | stored | ||
) | [private] |
Scale and/or offset stored to array.
This is meant when reading an array from the stored column. It optimizes for scale=1 and/or offset=0.
void casa::ScaledComplexData< VirtualType, StoredType >::scaleOnPut | ( | VirtualType | scale, |
VirtualType | offset, | ||
const Array< VirtualType > & | array, | ||
Array< StoredType > & | stored | ||
) | [private] |
Scale and/or offset array to stored.
This is meant when writing an array into the stored column. It optimizes for scale=1 and/or offset=0.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::setShape | ( | uInt | rownr, |
const IPosition & | shape | ||
) | [private, virtual] |
Define the shape of the array in the given row.
When the shape of the (underlying) stored array has already been defined, it checks whether its latter dimensions match the given virtual shape. When matching, nothing will be done. When mismatching or when the stored shape has not been defined yet, the stored shape will be defined from the virtual shape and the virtual element shape. E.g. in case of a StokesVector a virtual shape of (512,512) results in a stored shape of (4,512,512).
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual void casa::ScaledComplexData< VirtualType, StoredType >::setShapeColumn | ( | const IPosition & | shape | ) | [private, virtual] |
Set the shape of the FixedShape arrays in the column.
This function only gets called if the column has FixedShape arrays. The shape gets saved and used to set the shape of the arrays in the stored in case the stored has non-FixedShape arrays.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
virtual IPosition casa::ScaledComplexData< VirtualType, StoredType >::shape | ( | uInt | rownr | ) | [private, virtual] |
Get the shape of the array in the given row.
This is done by stripping the first dimension from the shape of the underlying stored array.
Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.
IPosition casa::ScaledComplexData< VirtualType, StoredType >::storedShape | ( | const IPosition & | virtualShape | ) | const [inline, private] |
Determine the shape of an array in the stored column.
Definition at line 372 of file ScaledComplexData.h.
References casa::IPosition::concatenate().
Slicer casa::ScaledComplexData< VirtualType, StoredType >::storedSlicer | ( | const Slicer & | virtualSlicer | ) | const [private] |
Bool casa::ScaledComplexData< VirtualType, StoredType >::fixedOffset_p [private] |
Definition at line 384 of file ScaledComplexData.h.
Bool casa::ScaledComplexData< VirtualType, StoredType >::fixedScale_p [private] |
Definition at line 383 of file ScaledComplexData.h.
VirtualType casa::ScaledComplexData< VirtualType, StoredType >::offset_p [private] |
Definition at line 382 of file ScaledComplexData.h.
ScalarColumn<VirtualType>* casa::ScaledComplexData< VirtualType, StoredType >::offsetColumn_p [private] |
Definition at line 386 of file ScaledComplexData.h.
String casa::ScaledComplexData< VirtualType, StoredType >::offsetName_p [private] |
Definition at line 380 of file ScaledComplexData.h.
VirtualType casa::ScaledComplexData< VirtualType, StoredType >::scale_p [private] |
Definition at line 381 of file ScaledComplexData.h.
ScalarColumn<VirtualType>* casa::ScaledComplexData< VirtualType, StoredType >::scaleColumn_p [private] |
Definition at line 385 of file ScaledComplexData.h.
String casa::ScaledComplexData< VirtualType, StoredType >::scaleName_p [private] |
Definition at line 379 of file ScaledComplexData.h.