28 #ifndef TABLES_TABLE_H
29 #define TABLES_TABLE_H
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/Tables/BaseTable.h>
35 #include <casacore/tables/Tables/TableLock.h>
36 #include <casacore/tables/Tables/RowNumbers.h>
37 #include <casacore/tables/DataMan/TSMOption.h>
38 #include <casacore/casa/Arrays/ArrayFwd.h>
39 #include <casacore/casa/Utilities/DataType.h>
40 #include <casacore/casa/Utilities/Sort.h>
57 template<
class T>
class Block;
58 template<
class T>
class CountedPtr;
580 Int maxVal=25)
const;
1178 const Record& dataManagerInfo,
1187 const Record& dataManagerInfo,
1265 Bool byColumn)
const
1277 showSubTables, sortColumns, cOrder); }
virtual void renameHypercolumn(const String &newName, const String &oldName)=0
Rename a hypercolumn.
virtual void flushTableInfo()
Write the TableInfo object.
virtual const TableLock & lockOptions() const =0
Get the locking info.
void unmarkForDelete(Bool callback, const String &oldName)
Unmark the table for delete.
virtual void reopenRW()=0
Reopen the table for read/write.
virtual Bool isNull() const
Is the table a null table? By default it is not.
virtual void renameColumn(const String &newName, const String &oldName)=0
Rename a column.
Bool isMarkedForDelete() const
Test if the table is marked for delete.
const TableDesc & tableDesc() const
Get the table description.
TableInfo & tableInfo()
Get access to the TableInfo object.
virtual Bool lock(FileLocker::LockType, uInt nattempts)=0
Try to lock the table for read or write access.
Bool isColumnWritable(const String &columnName) const
Test if the given column is writable.
virtual Bool canRemoveColumn(const Vector< String > &columnNames) const =0
Test if columns can be removed.
virtual void addColumn(const ColumnDesc &columnDesc, Bool addToParent)
Add one or more columns to the table.
virtual void removeColumn(const Vector< String > &columnNames)=0
Remove columns.
virtual TableRecord & keywordSet()=0
Get readonly access to the table keyword set.
virtual void removeRow(rownr_t rownr)
Remove rows.
virtual void addRow(rownr_t nrrow=1, Bool initialize=True)
Add one or more rows and possibly initialize them.
virtual Bool isMultiUsed(Bool checkSubTables) const =0
Is the table in use (i.e.
const String & tableName() const
Get the table name.
virtual Bool canRenameColumn(const String &columnName) const =0
Test if a column can be renamed.
Bool isColumnStored(const String &columnName) const
Test if the given column is stored (otherwise it is virtual).
virtual Bool isWritable() const =0
Test if this table is writable.
virtual void resync()=0
Resync the Table object with the table file.
virtual void rename(const String &newName, int tableOption)
Rename the table.
virtual Bool canAddRow() const
Test if it is possible to add a row to this table.
rownr_t nrow() const
Get number of rows.
int tableOption() const
Get the table option.
virtual void unlock()=0
Unlock the table.
void markForDelete(Bool callback, const String &oldName)
Mark the table for delete.
virtual BaseTable * root()
Get pointer to root table (i.e.
virtual Bool canRemoveRow() const
Test if it is possible to remove a row from this table.
virtual Bool hasLock(FileLocker::LockType) const =0
Has this process the read or write lock, thus can the table be read or written safely?
void addColumns(const TableDesc &tableDesc, const Record &dmInfo, Bool addToParent)
Add one or more columns to the table.
virtual void flush(Bool fsync, Bool recursive)=0
Flush the table, i.e.
virtual int tableType() const
Get the table type.
virtual DataManager * findDataManager(const String &name, Bool byColumn) const =0
Find the data manager with the given name or for the given column.
virtual const StorageOption & storageOption() const =0
Get the storage option used for the table.
virtual void deepCopy(const String &newName, const Record &dataManagerInfo, const StorageOption &, int tableOption, Bool valueCopy, int endianFormat, Bool noRows) const
void showStructure(std::ostream &, Bool showDataMan, Bool showColumns, Bool showSubTables, Bool sortColumns, Bool cOrder)
Show the table structure (implementation of Table::showStructure).
Referenced counted pointer for constant data.
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 void deleteTable(const String &tableName, Bool checkSubTables=False)
Delete the 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())
Table sort(const Block< String > &columnNames, const Block< CountedPtr< BaseCompare > > &compareObjects, const Block< Int > &sortOrders, int=Sort::ParSort) const
Sort on multiple columns.
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())
Table & operator=(const Table &)
Assignment (reference semantics).
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())
TableRecord & rwKeywordSet()
Get read/write access to the table keyword set.
static String fileName(const String &tableName)
Make the table file name.
Bool fastRowNumbers(const Vector< rownr_t > &v1, const Vector< rownr_t > &v2, Vector< rownr_t > &rows) const
Try if v1 is a subset of v2 and fill rows with its indices in v2.
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.
static ScratchCallback * setScratchCallback(ScratchCallback *)
Set the pointer to the ScratchCallback function.
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.
static rownr_t getLayout(TableDesc &desc, const String &tableName)
Return the layout of a table (i.e.
RowNumbers rowNumbers() const
Get a vector of row numbers in the root table of rows in this table.
static Table openTable(const String &tableName, TableOption=Table::Old, const TSMOption &=TSMOption())
Try to open a table.
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 ...
static ScratchCallback * scratchCallback_p
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.
friend AipsIO & operator<<(AipsIO &, const Table &)
Write a table to AipsIO (for TypedKeywords<Table>).
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.
Bool isColumnStored(const String &columnName) const
Test if the given column is stored (otherwise it is virtual).
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 Bool canDeleteTable(const String &tableName, Bool checkSubTables=False)
Can the table be deleted? If true, function deleteTable can safely be called.
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.
static Table openTable(const String &tableName, const TableLock &lockOptions, TableOption=Table::Old, const TSMOption &=TSMOption())
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())
static BaseTable * makeBaseTable(const String &name, const String &type, int tableOption, const TableLock &lockOptions, const TSMOption &tsmOpt, Bool addToCache, uInt locknr)
Construct a BaseTable object from the table file.
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).
void showColumnInfo(ostream &os, const TableDesc &, uInt maxNameLength, const Array< String > &columnNames, Bool sort) const
Show the info of the given columns.
Table operator|(const Table &) const
Union with another table.
void throwIfNull() const
Throw an exception if the object is null, i.e.
friend AipsIO & operator>>(AipsIO &, Table &)
Read a table from AipsIO (for TypedKeywords<Table>).
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.
void open(const String &name, const String &type, int tableOption, const TableLock &lockOptions, const TSMOption &tsmOpt)
Open an existing table.
Table sort(const Block< String > &columnNames, const Block< Int > &sortOrders, int=Sort::ParSort) const
Sort on multiple columns.
Table(BaseTable *, Bool countIt=True)
Construct a Table object from a BaseTable*.
void deepCopy(const String &newName, TableOption, Bool valueCopy=False, EndianFormat=AipsrcEndian, Bool noRows=False) const
virtual ~Table()
The destructor flushes (i.e.
BaseTable * lookCache(const String &name, int tableOption, const TableLock &tableInfo)
Look in the cache if the table is already open.
void addRow(rownr_t nrrow=1, Bool initialize=False)
Add one or more rows at the end of the table.
static Bool canDeleteTable(String &message, const String &tableName, Bool checkSubTables=False)
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
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.
TableExprNode keyCol(const String &name, const Vector< String > &fieldNames) const
Table(const String &tableName, const TableLock &lockOptions, TableOption=Table::Old, const TSMOption &=TSMOption())
static Vector< String > nonWritableFiles(const String &tableName)
Find the non-writable files in a table.
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.
static Vector< String > getLockedTables(FileLocker::LockType=FileLocker::Read, int lockOption=-1)
Get the names of tables locked in this process.
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.
Block< String > getPartNames(Bool recursive=False) const
Get the names of the tables this table consists of.
BaseTable * baseTablePtr() const
Get the pointer to the underlying BaseTable.
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())
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.
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.