Loading...
Searching...
No Matches
casacore::ColumnSet Class Reference
tables package (libcasa_tables) » Tables_module » Tables_module_internal_classes

More...

`#include <ColumnSet.h>`

## Public Member Functions

| ColumnSet (TableDesc *, const StorageOption &=StorageOption())
| Construct from the table description.
| ~ColumnSet ()
void | reopenRW ()
| Reopen the data managers for read/write.
void | renameTables (const String &newName, const String &oldName)
| Rename the necessary subtables in the column keywords.
const StorageOption & | storageOption () const
| Get the storage option.
std::shared_ptr< MultiFileBase > | getMultiFile () const
| Get the possible MultiFileBase object used to combine files.
Bool | areTablesMultiUsed () const
| Are subtables used in other processes.
PlainColumn * | getColumn (const String &columnName) const
| Get a column by name.
PlainColumn * | getColumn (uInt columnIndex) const
| Get a column by index.
void | addDataManager (DataManager *)
| Add a data manager.
void | initDataManagers (rownr_t nrrow, Bool bigEndian, const TSMOption &tsmOption, Table &tab)
| Initialize the data managers for a new table.
void | linkToTable (BaseTable *baseTableObject)
| Link the ColumnSet object to the BaseTable object.
void | linkToLockObject (TableLockData *lockObject)
| Link the ColumnSet object to the TableLockData object.
void | checkReadLock (Bool wait)
| Check if the table is locked for read or write.
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.
Bool | userLock (FileLocker::LockType, Bool wait)
| If needed, get a temporary user lock.
void | userUnlock (Bool releaseFlag)
| Release a temporary user lock if the given release flag is True.
Bool | canAddRow () const
| Do all data managers and engines allow to add rows?
Bool | canRemoveRow () const
| Do all data managers and engines allow to remove rows?
Bool | canRemoveColumn (const Vector< String > &columnNames) const
| Can the given columns be removed from the data manager?
Bool | canRenameColumn (const String &columnName) const
| Can a column be renamed in the data manager?
void | addRow (rownr_t nrrow)
| Add rows to all data managers.
void | removeRow (rownr_t rownr)
| Remove a row from all data managers.
void | removeColumn (const Vector< String > &columnNames)
| Remove the columns from the map and the data manager.
void | renameColumn (const String &newName, const String &oldName)
| Rename the column in the map.
void | addColumn (const ColumnDesc &columnDesc, Bool bigEndian, const TSMOption &tsmOption, Table &tab)
| Add a column to the table.
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)
rownr_t | nrow () const
| Get nr of rows.
TableDesc | actualTableDesc () const
| Get the actual table description.
Record | dataManagerInfo (Bool virtualOnly=False) const
| Get the data manager info.
int | traceId () const
| Get the trace-id of the table.
void | initialize (rownr_t startRownr, rownr_t endRownr)
| Initialize rows startRownr till endRownr (inclusive).
Bool | putFile (Bool writeTable, AipsIO &, const TableAttr &, Bool fsync)
| Write all the data and let the data managers flush their data.
rownr_t | getFile (AipsIO &, Table &tab, rownr_t nrrow, Bool bigEndian, const TSMOption &tsmOption)
| Read the data, reconstruct the data managers, and link those to the table object.
void | setTableChanged ()
| Set the table to being changed.
Block< Bool > & | dataManChanged ()
| Get the data manager change flags (used by PlainTable).
rownr_t | resync (rownr_t nrrow, Bool forceSync)
| Synchronize the data managers when data in them have changed.
void | invalidateColumnCaches ()
| Invalidate the column caches for all columns.
DataManager * | getDataManager (uInt seqnr) const
| Get the correct data manager.
void | checkDataManagerNames (const String &tableName) const
| Check if no double data manager names have been given.
DataManager * | findDataManager (const String &name, Bool byColumn=False) const
| Find the data manager with the given name or for the given column.
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.
void | syncColumns (const ColumnSet &other, const TableAttr &defaultAttr)
| Synchronize the columns after it appeared that data in the main table file have changed.

## Private Member Functions

