casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Static Public Member Functions | Static Private Member Functions | List of all members
casacore::TableCopy Class Reference

Class with static functions for copying a table. More...

#include <TableCopy.h>

Static Public Member Functions

static Table makeEmptyTable (const String &newName, const Record &dataManagerInfo, const Table &tab, Table::TableOption option, Table::EndianFormat endianFormat, Bool replaceTSM=True, Bool noRows=False, const StorageOption &=StorageOption())
 Make an (empty) table with the given description. More...
 
static Table makeEmptyMemoryTable (const String &newName, const Table &tab, Bool noRows=False)
 Make an (empty) memory table with the same layout as the input one. More...
 
static void copyRows (Table &out, const Table &in, Bool flush=True)
 Copy rows from the input to the output. More...
 
static void copyRows (Table &out, const Table &in, uInt startout, uInt startin, uInt nrrow, Bool flush=True)
 
static void copyInfo (Table &out, const Table &in)
 Copy the table info block from input to output table. More...
 
static void copySubTables (Table &out, const Table &in, Bool noRows=False, const Block< String > &omit=Block< String >())
 Copy all subtables (in table and column keywords) from input to output table. More...
 
static void copySubTables (TableRecord &outKeys, const TableRecord &inKeys, const String &outName, Table::TableType outType, const Table &in, Bool noRows=False, const Block< String > &omit=Block< String >())
 Copy the subtables in the given keywordset to the output keywordset in the table with the given name. More...
 
static void cloneColumn (const Table &fromTable, const String &fromColumn, Table &toTable, const String &newColumn, const String &dataManagerName=String())
 Clone a column in the from table to a new column in the to table. More...
 
template<typename T >
static void cloneColumnTyped (const Table &fromTable, const String &fromColumn, Table &toTable, const String &newColumn, const String &dataManagerName=String())
 Cloning as above, but the data type is set to the template parameter. More...
 
static void copyColumnData (const Table &fromTable, const String &fromColumn, Table &toTable, const String &toColumn, Bool preserveTileShape=True)
 Copy the data from one column to another. More...
 
template<typename T >
static void fillArrayColumn (Table &table, const String &column, const Array< T > &value)
 Fill the table column with the given array. More...
 
template<typename T >
static void fillColumnData (Table &table, const String &column, const T &value)
 Fill the table column with the given value. More...
 
static void fillColumnData (Table &table, const String &column, const char *value)
 Specialization to handle a C-string correctly. More...
 
template<typename T >
static void fillColumnData (Table &table, const String &column, const T &value, const Table &fromTable, const String &fromColumn, Bool preserveTileShape=True)
 Fill the table column with the given value. More...
 
static void fillColumnData (Table &table, const String &column, const char *value, const Table &fromTable, const String &fromColumn, Bool preserveTileShape=True)
 Specialization to handle a C-string correctly. More...
 
static void adjustTSM (TableDesc &tabDesc, Record &dminfo)
 Replace TiledDataStMan by TiledShapeStMan in the DataManagerInfo record. More...
 
static Record adjustStMan (const Record &dminfo)
 Replace non-writable storage managers by StandardStMan. More...
 
static void setTiledStMan (Record &dminfo, const Vector< String > &columns, const String &dmType, const String &dmName, const IPosition &defaultTileShape)
 Set the data managers of the given column(s) to the given tiled storage manager (normally TiledShapeStMan or TiledColumnStMan). More...
 
static Vector< StringremoveDminfoColumns (Record &dminfo, const Vector< String > &columns, const String &keepType=String())
 Remove the columns from the dminfo record and return a vector with the names of the columns actually removed. More...
 
static void adjustDesc (TableDesc &tabDesc, const Record &dminfo)
 Adjust the data manager types and groups and the hypercolumn definitions to the actual data manager info. More...
 

Static Private Member Functions

static void doCloneColumn (const Table &fromTable, const String &fromColumn, Table &toTable, const ColumnDesc &newColumn, const String &dataManagerName)
 

Detailed Description

Class with static functions for copying a table.

Intended use:

Public interface

Review Status

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

Prerequisite

Synopsis

