Go to the documentation of this file.
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/DataMan/TSMOption.h>
37 #include <casacore/casa/Utilities/DataType.h>
38 #include <casacore/casa/Utilities/Sort.h>
55 template<
class T>
class Vector;
56 template<
class T>
class Block;
57 template<
class T>
class CountedPtr;
578 Int maxVal=25)
const;
1176 const Record& dataManagerInfo,
1185 const Record& dataManagerInfo,
1263 Bool byColumn)
const
1275 showSubTables, sortColumns, cOrder); }
void renameColumn(const String &newName, const String &oldName)
Rename a column.
friend AipsIO & operator>>(AipsIO &, Table &)
Read a table from AipsIO (for TypedKeywords<Table>).
Define the structure of a Casacore table.
Bool isMarkedForDelete() const
Test if the table is marked for delete.
void showColumnInfo(ostream &os, const TableDesc &, uInt maxNameLength, const Array< String > &columnNames, Bool sort) const
Show the info of the given columns.
TableType
Define the possible table types.
virtual DataManager * findDataManager(const String &name, Bool byColumn) const =0
Find the data manager with the given name or for the given column.
LockOption
Define the possible table locking options.
Table::EndianFormat endianFormat() const
Get the endian format in which the table is stored.
void reopenRW()
Try to reopen the table for read/write access.
static Bool isReadable(const String &tableName, bool throwIf=False)
Test if a table with the given name exists and is readable.
LatticeExprNode all(const LatticeExprNode &expr)
Vector< uInt > rowNumbers() const
Get a vector of row numbers in the root table of rows in this table.
virtual BaseTable * root()
Get pointer to root table (i.e.
void addColumns(const TableDesc &tableDesc, const Record &dmInfo, Bool addToParent)
Add one or more columns to the table.
Bool isColumnStored(const String &columnName) const
Test if the given column is stored (otherwise it is virtual).
Table operator()(const TableExprNode &, uInt maxRow=0, uInt offset=0) const
Select rows from a table using an select expression consisting of TableExprNode objects.
Class for a table held in memory.
void markForDelete()
Mark the table for delete.
void addColumn(const ColumnDesc &columnDesc, Bool addToParent=True)
Add a column to the table.
void showStructure(std::ostream &, Bool showDataMan, Bool showColumns, Bool showSubTables, Bool sortColumns, Bool cOrder)
Show the table structure (implementation of Table::showStructure).
Table & operator=(const Table &)
Assignment (reference semantics).
Bool isColumnWritable(const String &columnName) const
Test if the given column is writable.
Bool isColumnStored(const String &columnName) const
Test if the given column is stored (otherwise it is virtual).
AipsIO is the object persistency mechanism of Casacore
Abstract base class for a data manager.
Block< String > getPartNames(Bool recursive=False) const
Get the names of the tables this table consists of.
Bool isColumnWritable(const String &columnName) const
Test if the given column is writable.
Class to view a concatenation of tables as a single table.
virtual void addColumn(const ColumnDesc &columnDesc, Bool addToParent)
Add one or more columns to the table.
void flush(Bool fsync=False, Bool recursive=False)
Flush the table, i.e.
@ Scratch
new table, which gets marked for delete
virtual Bool canRemoveRow() const
Test if it is possible to remove a row from this table.
EndianFormat
Define the possible endian formats in which table data can be stored.
TableExprNode key(const String &keywordName) const
Create a TableExprNode object for a column or for a keyword in the table keyword set.
Read/write access to a table column.
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.
Bool hasLock(FileLocker::LockType=FileLocker::Write) const
Has this process the read or write lock, thus can the table be read or written safely?
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....
virtual void reopenRW()=0
Reopen the table for read/write.
A hierarchical collection of named fields of various types.
virtual Bool canAddRow() const
Test if it is possible to add a row to this table.
virtual void unlock()=0
Unlock the table.
Bool canRemoveRow() const
Test if it is possible to remove a row from this table.
Referenced counted pointer for constant data.
@ Update
update existing table
virtual TableRecord & keywordSet()=0
Get readonly access to the table keyword set.
void flushTableInfo() const
Write the TableInfo object.
Class defining a plain regular table.
virtual void renameHypercolumn(const String &newName, const String &oldName)=0
Rename a hypercolumn.
virtual void addRow(uInt nrrow=1, Bool initialize=True)
Add one or more rows and possibly initialize them.
@ Read
Acquire a read lock.
virtual void rename(const String &newName, int tableOption)
Rename the table.
TableExprNode keyCol(const String &name, const Vector< String > &fieldNames) const
LockType
Define the possible lock types.
static Vector< String > getLockedTables(FileLocker::LockType=FileLocker::Read, int lockOption=-1)
Get the names of tables locked in this process.
virtual Bool canRemoveColumn(const Vector< String > &columnNames) const =0
Test if columns can be removed.
virtual void deepCopy(const String &newName, const Record &dataManagerInfo, const StorageOption &, int tableOption, Bool valueCopy, int endianFormat, Bool noRows) const
Table sort(const String &columnName, int=Sort::Ascending, int=Sort::ParSort) const
Sort a table on one or more columns of scalars.
Table operator^(const Table &) const
Xor with another table.
Abstract base class for tables.
TableDesc actualTableDesc() const
Table copyToMemoryTable(const String &name, Bool noRows=False) const
Make a copy of a table to a MemoryTable object.
virtual void resync()=0
Resync the Table object with the table file.
static Vector< String > nonWritableFiles(const String &tableName)
Find the non-writable files in a table.
Bool canRemoveColumn(const String &columnName) const
Test if columns can be removed.
BaseTable * baseTablePtr() const
Get the pointer to the underlying BaseTable.
Memory related information and utilities. use visibility=export>
uInt nrow() const
Get number of rows.
static ScratchCallback * scratchCallback_p
virtual void removeColumn(const Vector< String > &columnNames)=0
Remove columns.
virtual void removeRow(uInt rownr)
Remove rows.
void showKeywordSets(std::ostream &, Bool showTabKey, Bool showColKey, Int maxVal) const
Show the table and/or column keywords of this table.
Record dataManagerInfo() const
Return all data managers used and the columns served by them.
static uInt getLayout(TableDesc &desc, const String &tableName)
Return the layout of a table (i.e.
void closeSubTables() const
Close all open subtables.
int tableOption() const
Get the table option.
virtual Bool isMultiUsed(Bool checkSubTables) const =0
Is the table in use (i.e.
@ AipsrcEndian
use endian format defined in the aipsrc variable table.endianformat If undefined, it defaults to Loca...
void unmarkForDelete()
Unmark the table for delete.
virtual ~Table()
The destructor flushes (i.e.
@ Plain
plain table (stored on disk)
const TableDesc & tableDesc() const
Get the table description.
const TableDesc & tableDesc() const
Get the table description.
TableExprNode nodeRownr(uInt origin=0) const
Create a TableExprNode object for the rownumber function.
Main interface class to a read/write table.
void deepCopy(const String &newName, TableOption, Bool valueCopy=False, EndianFormat=AipsrcEndian, Bool noRows=False) const
void getTableKeyword(AipsIO &, Bool openWritable)
Read a table from AipsIO (for TableKeywords).
const TableLock & lockOptions() const
Get the locking options.
void resync()
Resynchronize the Table object with the table file.
void renameHypercolumn(const String &newName, const String &oldName)
void removeRow(uInt rownr)
Remove the given row(s).
Table operator&(const Table &) const
Do logical operations on a table.
@ Write
Acquire a write lock.
virtual void flush(Bool fsync, Bool recursive)=0
Flush the table, i.e.
TableRecord & rwKeywordSet()
Get read/write access to the table keyword set.
virtual Bool lock(FileLocker::LockType, uInt nattempts)=0
Try to lock the table for read or write access.
static void deleteTable(const String &tableName, Bool checkSubTables=False)
Delete the table.
TableInfo & tableInfo()
Get access to the TableInfo object.
void rename(const String &newName, TableOption)
Rename the table and all its subtables.
Bool canRenameColumn(const String &columnName) const
Test if a column can be renamed.
virtual Bool isNull() const
Is the table a null table? By default it is not.
@ BigEndian
store table data in big endian (e.g.
static String fileName(const String &tableName)
Make the table file name.
Create a new table - define shapes, data managers, etc.
Bool lock(FileLocker::LockType=FileLocker::Write, uInt nattempts=0)
Try to lock the table for read or write access (default is write).
@ NewNoReplace
create table (may not exist)
static Bool isNativeDataType(DataType dtype)
Test if the given data type is native to the table system.
Bool isMultiUsed(Bool checkSubTables=False) const
Is the table used (i.e.
virtual Bool isWritable() const =0
Test if this table is writable.
Table type, subtype and further info.
static Bool isOpened(const String &tableName)
Is the table used (i.e.
Bool isWritable() const
Test if this table is opened as writable.
Table operator!() const
Take complement.
Class to hold table lock options.
this file contains all the compiler specific defines
uInt nrow() const
Get the number of rows.
virtual void renameColumn(const String &newName, const String &oldName)=0
Rename a column.
TableType tableType() const
Get the table type.
virtual const StorageOption & storageOption() const =0
Get the storage option used for the table.
Base class for the Data Manager Accessor classes.
static ScratchCallback * setScratchCallback(ScratchCallback *)
Set the pointer to the ScratchCallback function.
void unmarkForDelete(Bool callback, const String &oldName)
Unmark the table for delete.
Table operator-(const Table &) const
Subtract another table.
static Bool canDeleteTable(const String &tableName, Bool checkSubTables=False)
Can the table be deleted? If true, function deleteTable can safely be called.
virtual const TableLock & lockOptions() const =0
Get the locking info.
Handle class for a table column expression tree.
Table operator|(const Table &) const
Union with another table.
DataManager * findDataManager(const String &name, Bool byColumn=False) const
Find the data manager with the given name or for the given column name.
friend AipsIO & operator<<(AipsIO &, const Table &)
Write a table to AipsIO (for TypedKeywords<Table>).
virtual int tableType() const
Get the table type.
Bool isRootTable() const
Test if this table is the root table (ie.
Bool fastRowNumbers(const Vector< uInt > &v1, const Vector< uInt > &v2, Vector< uInt > &rows) const
Try if v1 is a subset of v2 and fill rows with its indices in v2.
Options for the Tiled Storage Manager Access.
Bool isNull() const
Test if the object is null, i.e.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
TableExprNode col(const String &columnName) const
int tableOption() const
Get the table option.
static Table openTable(const String &tableName, TableOption=Table::Old, const TSMOption &=TSMOption())
Try to open a table.
Abstract base class for a node in a table column expression tree.
template <class T, class U> class vector;
const String & tableName() const
Get the table name.
String: the storage and methods of handling collections of characters.
BaseTable * lookCache(const String &name, int tableOption, const TableLock &tableInfo)
Look in the cache if the table is already open.
virtual void flushTableInfo()
Write the TableInfo object.
bool Bool
Define the standard types used by Casacore.
static uInt nAutoLocks()
Determine the number of locked tables opened with the AutoLock option (Locked table means locked for ...
void unlock()
Unlock the table.
A hierarchical collection of named fields of various types.
@ LittleEndian
store table data in little endian (e.g.
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.
Bool hasDataChanged()
Determine if column or keyword table data have changed (or is being changed) since the last time this...
A 1-D Specialization of the Array class.
const TableRecord & keywordSet() const
Get readonly access to the table keyword set.
@ LocalEndian
store data in the endian format of the machine used
Options defining how table files are organized.
Bool isSameRoot(const Table &other) const
Is the root table of this table the same as that of the other one?
static void relinquishAutoLocks(Bool all=False)
Unlock locked tables opened with the AutoLock option.
void copy(const String &newName, TableOption, Bool noRows=False) const
Copy the table and all its subtables.
void markForDelete(Bool callback, const String &oldName)
Mark the table for delete.
Table project(const Block< String > &columnNames) const
Project the given columns (i.e.
TableExprNode nodeRandom() const
Create a TableExprNode object for the rand function.
Bool isMarkedForDelete() const
Test if the table is marked for delete.
Bool canAddRow() const
Test if it is possible to add a row to this table.
TableOption
Define the possible options how a table can be opened.
void throwIfNull() const
Throw an exception if the object is null, i.e.
const String & tableName() const
Get the table name.
void open(const String &name, const String &type, int tableOption, const TableLock &lockOptions, const TSMOption &tsmOpt)
Open an existing table.
Class for a table as a view of another table.
Table()
Create a null Table object (i.e.
virtual Bool canRenameColumn(const String &columnName) const =0
Test if a column can be renamed.
const StorageOption & storageOption() const
Get the storage option used for the table.
Envelope class for the description of a table column.
const TableInfo & tableInfo() const
Get access to the TableInfo object.
void addRow(uInt nrrow=1, Bool initialize=False)
Add one or more rows at the end of the 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 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.