28 #ifndef TABLES_BASETABLE_H
29 #define TABLES_BASETABLE_H
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/Tables/TableInfo.h>
35 #include <casacore/tables/Tables/TableDesc.h>
36 #include <casacore/tables/Tables/StorageOption.h>
37 #include <casacore/casa/Utilities/Compare.h>
38 #include <casacore/casa/Utilities/CountedPtr.h>
39 #include <casacore/casa/BasicSL/String.h>
40 #include <casacore/casa/IO/FileLocker.h>
41 #include <casacore/casa/Arrays/ArrayFwd.h>
58 class BaseTableIterator;
61 template<
class T>
class Block;
62 template<
class T>
class PtrBlock;
352 Bool byColumn)
const = 0;
402 bool cacheIterationBoundaries =
false);
433 Bool throwException)
const;
440 const String& oldName) = 0;
444 const String& oldName) = 0;
471 Bool determineOrder)
const;
BaseTable * tabNot()
take complement
virtual void addColumn(const ColumnDesc &columnDesc, const String &dataManager, Bool byName, Bool addToParent)
virtual Bool adjustRownrs(rownr_t nrrow, Vector< rownr_t > &rownrs, Bool determineOrder) const
Adjust the row numbers to be the actual row numbers in the root table.
BaseTable * select(const Block< Bool > &mask)
Select rows using a mask block.
void BaseTableCommon(const String &tableName, int tableOption, rownr_t nrrow)
Common code shared by the MPI constructor and non-MPI constructor.
virtual BaseColumn * getColumn(const String &columnName) const =0
Get a column object using its name.
Bool openedForWrite() const
Test if the table is opened for write.
virtual void renameHypercolumn(const String &newName, const String &oldName)=0
Rename a hypercolumn.
virtual void flushTableInfo()
Write the TableInfo object.
void removeRow(const Vector< uInt > &rownrs)
virtual const TableLock & lockOptions() const =0
Get the locking info.
void unmarkForDelete(Bool callback, const String &oldName)
Unmark the table for delete.
BaseTable * tabOr(BaseTable *)
union with another table
virtual void reopenRW()=0
Reopen the table for read/write.
Bool isColumnStored(uInt columnIndex) const
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.
static void unlink(BaseTable *)
Unlink from a BaseTable.
BaseTable * select(const TableExprNode &, rownr_t maxRow, rownr_t offset)
Select rows using the given expression (which can be null).
BaseTable(MPI_Comm mpiComm, const String &tableName, int tableOption, rownr_t nrrow)
MPI version of the constructor.
void showColumnInfo(ostream &os, const TableDesc &, uInt maxNameLength, const Array< String > &columnNames, Bool sort, Bool cOrder) const
Show the info of the given columns.
void throwIfTableExists()
Check if the table already exists.
Bool isMarkedForDelete() const
Test if the table is marked for delete.
virtual void copy(const String &newName, int tableOption) const
Copy the table and all its subtables.
virtual Bool asBigEndian() const =0
Is the table stored in big or little endian format?
const TableDesc & tableDesc() const
Get the table description.
CountedPtr< TableDesc > tdescPtr_p
Bool makeTableDir()
Create the table directory when needed (and possible).
virtual Vector< rownr_t > * rowStorage()
By the default the table cannot return the storage of rownrs.
TableInfo & tableInfo()
Get access to the TableInfo object.
RefTable * makeRefTable(Bool rowOrder, rownr_t initialNrrow)
Create a RefTable object.
virtual Bool lock(FileLocker::LockType, uInt nattempts)=0
Try to lock the table for read or write access.
virtual BaseTable * doSort(PtrBlock< BaseColumn * > &, const Block< CountedPtr< BaseCompare > > &, const Block< Int > &sortOrder, int sortOption, std::shared_ptr< Vector< rownr_t >> sortIterBoundaries, std::shared_ptr< Vector< size_t >> sortIterKeyIdxChange)
Do the actual sort.
Bool isColumnWritable(const String &columnName) const
Test if the given column is writable.
void writeStart(AipsIO &, Bool bigEndian)
Start writing a table.
virtual Bool canRemoveColumn(const Vector< String > &columnNames) const =0
Test if columns can be removed.
virtual Vector< rownr_t > rowNumbers() const
Get a vector of row numbers.
void removeRow(const Vector< rownr_t > &rownrs)
virtual void addColumn(const ColumnDesc &columnDesc, Bool addToParent)
Add one or more columns to the table.
rownr_t logicRows(rownr_t *&rownrs, Bool &allocated)
Get the rownrs of the table in ascending order to be used in the logical operation on the table.
virtual void getPartNames(Block< String > &names, Bool recursive) const
Get the names of the tables this table consists of.
BaseTable(const String &tableName, int tableOption, rownr_t nrrow)
Initialize the object.
virtual void showStructureExtra(std::ostream &) const
Show a possible extra table structure header.
BaseTable * tabAnd(BaseTable *)
Do logical operations on a table.
virtual void removeColumn(const Vector< String > &columnNames)=0
Remove columns.
void writeEnd(AipsIO &)
End writing a table.
virtual BaseColumn * getColumn(uInt columnIndex) const =0
Get a column object using its index.
BaseTable * select(rownr_t maxRow, rownr_t offset)
Select maxRow rows and skip first offset rows.
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.
void checkRowNumberThrow(rownr_t rownr) const
Throw an exception for checkRowNumber.
const TableDesc & makeEmptyTableDesc() const
Make an empty table description.
virtual Bool isMultiUsed(Bool checkSubTables) const =0
Is the table in use (i.e.
void doNotWrite()
Do not write the table (used in in case of exceptions).
void link()
Link to this BaseTable object (i.e.
BaseTable * sort(const Block< String > &columnNames, const Block< CountedPtr< BaseCompare > > &compareObjects, const Block< Int > &sortOrder, int sortOption, std::shared_ptr< Vector< rownr_t >> sortIterBoundaries=nullptr, std::shared_ptr< Vector< size_t >> sortIterKeyIdxChange=nullptr)
Sort a table on one or more columns of scalars.
void prepareCopyRename(const String &newName, int tableOption) const
Prepare for copying or renaming a table.
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).
BaseTable & operator=(const BaseTable &)
Assignment is forbidden, because copying a table requires some more knowledge (like table name of res...
BaseTable * select(const Vector< rownr_t > &rownrs)
Select rows using a vector of row numbers.
virtual Bool isWritable() const =0
Test if this table is writable.
void trueDeepCopy(const String &newName, const Record &dataManagerInfo, const StorageOption &, int tableOption, int endianFormat, Bool noRows) const
Make a true deep copy of the table.
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.
MPI_Comm itsMpiComm
MPI communicator for parallel I/O.
virtual Bool rowOrder() const
Tell if the table is in row order.
virtual uInt getModifyCounter() const =0
Get the modify counter.
int tableOption() const
Get the table option.
virtual void unlock()=0
Unlock the table.
int traceId() const
Get the table's trace-id.
void markForDelete(Bool callback, const String &oldName)
Mark the table for delete.
virtual BaseTable * root()
Get pointer to root table (i.e.
virtual TableDesc actualTableDesc() const =0
Get the actual table description.
virtual void mergeLock(const TableLock &lockOptions)=0
Merge the given lock info with the existing one.
void scratchCallback(Bool isScratch, const String &oldName) const
Do the callback for scratch tables (if callback is set).
virtual Bool canRemoveRow() const
Test if it is possible to remove a row from this table.
virtual Record dataManagerInfo() const =0
Get the data manager info.
virtual void addColumn(const ColumnDesc &columnDesc, const DataManager &dataManager, Bool addToParent)
BaseTable * project(const Block< String > &columnNames)
Project the given columns (i.e.
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.
void checkRowNumber(rownr_t rownr) const
Check if the row number is valid.
virtual DataManager * findDataManager(const String &name, Bool byColumn) const =0
Find the data manager with the given name or for the given column.
Bool checkRemoveColumn(const Vector< String > &columnNames, Bool throwException) const
Check if the set of columns can be removed.
virtual void addColumn(const TableDesc &tableDesc, const DataManager &dataManager, Bool addToParent)
BaseTableIterator * makeIterator(const Block< String > &columnNames, const Block< CountedPtr< BaseCompare > > &, const Block< Int > &orders, int option, bool cacheIterationBoundaries=false)
Create an iterator.
virtual TableRecord & rwKeywordSet()=0
Get read/write access to the table keyword set.
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
BaseTable * tabSub(BaseTable *)
subtract another table
String makeAbsoluteName(const String &name) const
Make the name absolute.
BaseTable * tabXor(BaseTable *)
xor with another table
void getTableInfo()
Read the TableInfo object.
BaseTable(const BaseTable &)
Copy constructor is forbidden, because copying a table requires some more knowledge (like table name ...
Bool isColumnWritable(uInt columnIndex) const
static TableInfo tableInfo(const String &tableName)
Get the table info of the table with the given name.
Bool shouldNotWrite() const
Should the table be written.
void logicCheck(BaseTable *that)
Check if the tables combined in a logical operation have the same root.
virtual void renameSubTables(const String &newName, const String &oldName)
Rename the subtables (used by rename function).
void showStructure(std::ostream &, Bool showDataMan, Bool showColumns, Bool showSubTables, Bool sortColumns, Bool cOrder)
Show the table structure (implementation of Table::showStructure).
virtual void setTableChanged()
Set the table to being changed.
Referenced counted pointer for constant data.
Abstract base class for a data manager.
LockType
Define the possible lock types.
A drop-in replacement for Block<T*>.
String: the storage and methods of handling collections of characters.
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.
uInt64 rownr_t
Define the type of a row number in a table.