TableCopy is a class for making a deep copy of a table. The table can be a PlainTable or a RefTable. It contains the following static functions:

  1. makeEmptyTable creates a new table using the description and storage managers of the input table. By default TiledDataStMan (which is more or less obsolete) will be replaced by TiledShapeStMan. By default the new table contains the same number of rows as the existing table.
  2. copyRows copies the data of one to another table. It is possible to specify where to start in the input and output.
  3. CopyInfo copies the table info data.
  4. copySubTables copies all the subtables in table and column keywords. It is done recursively.

Definition at line 78 of file TableCopy.h.

Member Function Documentation

static void casacore::TableCopy::adjustDesc ( TableDesc tabDesc,
const Record dminfo 
)
inlinestatic

Adjust the data manager types and groups and the hypercolumn definitions to the actual data manager info.

Definition at line 260 of file TableCopy.h.

References casacore::DataManInfo::adjustDesc().

static Record casacore::TableCopy::adjustStMan ( const Record dminfo)
inlinestatic

Replace non-writable storage managers by StandardStMan.

This is needed for special storage managers like LofarStMan.

Definition at line 234 of file TableCopy.h.

References casacore::DataManInfo::adjustStMan().

static void casacore::TableCopy::adjustTSM ( TableDesc tabDesc,
Record dminfo 
)
inlinestatic

Replace TiledDataStMan by TiledShapeStMan in the DataManagerInfo record.

Since TiledShapeStMan does not support ID columns, they are adjusted as well in tabDesc and dminfo.

Definition at line 229 of file TableCopy.h.

References casacore::DataManInfo::adjustTSM().

static void casacore::TableCopy::cloneColumn ( const Table fromTable,
const String fromColumn,
Table toTable,
const String newColumn,
const String dataManagerName = String() 
)
static

Clone a column in the from table to a new column in the to table.

The new column gets the same table description and data manager as the from column. It has to get a unique data manager name. If not given, it is the new column name.

template<typename T >
static void casacore::TableCopy::cloneColumnTyped ( const Table fromTable,
const String fromColumn,
Table toTable,
const String newColumn,
const String dataManagerName = String() 
)
static

Cloning as above, but the data type is set to the template parameter.

static void casacore::TableCopy::copyColumnData ( const Table fromTable,
const String fromColumn,
Table toTable,
const String toColumn,
Bool  preserveTileShape = True 
)
static

Copy the data from one column to another.

It can be used after function cloneColumn to populate the new column. Note that the data types of the column do not need to match; data type promotion is done if needed.
The preserveTileShape argument tells if the original tile shape is kept if a tiled data manager is used. If False, the default tile shape of the data manager is used.
Tip: Note that a TaQL command can be used to fill a column in any way; For example, fill toColumn with the real part of a complex fromColumn:

Block<Table> tables(2);
tables[0] = toTable;
tables[1] = fromTable;
tableCommand ("update $1 set toColumn=real(t2;fromColumn) from $2 t2",
tables);

When copying a column in a straightforward way, the TaQL way is about 25% slower than using the function copyColumnData;

static void casacore::TableCopy::copyInfo ( Table out,
const Table in 
)
static

Copy the table info block from input to output table.

static void casacore::TableCopy::copyRows ( Table out,
const Table in,
Bool  flush = True 
)
inlinestatic

Copy rows from the input to the output.

By default all rows will be copied starting at row 0 of the output. Rows will be added to the output table as needed. The output table will by default be flushed after the rows are copied.
All columns in Table out will be filled from the column with the same name in table in. In principle only stored columns will be filled; however if the output table has only one column, it can also be a virtual one.

Definition at line 118 of file TableCopy.h.

References casacore::Table::nrow().

static void casacore::TableCopy::copyRows ( Table out,
const Table in,
uInt  startout,
uInt  startin,
uInt  nrrow,
Bool  flush = True 
)
static
static void casacore::TableCopy::copySubTables ( Table out,
const Table in,
Bool  noRows = False,
const Block< String > &  omit = BlockString >() 
)
static

Copy all subtables (in table and column keywords) from input to output table.

Subtables of which the keyword name matches an omit value are skipped. Optionally the row contents are not copied.

