casa
$Rev:20696$
|
Class to view a concatenation of tables as a single table. More...
#include <ConcatTable.h>
Public Member Functions | |
ConcatTable (const Block< BaseTable * > &tables, const Block< String > &subTables, const String &subDirName) | |
Create a virtual table as the concatenation of the given tables. | |
ConcatTable (const Block< String > &tableNames, const Block< String > &subTables, const String &subDirName, int option, const TableLock &lockOptions, const TSMOption &tsmOption) | |
ConcatTable (AipsIO &, const String &name, uInt nrrow, int option, const TableLock &lockOptions, const TSMOption &tsmOption) | |
Create a concat table out of a file (written by writeConcatTable). | |
virtual | ~ConcatTable () |
The destructor flushes (i.e. | |
virtual void | getPartNames (Block< String > &names, Bool recursive) const |
Get the names of the tables this table consists of. | |
virtual void | reopenRW () |
Try to reopen the table (the underlying ones) for read/write access. | |
virtual Bool | asBigEndian () const |
Is the table stored in big or little endian format? It returns the endianness of the first underlying table. | |
virtual Bool | isMultiUsed (Bool checkSubTable) const |
Is the table in use (i.e. | |
virtual const TableLock & | lockOptions () const |
Get the locking info. | |
virtual void | mergeLock (const TableLock &lockOptions) |
Merge the given lock info with the existing one. | |
virtual Bool | hasLock (FileLocker::LockType) const |
Has this process the read or write lock, thus can the table be read or written safely? | |
virtual Bool | lock (FileLocker::LockType, uInt nattempts) |
Try to lock the table for read or write access. | |
virtual void | unlock () |
Unlock the table. | |
virtual void | flush (Bool fsync, Bool recursive) |
Flush the table, i.e. | |
virtual void | resync () |
Resync the Table object with the table files. | |
virtual uInt | getModifyCounter () const |
Get the modify counter. | |
virtual Bool | isWritable () const |
Test if all underlying tables are opened as writable. | |
void | getConcat (AipsIO &, int option, const TableLock &lockOptions, const TSMOption &tsmOption) |
Read a concat table from a file. | |
virtual void | copy (const String &newName, int tableOption) const |
This is doing a shallow copy. | |
virtual void | deepCopy (const String &newName, const Record &dataManagerInfo, int tableOption, Bool, int endianFormat, Bool noRows) const |
Copy the table and all its subtables. | |
virtual int | tableType () const |
It returns the type of the parent table. | |
virtual TableDesc | actualTableDesc () const |
Get the actual table description. | |
virtual Record | dataManagerInfo () const |
Get the data manager info (of the first underlying table). | |
virtual TableRecord & | keywordSet () |
Get readonly access to the table keyword set. | |
virtual TableRecord & | rwKeywordSet () |
Get read/write access to the table keyword set. | |
virtual BaseColumn * | getColumn (uInt columnIndex) const |
Get a column object using its index. | |
virtual BaseColumn * | getColumn (const String &columnName) const |
Get a column object using its name. | |
virtual Bool | canRemoveRow () const |
Test if it is possible to remove a row from this table (no). | |
virtual void | removeRow (uInt rownr) |
Remove the given row. | |
virtual Bool | canRemoveColumn (const Vector< String > &columnNames) const |
Test if columns can be removed (no). | |
virtual void | addColumn (const ColumnDesc &columnDesc, Bool addToParent) |
Add one or more columns to the table. | |
virtual void | addColumn (const ColumnDesc &columnDesc, const String &dataManager, Bool byName, Bool addToParent) |
virtual void | addColumn (const ColumnDesc &columnDesc, const DataManager &dataManager, Bool addToParent) |
virtual void | addColumn (const TableDesc &tableDesc, const DataManager &dataManager, Bool addToParent) |
virtual void | removeColumn (const Vector< String > &columnNames) |
Remove a column. | |
virtual Bool | canRenameColumn (const String &columnName) const |
Test if a column can be renamed (no). | |
virtual void | renameColumn (const String &newName, const String &oldName) |
Rename a column. | |
virtual void | renameHypercolumn (const String &newName, const String &oldName) |
Rename a hypercolumn. | |
virtual DataManager * | findDataManager (const String &name, Bool byColumn) const |
Find the data manager with the given name or for the given column. | |
const ConcatRows & | rows () const |
Get the rows object. | |
Block< BaseColumn * > | getRefColumns (const String &columnName) |
Get the column objects in the referenced tables. | |
Table | asTable () |
Create a (temporary) Table object from it. | |
Static Public Member Functions | |
static void | getLayout (TableDesc &desc, AipsIO &ios) |
Return the layout of a table (i.e. | |
Private Member Functions | |
ConcatTable (const ConcatTable &) | |
Copy constructor is forbidden, because copying a table requires some more knowledge (like table name of result). | |
ConcatTable & | operator= (const ConcatTable &) |
Assignment is forbidden, because copying a table requires some more knowledge (like table name of result). | |
void | showStructureExtra (std::ostream &) const |
Show the extra table structure info (names of used tables). | |
void | openTables (const Block< String > &tableNames, int option, const TableLock &lockOptions, const TSMOption &tsmOption) |
Open all tables in the required way. | |
void | initialize () |
Initialize. | |
void | setup (BaseTable *btp, const Vector< String > &columnNames) |
Setup the main parts of the object. | |
void | addInfo () |
Add lines containing the concatenated tables to the info. | |
void | makeConcatCol () |
Create the ConcatColumn objects for all columns in the description. | |
void | handleSubTables () |
Handle the subtales that have to be concatenated. | |
void | writeConcatTable (Bool fsync) |
Write a reference table. | |
void | checkAddColumn (const String &name, Bool addToParent) |
Check if the column can be added, thus does not exist yet. | |
Private Attributes | |
Block< String > | subTableNames_p |
String | subDirName_p |
Block< BaseTable * > | baseTabPtr_p |
SimpleOrderedMap< String, ConcatColumn * > | colMap_p |
TableRecord | keywordSet_p |
Bool | changed_p |
ConcatRows | rows_p |
Class to view a concatenation of tables as a single table.
Internal
ConcatTable represents the concatenation of one or more tables.
ConcatTable is used to virtually concatenate one or more tables. Those tables must have the same description.
It acts to the user as a normal table. All gets and puts are handled by ConcatColumn which directs them to the referenced columns while (if needed) converting the given row number to the row number in the referenced tables. For that purpose ConcatTable keeps the number of rows in the referenced tables.
Note: Currently it cannot handle changes in the number of rows in the underlying tables;
It is possible to specify the keyword names of the subtables that have to be concatenated as well. The other subtables are assumed to be identical for all tables, so only the subtable of the first table is used.
The ConcatTable maintains its own keyword set, which is initially a copy of the keyword set of the first table. It replaces the keywords of the subtables to be concatenated. The keyword set is not persistent. One can add or change keywords, but these changes are not kept when the ConcatTable object is made persistent.
Sometimes a very large MeasurementSet is split into multiple smaller ones using the time axis. Using ConcatTable they can still b viewed as a single MS. The SYSCAL subtable is split in time as well, thus it has to be possible to concatenate that one as well.
Note: An MS split in subband could be concatenated as well provided that at least the first part contains the full SPECTRAL_WINDOW subtable and that unique SPWids are used;
Definition at line 118 of file ConcatTable.h.
casa::ConcatTable::ConcatTable | ( | const Block< BaseTable * > & | tables, |
const Block< String > & | subTables, | ||
const String & | subDirName | ||
) |
Create a virtual table as the concatenation of the given tables.
It checks if the table descriptions of the tables are the same. Subtables with the given names will be concatenated as well. It is assumed that the other subtables are the same for all tables, so the ones of the first table are used.
The option can be Table::Old or Table::Update.
If a non-empty subdirectory name is given, the tables will be moved to that subdirectory when the concatenated table is written (by writeConcatTable).
casa::ConcatTable::ConcatTable | ( | const Block< String > & | tableNames, |
const Block< String > & | subTables, | ||
const String & | subDirName, | ||
int | option, | ||
const TableLock & | lockOptions, | ||
const TSMOption & | tsmOption | ||
) |
casa::ConcatTable::ConcatTable | ( | AipsIO & | , |
const String & | name, | ||
uInt | nrrow, | ||
int | option, | ||
const TableLock & | lockOptions, | ||
const TSMOption & | tsmOption | ||
) |
Create a concat table out of a file (written by writeConcatTable).
The referenced tables will also be opened (if not stored in the cache).
virtual casa::ConcatTable::~ConcatTable | ( | ) | [virtual] |
The destructor flushes (i.e.
writes) the table if it is opened for output and not marked for delete.
casa::ConcatTable::ConcatTable | ( | const ConcatTable & | ) | [private] |
Copy constructor is forbidden, because copying a table requires some more knowledge (like table name of result).
Declaring it private, makes it unusable.
virtual TableDesc casa::ConcatTable::actualTableDesc | ( | ) | const [virtual] |
Get the actual table description.
Implements casa::BaseTable.
virtual void casa::ConcatTable::addColumn | ( | const ColumnDesc & | columnDesc, |
Bool | addToParent | ||
) | [virtual] |
Add one or more columns to the table.
The column is added to the parent tables if told so and if not existing.
Reimplemented from casa::BaseTable.
virtual void casa::ConcatTable::addColumn | ( | const ColumnDesc & | columnDesc, |
const String & | dataManager, | ||
Bool | byName, | ||
Bool | addToParent | ||
) | [virtual] |
Reimplemented from casa::BaseTable.
virtual void casa::ConcatTable::addColumn | ( | const ColumnDesc & | columnDesc, |
const DataManager & | dataManager, | ||
Bool | addToParent | ||
) | [virtual] |
Reimplemented from casa::BaseTable.
virtual void casa::ConcatTable::addColumn | ( | const TableDesc & | tableDesc, |
const DataManager & | dataManager, | ||
Bool | addToParent | ||
) | [virtual] |
Reimplemented from casa::BaseTable.
void casa::ConcatTable::addInfo | ( | ) | [private] |
Add lines containing the concatenated tables to the info.
virtual Bool casa::ConcatTable::asBigEndian | ( | ) | const [virtual] |
Is the table stored in big or little endian format? It returns the endianness of the first underlying table.
Implements casa::BaseTable.
Table casa::ConcatTable::asTable | ( | ) | [inline] |
Create a (temporary) Table object from it.
Definition at line 301 of file ConcatTable.h.
References casa::False.
virtual Bool casa::ConcatTable::canRemoveColumn | ( | const Vector< String > & | columnNames | ) | const [virtual] |
Test if columns can be removed (no).
Implements casa::BaseTable.
virtual Bool casa::ConcatTable::canRemoveRow | ( | ) | const [virtual] |
Test if it is possible to remove a row from this table (no).
Reimplemented from casa::BaseTable.
virtual Bool casa::ConcatTable::canRenameColumn | ( | const String & | columnName | ) | const [virtual] |
Test if a column can be renamed (no).
Implements casa::BaseTable.
void casa::ConcatTable::checkAddColumn | ( | const String & | name, |
Bool | addToParent | ||
) | [private] |
Check if the column can be added, thus does not exist yet.
virtual void casa::ConcatTable::copy | ( | const String & | newName, |
int | tableOption | ||
) | const [virtual] |
This is doing a shallow copy.
It gives an error if the ConcatTable has not been stored yet.
Reimplemented from casa::BaseTable.
virtual Record casa::ConcatTable::dataManagerInfo | ( | ) | const [virtual] |
Get the data manager info (of the first underlying table).
Implements casa::BaseTable.
virtual void casa::ConcatTable::deepCopy | ( | const String & | newName, |
const Record & | dataManagerInfo, | ||
int | tableOption, | ||
Bool | , | ||
int | endianFormat, | ||
Bool | noRows | ||
) | const [virtual] |
Copy the table and all its subtables.
It copies the contents of each row to get a real copy.
Reimplemented from casa::BaseTable.
virtual DataManager* casa::ConcatTable::findDataManager | ( | const String & | name, |
Bool | byColumn | ||
) | const [virtual] |
Find the data manager with the given name or for the given column.
Implements casa::BaseTable.
virtual void casa::ConcatTable::flush | ( | Bool | fsync, |
Bool | recursive | ||
) | [virtual] |
Flush the table, i.e.
write it to disk. Nothing will be done if the table is not writable. A flush can be executed at any time. When a table is marked for delete, the destructor will remove files written by intermediate flushes. Note that if necessary the destructor will do an implicit flush, unless it is executed due to an exception.
Implements casa::BaseTable.
virtual BaseColumn* casa::ConcatTable::getColumn | ( | uInt | columnIndex | ) | const [virtual] |
Get a column object using its index.
Implements casa::BaseTable.
virtual BaseColumn* casa::ConcatTable::getColumn | ( | const String & | columnName | ) | const [virtual] |
Get a column object using its name.
Implements casa::BaseTable.
void casa::ConcatTable::getConcat | ( | AipsIO & | , |
int | option, | ||
const TableLock & | lockOptions, | ||
const TSMOption & | tsmOption | ||
) |
Read a concat table from a file.
The underlying tables will be opened (if not stored in the cache).
static void casa::ConcatTable::getLayout | ( | TableDesc & | desc, |
AipsIO & | ios | ||
) | [static] |
Return the layout of a table (i.e.
description and #rows). This function has the advantage that only the minimal amount of information required is read from the table, thus it is much faster than a normal table open.
The number of rows is returned. The description of the table is stored in desc (its contents will be overwritten).
virtual uInt casa::ConcatTable::getModifyCounter | ( | ) | const [virtual] |
Get the modify counter.
Implements casa::BaseTable.
virtual void casa::ConcatTable::getPartNames | ( | Block< String > & | names, |
Bool | recursive | ||
) | const [virtual] |
Get the names of the tables this table consists of.
Reimplemented from casa::BaseTable.
Block<BaseColumn*> casa::ConcatTable::getRefColumns | ( | const String & | columnName | ) |
Get the column objects in the referenced tables.
void casa::ConcatTable::handleSubTables | ( | ) | [private] |
Handle the subtales that have to be concatenated.
virtual Bool casa::ConcatTable::hasLock | ( | FileLocker::LockType | ) | const [virtual] |
Has this process the read or write lock, thus can the table be read or written safely?
Implements casa::BaseTable.
void casa::ConcatTable::initialize | ( | ) | [private] |
Initialize.
It checks if the descriptions of all tables are equal. It creates the keyword setfor which it concatenates subtables as needed.
virtual Bool casa::ConcatTable::isMultiUsed | ( | Bool | checkSubTable | ) | const [virtual] |
Is the table in use (i.e.
open) in another process? It always returns False.
Implements casa::BaseTable.
virtual Bool casa::ConcatTable::isWritable | ( | ) | const [virtual] |
Test if all underlying tables are opened as writable.
Implements casa::BaseTable.
virtual TableRecord& casa::ConcatTable::keywordSet | ( | ) | [virtual] |
Get readonly access to the table keyword set.
Implements casa::BaseTable.
virtual Bool casa::ConcatTable::lock | ( | FileLocker::LockType | , |
uInt | nattempts | ||
) | [virtual] |
Try to lock the table for read or write access.
Implements casa::BaseTable.
virtual const TableLock& casa::ConcatTable::lockOptions | ( | ) | const [virtual] |
void casa::ConcatTable::makeConcatCol | ( | ) | [private] |
Create the ConcatColumn objects for all columns in the description.
virtual void casa::ConcatTable::mergeLock | ( | const TableLock & | lockOptions | ) | [virtual] |
Merge the given lock info with the existing one.
Implements casa::BaseTable.
void casa::ConcatTable::openTables | ( | const Block< String > & | tableNames, |
int | option, | ||
const TableLock & | lockOptions, | ||
const TSMOption & | tsmOption | ||
) | [private] |
Open all tables in the required way.
ConcatTable& casa::ConcatTable::operator= | ( | const ConcatTable & | ) | [private] |
Assignment is forbidden, because copying a table requires some more knowledge (like table name of result).
Declaring it private, makes it unusable.
virtual void casa::ConcatTable::removeColumn | ( | const Vector< String > & | columnNames | ) | [virtual] |
Remove a column.
Implements casa::BaseTable.
virtual void casa::ConcatTable::removeRow | ( | uInt | rownr | ) | [virtual] |
Remove the given row.
Reimplemented from casa::BaseTable.
virtual void casa::ConcatTable::renameColumn | ( | const String & | newName, |
const String & | oldName | ||
) | [virtual] |
Rename a column.
Implements casa::BaseTable.
virtual void casa::ConcatTable::renameHypercolumn | ( | const String & | newName, |
const String & | oldName | ||
) | [virtual] |
Rename a hypercolumn.
Implements casa::BaseTable.
virtual void casa::ConcatTable::reopenRW | ( | ) | [virtual] |
Try to reopen the table (the underlying ones) for read/write access.
An exception is thrown if the table is not writable. Nothing is done if the table is already open for read/write.
Implements casa::BaseTable.
virtual void casa::ConcatTable::resync | ( | ) | [virtual] |
Resync the Table object with the table files.
Implements casa::BaseTable.
const ConcatRows& casa::ConcatTable::rows | ( | ) | const [inline] |
virtual TableRecord& casa::ConcatTable::rwKeywordSet | ( | ) | [virtual] |
Get read/write access to the table keyword set.
This requires that the table is locked (or it gets locked when using AutoLocking mode).
Implements casa::BaseTable.
void casa::ConcatTable::setup | ( | BaseTable * | btp, |
const Vector< String > & | columnNames | ||
) | [private] |
Setup the main parts of the object.
First create the name map (mapping column name in ConcatTable to the column in the original table). If the BaseTable is a ConcatTable, use its name map. Otherwise create the initial name map from the table description. A rename might change the map.
Create the ConcatColumn objects.
Create the initial TableInfo as a copy of the original BaseTable.
void casa::ConcatTable::showStructureExtra | ( | std::ostream & | ) | const [private, virtual] |
Show the extra table structure info (names of used tables).
Reimplemented from casa::BaseTable.
virtual int casa::ConcatTable::tableType | ( | ) | const [virtual] |
It returns the type of the parent table.
Reimplemented from casa::BaseTable.
virtual void casa::ConcatTable::unlock | ( | ) | [virtual] |
Unlock the table.
This will also synchronize the table data, thus force the data to be written to disk.
Implements casa::BaseTable.
void casa::ConcatTable::writeConcatTable | ( | Bool | fsync | ) | [private] |
Write a reference table.
Block<BaseTable*> casa::ConcatTable::baseTabPtr_p [private] |
Definition at line 355 of file ConcatTable.h.
Bool casa::ConcatTable::changed_p [private] |
Definition at line 358 of file ConcatTable.h.
Definition at line 356 of file ConcatTable.h.
TableRecord casa::ConcatTable::keywordSet_p [private] |
Definition at line 357 of file ConcatTable.h.
ConcatRows casa::ConcatTable::rows_p [private] |
Definition at line 359 of file ConcatTable.h.
Referenced by rows().
String casa::ConcatTable::subDirName_p [private] |
Definition at line 354 of file ConcatTable.h.
Block<String> casa::ConcatTable::subTableNames_p [private] |
Definition at line 353 of file ConcatTable.h.