31#include <casacore/casa/aips.h>
32#include <casacore/tables/Tables/BaseTable.h>
33#include <casacore/tables/Tables/TableLock.h>
34#include <casacore/tables/Tables/RowNumbers.h>
35#include <casacore/tables/DataMan/TSMOption.h>
36#include <casacore/casa/Arrays/ArrayFwd.h>
37#include <casacore/casa/Containers/Record.h>
38#include <casacore/casa/Utilities/DataType.h>
39#include <casacore/casa/Utilities/Sort.h>
58template<
class T>
class Block;
380 {
return baseTabPtr_p == other.baseTabPtr_p; }
481 {
return (baseTabPtr_p == 0 ?
True : baseTabPtr_p->isNull()); }
519 Int maxVal=25)
const;
853 const Block<std::shared_ptr<BaseCompare>>& compareObjects,
1013 __attribute__ ((deprecated ("Now use TableUtil::openTable")));
1019 __attribute__ ((deprecated ("Now use TableUtil::openTable")));
1023 __attribute__ ((deprecated ("Now use TableUtil::canDeleteTable")));
1027 __attribute__ ((deprecated ("Now use TableUtil::canDeleteTable")));
1031 __attribute__ ((deprecated ("Now use TableUtil::deleteTable")));
1034 __attribute__ ((deprecated ("Now use TableUtil::getLayout")));
1037 __attribute__ ((deprecated ("Now use TableUtil::
tableInfo")));
1051 uInt lastModCounter_p;
1095 void showColumnInfo (ostream& os, const
TableDesc&,
uInt maxNameLength,
1102 {
return baseTabPtr_p->
root() == other.baseTabPtr_p->
root(); }
1107 { baseTabPtr_p->flush (fsync, recursive); }
1109 { baseTabPtr_p->resync(); }
1112 {
return baseTabPtr_p->storageOption(); }
1114 {
return baseTabPtr_p->isMultiUsed(checkSubTables); }
1116 {
return baseTabPtr_p->lockOptions(); }
1118 {
return baseTabPtr_p->lock (type, nattempts); }
1125 { baseTabPtr_p->unlock(); }
1127 {
return baseTabPtr_p->hasLock (type); }
1134 {
return baseTabPtr_p == baseTabPtr_p->root(); }
1137 {
return baseTabPtr_p->isWritable(); }
1139 {
return baseTabPtr_p->isColumnWritable (columnName); }
1141 {
return baseTabPtr_p->isColumnWritable (columnIndex); }
1144 {
return baseTabPtr_p->isColumnStored (columnName); }
1146 {
return baseTabPtr_p->isColumnStored (columnIndex); }
1149 { baseTabPtr_p->rename (newName, option); }
1170 { baseTabPtr_p->markForDelete (
True,
""); }
1172 { baseTabPtr_p->unmarkForDelete(
True,
""); }
1174 {
return baseTabPtr_p->isMarkedForDelete(); }
1177 {
return baseTabPtr_p->nrow(); }
1178inline BaseTable* Table::baseTablePtr()
const
1179 {
return baseTabPtr_p; }
1181 {
return baseTabPtr_p->tableDesc(); }
1183 {
return baseTabPtr_p->keywordSet(); }
1186 {
return baseTabPtr_p->tableInfo(); }
1188 {
return baseTabPtr_p->tableInfo(); }
1190 { baseTabPtr_p->flushTableInfo(); }
1193 {
return baseTabPtr_p->tableName(); }
1195 {
return TableType(baseTabPtr_p->tableType()); }
1197 {
return baseTabPtr_p->tableOption(); }
1200 {
return baseTabPtr_p->canAddRow(); }
1202 {
return baseTabPtr_p->canRemoveRow(); }
1204 {
return baseTabPtr_p->canRemoveColumn (columnNames); }
1206 {
return baseTabPtr_p->canRenameColumn (columnName); }
1209 { baseTabPtr_p->addRow (nrrow, initialize); }
1211 { baseTabPtr_p->removeRow (rownr); }
1213 { baseTabPtr_p->removeRow (rownrs); }
1215 { baseTabPtr_p->addColumn (columnDesc, addToParent); }
1219 { baseTabPtr_p->addColumn (columnDesc, dataManager, byName, addToParent); }
1222 { baseTabPtr_p->addColumn (columnDesc, dataManager, addToParent); }
1225 { baseTabPtr_p->addColumn (
tableDesc, dataManager, addToParent); }
1229 { baseTabPtr_p->removeColumn (columnNames); }
1231 { baseTabPtr_p->renameColumn (newName, oldName); }
1233 { baseTabPtr_p->renameHypercolumn (newName, oldName); }
1236 Bool byColumn)
const
1238 return baseTabPtr_p->findDataManager (name, byColumn);
1247 { baseTabPtr_p->showStructure (os, showDataMans, showColumns,
1248 showSubTables, sortColumns, cOrder); }
virtual void reopenRW()=0
Reopen the table for read/write.
virtual BaseTable * root()
Get pointer to root table (i.e.
Abstract base class for a data manager.
LockType
Define the possible lock types.
@ Write
Acquire a write lock.
@ Read
Acquire a read lock.
Create a new table - define shapes, data managers, etc.
String: the storage and methods of handling collections of characters.
Abstract base class for a node in a table column expression tree.
LockOption
Define the possible table locking options.
static Bool isOpened(const String &tableName)
Is the table used (i.e.
Table(SetupNewTable &, const TableLock &lockOptions, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Table(SetupNewTable &, TableType, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
void copy(const String &newName, TableOption, Bool noRows=False) const
Copy the table and all its subtables.
Bool hasLock(FileLocker::LockType=FileLocker::Write) const
Has this process the read or write lock, thus can the table be read or written safely?
const TableLock & lockOptions() const
Get the locking options.
void unlock()
Unlock the table.
void renameHypercolumn(const String &newName, const String &oldName)
Table(const Block< Table > &tables, const Block< String > &subTables=Block< String >(), const String &subDirName=String())
Create a table object as the virtual concatenation of one or more of existing tables.
static Vector< String > nonWritableFiles(const String &tableName)
Find the non-writable files in a table.
Bool isMarkedForDelete() const
Test if the table is marked for delete.
TableType tableType() const
Get the table type.
Table(const String &tableName, const String &tableDescName, const TableLock &lockOptions, TableOption=Table::Old, const TSMOption &=TSMOption())
friend AipsIO & operator>>(AipsIO &, Table &)
Read a table from AipsIO (for TypedKeywords<Table>).
int tableOption() const
Get the table option.
void ScratchCallback(const String &name, Bool isScratch, const String &oldName)
Define the signature of the function being called when the state of a scratch table changes (i....
Bool isNull() const
Test if the object is null, i.e.
Table sort(const String &columnName, int=Sort::Ascending, int=Sort::ParSort) const
Sort a table on one or more columns of scalars.
Table(const String &tableName, const String &tableDescName, TableOption=Table::Old, const TSMOption &=TSMOption())
Bool isColumnWritable(const String &columnName) const
Test if the given column is writable.
static Bool isNativeDataType(DataType dtype)
Test if the given data type is native to the table system.
void unmarkForDelete()
Unmark the table for delete.
Table operator()(const TableExprNode &, rownr_t maxRow=0, rownr_t offset=0) const
Select rows from a table using an select expression consisting of TableExprNode objects.
const TableDesc & tableDesc() const
Get the table description.
Table(MPI_Comm mpiComm, SetupNewTable &, TableType, const TableLock &lockOptions, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
static String fileName(const String &tableName)
Make the table file name.
void closeSubTables() const
Close all open subtables.
Bool isSameRoot(const Table &other) const
Is the root table of this table the same as that of the other one?
DataManager * findDataManager(const String &name, Bool byColumn=False) const
Find the data manager with the given name or for the given column name.
void renameColumn(const String &newName, const String &oldName)
Rename a column.
Table(MPI_Comm mpiComm, SetupNewTable &, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Table(TableType, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Make a new empty table (plain (scratch) or memory type).
const String & tableName() const
Get the table name.
Table(const Block< String > &tableNames, const Block< String > &subTables, const TableLock &lockOptions, TableOption=Table::Old, const TSMOption &=TSMOption())
Bool canRemoveRow() const
Test if it is possible to remove a row from this table.
RowNumbers rowNumbers() const
Get a vector of row numbers in the root table of rows in this table.
TableExprNode key(const Vector< String > &fieldNames) const
EndianFormat
Define the possible endian formats in which table data can be stored.
@ AipsrcEndian
use endian format defined in the aipsrc variable table.endianformat If undefined, it defaults to Loca...
@ LocalEndian
store data in the endian format of the machine used
@ BigEndian
store table data in big endian (e.g.
@ LittleEndian
store table data in little endian (e.g.
static uInt nAutoLocks()
Determine the number of locked tables opened with the AutoLock option (Locked table means locked for ...
TableOption
Define the possible options how a table can be opened.
@ Scratch
new table, which gets marked for delete
@ Update
update existing table
@ NewNoReplace
create table (may not exist)
rownr_t nrow() const
Get the number of rows.
static Bool isWritable(const String &tableName, bool throwIf=False)
Test if a table with the given name exists and is writable.
Table(SetupNewTable &, TableLock::LockOption, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
void flushTableInfo() const
Write the TableInfo object.
Bool canAddRow() const
Test if it is possible to add a row to this table.
Bool lock(FileLocker::LockType=FileLocker::Write, uInt nattempts=0)
Try to lock the table for read or write access (default is write).
Bool hasDataChanged()
Determine if column or keyword table data have changed (or is being changed) since the last time this...
Table operator&(const Table &) const
Do logical operations on a table.
static Bool isReadable(const String &tableName, bool throwIf=False)
Test if a table with the given name exists and is readable.
void rename(const String &newName, TableOption)
Rename the table and all its subtables.
TableExprNode key(const String &keywordName) const
Create a TableExprNode object for a column or for a keyword in the table keyword set.
void flush(Bool fsync=False, Bool recursive=False)
Flush the table, i.e.
Bool canRemoveColumn(const String &columnName) const
Test if columns can be removed.
void markForDelete()
Mark the table for delete.
static void relinquishAutoLocks(Bool all=False)
Unlock locked tables opened with the AutoLock option.
friend AipsIO & operator<<(AipsIO &, const Table &)
Write a table to AipsIO (for TypedKeywords<Table>).
Bool isColumnStored(const String &columnName) const
Test if the given column is stored (otherwise it is virtual).
Block< String > getPartNames(Bool recursive=False) const
Get the names of the tables this table consists of.
TableExprNode nodeRownr(rownr_t origin=0) const
Create a TableExprNode object for the rownumber function.
const StorageOption & storageOption() const
Get the storage option used for the table.
Table copyToMemoryTable(const String &name, Bool noRows=False) const
Make a copy of a table to a MemoryTable object.
Table(SetupNewTable &, TableType, const TableLock &lockOptions, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
static ScratchCallback * setScratchCallback(ScratchCallback *)
Set the pointer to the ScratchCallback function.
void removeColumn(const String &columnName)
Remove columns.
void showStructure(std::ostream &, Bool showDataMans=True, Bool showColumns=True, Bool showSubTables=False, Bool sortColumns=False, Bool cOrder=False) const
Show the structure of the table.
const TableRecord & keywordSet() const
Get readonly access to the table keyword set.
TableExprNode nodeRandom() const
Create a TableExprNode object for the rand function.
Table operator!() const
Take complement.
Table(const String &tableName, TableOption=Table::Old, const TSMOption &=TSMOption())
Create a table object for an existing table.
Table(MPI_Comm mpiComm, SetupNewTable &, TableLock::LockOption, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Table operator^(const Table &) const
Xor with another table.
void getTableKeyword(AipsIO &, Bool openWritable)
Read a table from AipsIO (for TableKeywords).
void removeRow(rownr_t rownr)
Remove the given row(s).
Table sort(const Block< String > &columnNames, const Block< std::shared_ptr< BaseCompare > > &compareObjects, const Block< Int > &sortOrders, int=Sort::ParSort) const
Sort on multiple columns.
Table operator|(const Table &) const
Union with another table.
void throwIfNull() const
Throw an exception if the object is null, i.e.
Bool isMultiUsed(Bool checkSubTables=False) const
Is the table used (i.e.
Bool isWritable() const
Test if this table is opened as writable.
Table::EndianFormat endianFormat() const
Get the endian format in which the table is stored.
void resync()
Resynchronize the Table object with the table file.
Bool canRenameColumn(const String &columnName) const
Test if a column can be renamed.
void reopenRW()
Try to reopen the table for read/write access.
TableDesc actualTableDesc() const
Table(MPI_Comm mpiComm, SetupNewTable &, const TableLock &lockOptions, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
TableType
Define the possible table types.
@ Plain
plain table (stored on disk)
const TableInfo & tableInfo() const
Get access to the TableInfo object.
Table sort(const Block< String > &columnNames, const Block< Int > &sortOrders, int=Sort::ParSort) const
Sort on multiple columns.
void deepCopy(const String &newName, TableOption, Bool valueCopy=False, EndianFormat=AipsrcEndian, Bool noRows=False) const
virtual ~Table()
The destructor flushes (i.e.
void addRow(rownr_t nrrow=1, Bool initialize=False)
Add one or more rows at the end of the table.
TableExprNode col(const String &columnName, const Vector< String > &fieldNames) const
Table(const Table &)
Copy constructor (reference semantics).
Bool isRootTable() const
Test if this table is the root table (ie.
Table(MPI_Comm mpiComm, TableType, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
TableExprNode col(const String &columnName) const
static Vector< String > getLockedTables(FileLocker::LockType=FileLocker::Read, int lockOption=-1)
Get the names of tables locked in this process.
Table(const Block< String > &tableNames, const Block< String > &subTables=Block< String >(), TableOption=Table::Old, const TSMOption &=TSMOption(), const String &subDirName=String())
Table sort(const Block< String > &columnNames, int=Sort::Ascending, int=Sort::ParSort) const
Sort on multiple columns.
Table()
Create a null Table object (i.e.
Table(const String &tableName, const TableLock &lockOptions, TableOption=Table::Old, const TSMOption &=TSMOption())
Table operator-(const Table &) const
Subtract another table.
Table(SetupNewTable &, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Make a table object for a new table, which can thereafter be used for reading and writing.
TableRecord & rwKeywordSet()
Get read/write access to the table keyword set.
Table project(const Block< String > &columnNames) const
Project the given columns (i.e.
RowNumbers rowNumbers(const Table &that, Bool tryFast=False) const
Get a vector of row numbers in that table of rows in this table.
void addColumn(const ColumnDesc &columnDesc, Bool addToParent=True)
Add a column to the table.
void showKeywordSets(std::ostream &, Bool showTabKey, Bool showColKey, Int maxVal) const
Show the table and/or column keywords of this table.
Table(MPI_Comm mpiComm, SetupNewTable &, TableType, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Bool isSameTable(const Table &other) const
Is this table the same as the other?
void showKeywords(std::ostream &, Bool showSubTables=False, Bool showTabKey=True, Bool showColKey=False, Int maxVal=25) const
Show the table and/or column keywords, possibly also of all subtables.
Table & operator=(const Table &)
Assignment (reference semantics).
Record dataManagerInfo() const
Return all data managers used and the columns served by them.
this file contains all the compiler specific defines
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
bool Bool
Define the standard types used by Casacore.
LatticeExprNode all(const LatticeExprNode &expr)
uInt64 rownr_t
Define the type of a row number in a table.
Define real & complex conjugation for non-complex types and put comparisons into std namespace.