void | removeLastDataManager ()
| Remove the last data manager (used by addColumn after an exception).
void | initSomeDataManagers (uInt from, Table &tab)
| Let the data managers (from the given index on) initialize themselves.
void | prepareSomeDataManagers (uInt from)
| Let the data managers (from the given index on) prepare themselves.
void | openMultiFile (uInt from, const Table &tab, ByteIO::OpenOption)
| Open or create the MultiFile if needed.
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.
void | doAddColumn (const ColumnDesc &columnDesc, DataManager *dataManPtr)
| Do the actual addition of a column.
std::map< void *, Int > | checkRemoveColumn (const Vector< String > &columnNames)
| Check if columns to be removed can be removed.
void | doLock (FileLocker::LockType, Bool wait)
| Check if the table is locked for read or write.

## Private Attributes

TableDesc * | tdescPtr_p
StorageOption | storageOpt_p
std::shared_ptr< MultiFileBase > | multiFile_p
rownr_t | 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

## Detailed Description

Class to manage a set of table columns

### Intended use:

Internal

### Review Status

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

### Prerequisite

- PlainTable
- DataManager

### Etymology

ColumnSet represent the set of columns in a table.

### Synopsis

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 91 of file ColumnSet.h.

## Constructor & Destructor Documentation

## ColumnSet()

casacore::ColumnSet::ColumnSet | ( | TableDesc * | ,
|  | const StorageOption & | = StorageOption() )

Construct from the table description.

This creates all underlying filled and virtual column objects.

Referenced by syncColumns().

## ~ColumnSet()

casacore::ColumnSet::~ColumnSet | ( |  | ) |

## Member Function Documentation

## actualTableDesc()

TableDesc casacore::ColumnSet::actualTableDesc | ( |  | ) | const

Get the actual table description.

## addColumn() [1/4]

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.

## addColumn() [2/4]

void casacore::ColumnSet::addColumn | ( | const ColumnDesc & | columnDesc,
|  | const DataManager & | dataManager,
|  | Bool | bigEndian,
|  | const TSMOption & | tsmOption,
|  | Table & | tab )

## addColumn() [3/4]

void casacore::ColumnSet::addColumn | ( | const ColumnDesc & | columnDesc,
|  | const String & | dataManager,
|  | Bool | byName,
|  | Bool | bigEndian,
|  | const TSMOption & | tsmOption,
|  | Table & | tab )

## addColumn() [4/4]

void casacore::ColumnSet::addColumn | ( | const TableDesc & | tableDesc,
|  | const DataManager & | dataManager,
|  | Bool | bigEndian,
|  | const TSMOption & | tsmOption,
|  | Table & | tab )

## addDataManager()

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.

## addRow()

void casacore::ColumnSet::addRow | ( | rownr_t | nrrow | ) |

Add rows to all data managers.

## areTablesMultiUsed()

Bool casacore::ColumnSet::areTablesMultiUsed | ( |  | ) | const

Are subtables used in other processes.

## autoReleaseLock()

void casacore::ColumnSet::autoReleaseLock | ( |  | ) |

inline

Inspect the auto lock when the inspection interval has expired and release it when another process needs the lock.

Definition at line 368 of file ColumnSet.h.

References lockPtr_p.

## canAddRow()

Bool casacore::ColumnSet::canAddRow | ( |  | ) | const

Do all data managers and engines allow to add rows?

## canRemoveColumn()

Bool casacore::ColumnSet::canRemoveColumn | ( | const Vector< String > & | columnNames | ) | const

Can the given columns be removed from the data manager?

## canRemoveRow()

Bool casacore::ColumnSet::canRemoveRow | ( |  | ) | const

Do all data managers and engines allow to remove rows?

## canRenameColumn()

Bool casacore::ColumnSet::canRenameColumn | ( | const String & | columnName | ) | const

Can a column be renamed in the data manager?

## checkDataManagerName()

Bool casacore::ColumnSet::checkDataManagerName | ( | const String & | name,
|  | uInt | from,
|  | const String & | tableName,
|  | Bool | doTthrow = True ) const

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.

References casacore::name(), and casacore::True.

## checkDataManagerNames()

void casacore::ColumnSet::checkDataManagerNames | ( | const String & | tableName | ) | const

Check if no double data manager names have been given.

## checkReadLock()