static void casacore::TableCopy::copySubTables ( TableRecord outKeys,
const TableRecord inKeys,
const String outName,
Table::TableType  outType,
const Table in,
Bool  noRows = False,
const Block< String > &  omit = BlockString >() 
)
static

Copy the subtables in the given keywordset to the output keywordset in the table with the given name.

Subtables of which the keyword name matches an omit value are skipped. Optionally the row contents are not copied.

static void casacore::TableCopy::doCloneColumn ( const Table fromTable,
const String fromColumn,
Table toTable,
const ColumnDesc newColumn,
const String dataManagerName 
)
staticprivate
template<typename T >
static void casacore::TableCopy::fillArrayColumn ( Table table,
const String column,
const Array< T > &  value 
)
static

Fill the table column with the given array.

The template type must match the column data type.

template<typename T >
static void casacore::TableCopy::fillColumnData ( Table table,
const String column,
const T &  value 
)
static

Fill the table column with the given value.

If the column contains arrays, the arrays are filled with the value. The template type must match the column data type.

Referenced by fillColumnData().

static void casacore::TableCopy::fillColumnData ( Table table,
const String column,
const char *  value 
)
inlinestatic

Specialization to handle a C-string correctly.

Definition at line 203 of file TableCopy.h.

References fillColumnData().

template<typename T >
static void casacore::TableCopy::fillColumnData ( Table table,
const String column,
const T &  value,
const Table fromTable,
const String fromColumn,
Bool  preserveTileShape = True 
)
static

Fill the table column with the given value.

The column must contain arrays. The arrays get the shape of the corresponding row in the fromColumn in the fromTable. It can be used after function cloneColumn to initialize the new column. The template type must match the column data type.

static void casacore::TableCopy::fillColumnData ( Table table,
const String column,
const char *  value,
const Table fromTable,
const String fromColumn,
Bool  preserveTileShape = True 
)
inlinestatic

Specialization to handle a C-string correctly.

Definition at line 218 of file TableCopy.h.

References fillColumnData().

static Table casacore::TableCopy::makeEmptyMemoryTable ( const String newName,
const Table tab,
Bool  noRows = False 
)
static

Make an (empty) memory table with the same layout as the input one.

It has the same keywords and columns as the input one. By default, the new table has the same nr of rows as the input table. If noRows=True is given, it does not contain any row.

static Table casacore::TableCopy::makeEmptyTable ( const String newName,
const Record dataManagerInfo,
const Table tab,
Table::TableOption  option,
Table::EndianFormat  endianFormat,
Bool  replaceTSM = True,
Bool  noRows = False,
const StorageOption = StorageOption() 
)
static

Make an (empty) table with the given description.

If the description contains no columns, the description of the input table is used, so it has the same keywords and columns as the input one. The data managers can be given in the dataManagerInfo record. If it is empty, the info is taken from the input table.
Non-writable storage managers (like LofarStMan) are by default replaced by StandardStMan. If replaceMSM is set, MemoryStMan is also replaced by StandardStMan.
By default, the TiledDataStMan will be replaced by the TiledShapeStMan.
By default, the new table has the same nr of rows as the input table. If noRows=True is given, it does not contain any row.

static Vector<String> casacore::TableCopy::removeDminfoColumns ( Record dminfo,
const Vector< String > &  columns,
const String keepType = String() 
)
inlinestatic

Remove the columns from the dminfo record and return a vector with the names of the columns actually removed.

The columns having a data manager matching keepType are not removed. Matching means that the beginning of the data manager name have to match, so "Tiled" matches all tiled storagemanagers.

Definition at line 253 of file TableCopy.h.

References casacore::DataManInfo::removeDminfoColumns().

static void casacore::TableCopy::setTiledStMan ( Record dminfo,
const Vector< String > &  columns,
const String dmType,
const String dmName,
const IPosition defaultTileShape 
)
inlinestatic

Set the data managers of the given column(s) to the given tiled storage manager (normally TiledShapeStMan or TiledColumnStMan).

The columns are combined in a single storage manager, so the function has to be called multiple times if, say, one per column is needed. The columns already having a tiled storage manager are not changed.

Definition at line 242 of file TableCopy.h.

References casacore::DataManInfo::setTiledStMan().


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