casa
5.7.0-16
|
Class to manage a set of table columns. More...
#include <ColumnSet.h>
Public Member Functions | |
ColumnSet (TableDesc *, const StorageOption &=StorageOption()) | |
Construct from the table description. More... | |
~ColumnSet () | |
void | reopenRW () |
Reopen the data managers for read/write. More... | |
void | renameTables (const String &newName, const String &oldName) |
Rename the necessary subtables in the column keywords. More... | |
const StorageOption & | storageOption () const |
Get the storage option. More... | |
Bool | areTablesMultiUsed () const |
Are subtables used in other processes. More... | |
PlainColumn * | getColumn (const String &columnName) const |
Get a column by name. More... | |
PlainColumn * | getColumn (uInt columnIndex) const |
Get a column by index. More... | |
void | addDataManager (DataManager *) |
Add a data manager. More... | |
void | initDataManagers (uInt nrrow, Bool bigEndian, const TSMOption &tsmOption, Table &tab) |
Initialize the data managers for a new table. More... | |
void | linkToTable (BaseTable *baseTableObject) |
Link the ColumnSet object to the BaseTable object. More... | |
void | linkToLockObject (TableLockData *lockObject) |
Link the ColumnSet object to the TableLockData object. More... | |
void | checkReadLock (Bool wait) |
Check if the table is locked for read or write. More... | |
void | checkWriteLock (Bool wait) |
void | autoReleaseLock () |
Inspect the auto lock when the inspection interval has expired and release it when another process needs the lock. More... | |
Bool | userLock (FileLocker::LockType, Bool wait) |
If needed, get a temporary user lock. More... | |
void | userUnlock (Bool releaseFlag) |
Release a temporary user lock if the given release flag is True. More... | |
Bool | canAddRow () const |
Do all data managers and engines allow to add rows? More... | |
Bool | canRemoveRow () const |
Do all data managers and engines allow to remove rows? More... | |
Bool | canRemoveColumn (const Vector< String > &columnNames) const |
Can the given columns be removed from the data manager? More... | |
Bool | canRenameColumn (const String &columnName) const |
Can a column be renamed in the data manager? More... | |
void | addRow (uInt nrrow) |
Add rows to all data managers. More... | |
void | removeRow (uInt rownr) |
Remove a row from all data managers. More... | |
void | removeColumn (const Vector< String > &columnNames) |
Remove the columns from the map and the data manager. More... | |
void | renameColumn (const String &newName, const String &oldName) |
Rename the column in the map. More... | |
void | addColumn (const ColumnDesc &columnDesc, Bool bigEndian, const TSMOption &tsmOption, Table &tab) |
Add a column to the table. More... | |
void | addColumn (const ColumnDesc &columnDesc, const String &dataManager, Bool byName, Bool bigEndian, const TSMOption &tsmOption, Table &tab) |
void | addColumn (const ColumnDesc &columnDesc, const DataManager &dataManager, Bool bigEndian, const TSMOption &tsmOption, Table &tab) |
void | addColumn (const TableDesc &tableDesc, const DataManager &dataManager, Bool bigEndian, const TSMOption &tsmOption, Table &tab) |
uInt | nrow () const |
Get nr of rows. More... | |
TableDesc | actualTableDesc () const |
Get the actual table description. More... | |
Record | dataManagerInfo (Bool virtualOnly=False) const |
Get the data manager info. More... | |
int | traceId () const |
Get the trace-id of the table. More... | |
void | initialize (uInt startRownr, uInt endRownr) |
Initialize rows startRownr till endRownr (inclusive). More... | |
Bool | putFile (Bool writeTable, AipsIO &, const TableAttr &, Bool fsync) |
Write all the data and let the data managers flush their data. More... | |
uInt | getFile (AipsIO &, Table &tab, uInt nrrow, Bool bigEndian, const TSMOption &tsmOption) |
Read the data, reconstruct the data managers, and link those to the table object. More... | |
void | setTableChanged () |
Set the table to being changed. More... | |
Block< Bool > & | dataManChanged () |
Get the data manager change flags (used by PlainTable). More... | |
uInt | resync (uInt nrrow, Bool forceSync) |
Synchronize the data managers when data in them have changed. More... | |
void | invalidateColumnCaches () |
Invalidate the column caches for all columns. More... | |
DataManager * | getDataManager (uInt seqnr) const |
Get the correct data manager. More... | |
void | checkDataManagerNames (const String &tableName) const |
Check if no double data manager names have been given. More... | |
DataManager * | findDataManager (const String &name, Bool byColumn=False) const |
Find the data manager with the given name or for the given column. More... | |
String | uniqueDataManagerName (const String &name) const |
Make a unique data manager name by appending a suffix _n if needed where n is a number that makes the name unique. More... | |
void | syncColumns (const ColumnSet &other, const TableAttr &defaultAttr) |
Synchronize the columns after it appeared that data in the main table file have changed. More... | |
Private Member Functions | |
void | removeLastDataManager () |
Remove the last data manager (used by addColumn after an exception). More... | |
void | initSomeDataManagers (uInt from, Table &tab) |
Let the data managers (from the given index on) initialize themselves. More... | |
void | prepareSomeDataManagers (uInt from) |
Let the data managers (from the given index on) prepare themselves. More... | |
void | openMultiFile (uInt from, const Table &tab, ByteIO::OpenOption) |
Open or create the MultiFile if needed. More... | |
Bool | checkDataManagerName (const String &name, uInt from, const String &tableName, Bool doTthrow=True) const |
Check if a data manager name has not already been used. More... | |
void | doAddColumn (const ColumnDesc &columnDesc, DataManager *dataManPtr) |
Do the actual addition of a column. More... | |
std::map< void *, Int > | checkRemoveColumn (const Vector< String > &columnNames) |
Check if columns to be removed can be removed. More... | |
void | doLock (FileLocker::LockType, Bool wait) |
Check if the table is locked for read or write. More... | |
Private Attributes | |
TableDesc * | tdescPtr_p |
StorageOption | storageOpt_p |
MultiFileBase * | multiFile_p |
Int64 | nrrow_p |
BaseTable * | baseTablePtr_p |
TableLockData * | lockPtr_p |
std::map< String, void * > | colMap_p |
uInt | seqCount_p |
Block< void * > | blockDataMan_p |
Block< Bool > | dataManChanged_p |
Class to manage a set of table columns.
Internal
ColumnSet represent the set of columns in a table.
ColumnSet contains all columns in a plain table (thus not in a RefTable). Furthermore it contains the set of data managers used by the columns in the table.
The main purpose of the class is to deal with constructing, writing and reading the column objects. It is used by classes SetupNewTable and Table.
Definition at line 93 of file ColumnSet.h.
casacore::ColumnSet::ColumnSet | ( | TableDesc * | , |
const StorageOption & | = StorageOption() |
||
) |
Construct from the table description.
This creates all underlying filled and virtual column objects.
casacore::ColumnSet::~ColumnSet | ( | ) |
TableDesc casacore::ColumnSet::actualTableDesc | ( | ) | const |
Get the actual table description.
void casacore::ColumnSet::addColumn | ( | const ColumnDesc & | columnDesc, |
Bool | bigEndian, | ||
const TSMOption & | tsmOption, | ||
Table & | tab | ||
) |
Add a column to the table.
The default implementation throws an "invalid operation" exception.
void casacore::ColumnSet::addColumn | ( | const ColumnDesc & | columnDesc, |
const String & | dataManager, | ||
Bool | byName, | ||
Bool | bigEndian, | ||
const TSMOption & | tsmOption, | ||
Table & | tab | ||
) |
void casacore::ColumnSet::addColumn | ( | const ColumnDesc & | columnDesc, |
const DataManager & | dataManager, | ||
Bool | bigEndian, | ||
const TSMOption & | tsmOption, | ||
Table & | tab | ||
) |
void casacore::ColumnSet::addColumn | ( | const TableDesc & | tableDesc, |
const DataManager & | dataManager, | ||
Bool | bigEndian, | ||
const TSMOption & | tsmOption, | ||
Table & | tab | ||
) |
void casacore::ColumnSet::addDataManager | ( | DataManager * | ) |
Add a data manager.
It increments seqCount_p and returns that as a unique sequence number. This can, for instance, be used to create a unique file name.
void casacore::ColumnSet::addRow | ( | uInt | nrrow | ) |
Add rows to all data managers.
Bool casacore::ColumnSet::areTablesMultiUsed | ( | ) | const |
Are subtables used in other processes.
|
inline |
Inspect the auto lock when the inspection interval has expired and release it when another process needs the lock.
Definition at line 366 of file ColumnSet.h.
References casacore::TableLockData::autoRelease(), and lockPtr_p.
Referenced by casacore::PlainColumn::autoReleaseLock().
Bool casacore::ColumnSet::canAddRow | ( | ) | const |
Do all data managers and engines allow to add rows?
Can the given columns be removed from the data manager?
Bool casacore::ColumnSet::canRemoveRow | ( | ) | const |
Do all data managers and engines allow to remove rows?
Can a column be renamed in the data manager?
|
private |
Check if a data manager name has not already been used.
Start checking at the given index in the array. It returns False if the name has already been used. By default an exception is thrown if the name has already been used.
void casacore::ColumnSet::checkDataManagerNames | ( | const String & | tableName | ) | const |
Check if no double data manager names have been given.
|
inline |
Check if the table is locked for read or write.
If manual or permanent locking is in effect, it checks if the table is properly locked. If autolocking is in effect, it locks the table when needed.
Definition at line 347 of file ColumnSet.h.
References doLock(), casacore::TableLockData::hasLock(), lockPtr_p, casacore::FileLocker::Read, and casacore::TableLock::readLocking().
Referenced by casacore::PlainColumn::checkReadLock().
|
private |
Check if columns to be removed can be removed.
It returns a map of DataManager* telling how many columns for a data manager have to be removed. A count of -1 means that all columns have to be removed. For such columns the flag in the returned Block is False, otherwise True.
|
inline |
Definition at line 354 of file ColumnSet.h.
References doLock(), casacore::TableLockData::hasLock(), lockPtr_p, and casacore::FileLocker::Write.
Referenced by casacore::PlainColumn::checkWriteLock().
Get the data manager info.
Optionally only the virtual engines are retrieved.
Get the data manager change flags (used by PlainTable).
Definition at line 370 of file ColumnSet.h.
References dataManChanged_p.
|
private |
Do the actual addition of a column.
|
private |
Check if the table is locked for read or write.
If manual or permanent locking is in effect, it checks if the table is properly locked. If autolocking is in effect, it locks the table when needed.
Referenced by checkReadLock(), and checkWriteLock().
DataManager* casacore::ColumnSet::findDataManager | ( | const String & | name, |
Bool | byColumn = False |
||
) | const |
Find the data manager with the given name or for the given column.
If the data manager or column is unknown, an exception is thrown. A blank name means the data manager is unknown.
PlainColumn* casacore::ColumnSet::getColumn | ( | const String & | columnName | ) | const |
Get a column by name.
PlainColumn* casacore::ColumnSet::getColumn | ( | uInt | columnIndex | ) | const |
Get a column by index.
DataManager* casacore::ColumnSet::getDataManager | ( | uInt | seqnr | ) | const |
Get the correct data manager.
This is used by the column objects to link themselves to the correct datamanagers when they are read back.
uInt casacore::ColumnSet::getFile | ( | AipsIO & | , |
Table & | tab, | ||
uInt | nrrow, | ||
Bool | bigEndian, | ||
const TSMOption & | tsmOption | ||
) |
Read the data, reconstruct the data managers, and link those to the table object.
This function gets called when an existing table is read back. It returns the number of rows in case a data manager thinks there are more. That is in particular used by LofarStMan.
void casacore::ColumnSet::initDataManagers | ( | uInt | nrrow, |
Bool | bigEndian, | ||
const TSMOption & | tsmOption, | ||
Table & | tab | ||
) |
Initialize the data managers for a new table.
It creates the data manager column objects for each column and it allows the data managers to link themselves to the Table object and to initialize themselves.
Initialize rows startRownr till endRownr (inclusive).
Let the data managers (from the given index on) initialize themselves.
void casacore::ColumnSet::invalidateColumnCaches | ( | ) |
Invalidate the column caches for all columns.
|
inline |
Link the ColumnSet object to the TableLockData object.
Definition at line 343 of file ColumnSet.h.
References lockPtr_p.
|
inline |
Link the ColumnSet object to the BaseTable object.
Definition at line 335 of file ColumnSet.h.
References baseTablePtr_p.
|
inline |
|
private |
Open or create the MultiFile if needed.
|
private |
Let the data managers (from the given index on) prepare themselves.
Write all the data and let the data managers flush their data.
This function is called when a table gets written (i.e. flushed). It returns True if any data manager wrote something.
Remove the columns from the map and the data manager.
|
private |
Remove the last data manager (used by addColumn after an exception).
It does the opposite of addDataManager.
void casacore::ColumnSet::removeRow | ( | uInt | rownr | ) |
Remove a row from all data managers.
It will throw an exception if not possible.
Rename the column in the map.
Rename the necessary subtables in the column keywords.
void casacore::ColumnSet::reopenRW | ( | ) |
Reopen the data managers for read/write.
Synchronize the data managers when data in them have changed.
It returns the number of rows it think it has, which is needed for storage managers like LofarStMan. forceSync=True
means that the data managers are forced to do a sync. Otherwise the contents of the lock file tell if a data manager has to sync.
|
inline |
Set the table to being changed.
Definition at line 339 of file ColumnSet.h.
References baseTablePtr_p, and casacore::BaseTable::setTableChanged().
|
inline |
Synchronize the columns after it appeared that data in the main table file have changed.
It cannot deal with changes in number of columns, so it throws an exception when they have changed. Keywords in all columns are updated. The other ColumnSet gives the new data.
|
inline |
Get the trace-id of the table.
Definition at line 213 of file ColumnSet.h.
References baseTablePtr_p, and casacore::BaseTable::traceId().
Referenced by casacore::PlainColumn::traceId().
Make a unique data manager name by appending a suffix _n if needed where n is a number that makes the name unique.
Bool casacore::ColumnSet::userLock | ( | FileLocker::LockType | , |
Bool | wait | ||
) |
If needed, get a temporary user lock.
It returns False if the lock was already there.
|
inline |
Release a temporary user lock if the given release flag is True.
Definition at line 360 of file ColumnSet.h.
References lockPtr_p, and casacore::TableLockData::release().
|
private |
Definition at line 320 of file ColumnSet.h.
Referenced by linkToTable(), setTableChanged(), and traceId().
|
private |
Definition at line 325 of file ColumnSet.h.
|
private |
Definition at line 322 of file ColumnSet.h.
Definition at line 326 of file ColumnSet.h.
Referenced by dataManChanged().
|
private |
Definition at line 321 of file ColumnSet.h.
Referenced by autoReleaseLock(), checkReadLock(), checkWriteLock(), linkToLockObject(), and userUnlock().
|
private |
Definition at line 318 of file ColumnSet.h.
|
private |
Definition at line 319 of file ColumnSet.h.
Referenced by nrow().
|
private |
Definition at line 323 of file ColumnSet.h.
|
private |
Definition at line 317 of file ColumnSet.h.
Referenced by storageOption().
|
private |
Definition at line 316 of file ColumnSet.h.