void casacore::ColumnSet::checkReadLock | ( | Bool | wait | ) |

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 349 of file ColumnSet.h.

References doLock(), lockPtr_p, and casacore::FileLocker::Read.

## checkRemoveColumn()

std::map< void *, Int > casacore::ColumnSet::checkRemoveColumn | ( | const Vector< String > & | columnNames | ) |

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.

## checkWriteLock()

void casacore::ColumnSet::checkWriteLock | ( | Bool | wait | ) |

inline

Definition at line 356 of file ColumnSet.h.

References doLock(), lockPtr_p, and casacore::FileLocker::Write.

## dataManagerInfo()

Record casacore::ColumnSet::dataManagerInfo | ( | Bool | virtualOnly = False | ) | const

Get the data manager info.

Optionally only the virtual engines are retrieved.

References casacore::False, and casacore::Record().

## dataManChanged()

Block< Bool > & casacore::ColumnSet::dataManChanged | ( |  | ) |

inline

Get the data manager change flags (used by PlainTable).

Definition at line 372 of file ColumnSet.h.

References dataManChanged_p.

## doAddColumn()

void casacore::ColumnSet::doAddColumn | ( | const ColumnDesc & | columnDesc,
|  | DataManager * | dataManPtr )

private

Do the actual addition of a column.

## doLock()

void casacore::ColumnSet::doLock | ( | FileLocker::LockType | ,
|  | Bool | wait )

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().

## findDataManager()

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.

References casacore::False, and casacore::name().

## getColumn() [1/2]

PlainColumn * casacore::ColumnSet::getColumn | ( | const String & | columnName | ) | const

Get a column by name.

## getColumn() [2/2]

PlainColumn * casacore::ColumnSet::getColumn | ( | uInt | columnIndex | ) | const

Get a column by index.

## getDataManager()

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.

## getFile()

rownr_t casacore::ColumnSet::getFile | ( | AipsIO & | ,
|  | Table & | tab,
|  | rownr_t | 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.

## getMultiFile()

std::shared_ptr< MultiFileBase > casacore::ColumnSet::getMultiFile | ( |  | ) | const

inline

Get the possible MultiFileBase object used to combine files.

Definition at line 112 of file ColumnSet.h.

References multiFile_p.

## initDataManagers()

void casacore::ColumnSet::initDataManagers | ( | rownr_t | 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()

void casacore::ColumnSet::initialize | ( | rownr_t | startRownr,
|  | rownr_t | endRownr )

Initialize rows startRownr till endRownr (inclusive).

## initSomeDataManagers()

void casacore::ColumnSet::initSomeDataManagers | ( | uInt | from,
|  | Table & | tab )

private

Let the data managers (from the given index on) initialize themselves.

## invalidateColumnCaches()

void casacore::ColumnSet::invalidateColumnCaches | ( |  | ) |

Invalidate the column caches for all columns.

## linkToLockObject()

void casacore::ColumnSet::linkToLockObject | ( | TableLockData * | lockObject | ) |

inline

Link the ColumnSet object to the TableLockData object.

Definition at line 345 of file ColumnSet.h.

References lockPtr_p.

## linkToTable()

void casacore::ColumnSet::linkToTable | ( | BaseTable * | baseTableObject | ) |

inline

Link the ColumnSet object to the BaseTable object.

Definition at line 337 of file ColumnSet.h.

References baseTablePtr_p.

## nrow()

rownr_t casacore::ColumnSet::nrow | ( |  | ) | const

inline

Get nr of rows.

Definition at line 333 of file ColumnSet.h.

References nrrow_p.

## openMultiFile()

void casacore::ColumnSet::openMultiFile | ( | uInt | from,
|  | const Table & | tab,
|  | ByteIO::OpenOption | )

private

Open or create the MultiFile if needed.

## prepareSomeDataManagers()

void casacore::ColumnSet::prepareSomeDataManagers | ( | uInt | from | ) |

private

Let the data managers (from the given index on) prepare themselves.

## putFile()

Bool casacore::ColumnSet::putFile | ( | Bool | writeTable,
|  | AipsIO & | ,
|  | const TableAttr & | ,
|  | Bool | fsync )

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.

## removeColumn()

void casacore::ColumnSet::removeColumn | ( | const Vector< String > & | columnNames | ) |

Remove the columns from the map and the data manager.

## removeLastDataManager()

void casacore::ColumnSet::removeLastDataManager | ( |  | ) |

private

Remove the last data manager (used by addColumn after an exception).

It does the opposite of addDataManager.

## removeRow()

void casacore::ColumnSet::removeRow | ( | rownr_t | rownr | ) |

Remove a row from all data managers.

It will throw an exception if not possible.

## renameColumn()

void casacore::ColumnSet::renameColumn | ( | const String & | newName,
|  | const String & | oldName )

Rename the column in the map.

## renameTables()

void casacore::ColumnSet::renameTables | ( | const String & | newName,
|  | const String & | oldName )

Rename the necessary subtables in the column keywords.

## reopenRW()

void casacore::ColumnSet::reopenRW | ( |  | ) |

Reopen the data managers for read/write.

## resync()

rownr_t casacore::ColumnSet::resync | ( | rownr_t | nrrow,
|  | Bool | forceSync )

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.

## setTableChanged()

void casacore::ColumnSet::setTableChanged | ( |  | ) |

inline

Set the table to being changed.

Definition at line 341 of file ColumnSet.h.

References baseTablePtr_p.

## storageOption()

const StorageOption & casacore::ColumnSet::storageOption | ( |  | ) | const

inline

Get the storage option.

Definition at line 108 of file ColumnSet.h.

References storageOpt_p.

## syncColumns()

void casacore::ColumnSet::syncColumns | ( | const ColumnSet & | other,
|  | const TableAttr & | defaultAttr )

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.

References ColumnSet().

## traceId()

int casacore::ColumnSet::traceId | ( |  | ) | const

inline

Get the trace-id of the table.

Definition at line 215 of file ColumnSet.h.

References baseTablePtr_p.

## uniqueDataManagerName()

String casacore::ColumnSet::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.

References casacore::name().

## userLock()

Bool casacore::ColumnSet::userLock | ( | FileLocker::LockType | ,
|  | Bool | wait )

If needed, get a temporary user lock.

It returns False if the lock was already there.

## userUnlock()

void casacore::ColumnSet::userUnlock | ( | Bool | releaseFlag | ) |

inline

Release a temporary user lock if the given release flag is True.

Definition at line 362 of file ColumnSet.h.

References lockPtr_p.

## Member Data Documentation

## baseTablePtr_p

BaseTable* casacore::ColumnSet::baseTablePtr_p

private

Definition at line 322 of file ColumnSet.h.

Referenced by linkToTable(), setTableChanged(), and traceId().

## blockDataMan_p

Block<void*> casacore::ColumnSet::blockDataMan_p

private

Definition at line 327 of file ColumnSet.h.

## colMap_p

std::map<String,void*> casacore::ColumnSet::colMap_p

private

Definition at line 324 of file ColumnSet.h.

## dataManChanged_p

Block<Bool> casacore::ColumnSet::dataManChanged_p

private

Definition at line 328 of file ColumnSet.h.

Referenced by dataManChanged().

## lockPtr_p

TableLockData* casacore::ColumnSet::lockPtr_p

private

Definition at line 323 of file ColumnSet.h.

Referenced by autoReleaseLock(), checkReadLock(), checkWriteLock(), linkToLockObject(), and userUnlock().

## multiFile_p

std::shared_ptr<MultiFileBase> casacore::ColumnSet::multiFile_p

private

Definition at line 320 of file ColumnSet.h.

Referenced by getMultiFile().

## nrrow_p

rownr_t casacore::ColumnSet::nrrow_p

private

Definition at line 321 of file ColumnSet.h.

Referenced by nrow().

## seqCount_p

uInt casacore::ColumnSet::seqCount_p

private

Definition at line 325 of file ColumnSet.h.

## storageOpt_p

StorageOption casacore::ColumnSet::storageOpt_p

private

Definition at line 319 of file ColumnSet.h.

Referenced by storageOption().

## tdescPtr_p

TableDesc* casacore::ColumnSet::tdescPtr_p

private

Definition at line 318 of file ColumnSet.h.

The documentation for this class was generated from the following file:

- tables/Tables/ColumnSet.h