casacore
Loading...
Searching...
No Matches
DataManInfo.h
Go to the documentation of this file.
1// # DataManInfo.h: Class with static functions to manipulate a datamanager info record
2// # Copyright (C) 2001,2002,2003,2009
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef TABLES_DATAMANINFO_H
27#define TABLES_DATAMANINFO_H
28
29#include <ostream>
30
31#include <casacore/casa/aips.h>
32#include <casacore/casa/Arrays/Vector.h>
33#include <casacore/casa/BasicSL/String.h>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// # Forward Declarations.
38class TableDesc;
39class Table;
40class Record;
41
42// <summary>
43// Class with static functions to manipulate a datamanager record.
44// </summary>
45
46// <use visibility=export>
47
48// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tTableCopy.cc">
49// </reviewed>
50
51// <prerequisite>
52// # Classes you should understand before using this one.
53// <li> Table
54// </prerequisite>
55
56// <synopsis>
57// DataManInfo is a class to manipulate a datamanager info record and/or table
58// description. A datamanager info record tells how the columns are stored.
59// It is a Record containing the following fields. If omitted, a default is used.
60// <ul>
61// <li> TYPE: data manager type (default StandardStMan)
62// <li> NAME: unique data manager name
63// <li> COLUMNS: string vector containing columns stored with this data manager
64// <li> SPEC: subrecord containing data manager specific parameters
65// </ul>
66// Often an existing table description and datamanager info record are used to
67// construct a new table, but it might be necessary to change it somewhat.
68// <ul>
69// <li> Remove hypercolumn definitions from a table description. They are
70// not needed anymore and can be a burden.
71// <li> Replace non-writable storage managers (like LofarStMan) by a
72// writable one.
73// <li> Replace the deprecated TiledDataStMan by TiledShapeStMan.
74// <li> Merge two datamanager info records.
75// </ul>
76// </synopsis>
77
78// # <todo asof="$DATE:$">
79// # </todo>
80
82 public:
83 // Remove hypercolumn definitions from the table description.
84 static void removeHypercolumns(TableDesc& tabDesc);
85
86 // Replace TiledDataStMan by TiledShapeStMan in the DataManagerInfo record.
87 // Since TiledShapeStMan does not support ID columns, they are
88 // adjusted as well in tabDesc and dminfo.
89 static void adjustTSM(TableDesc& tabDesc, Record& dminfo);
90
91 // Replace non-writable storage managers by the given storage manager
92 // (usually StandardStMan or IncrementalStMan).
93 // It is possible to specify the new data manager type to use.
94 // This is needed for special storage managers like LofarStMan.
95 // If replaceMSM is set, MemoryStMan is also replaced.
96 static Record adjustStMan(const Record& dminfo, const String& dmType, Bool replaceMSM = True);
97
98 // Ensure all data manager names in <src>dminfo</src> are unique by
99 // adding a unique suffix as needed (using function <src>uniqueName</src>).
100 // Empty names are set to the name of the first column (DM if no columns).
101 static void makeUniqueNames(Record& dminfo);
102
103 // Return a unique data manager name by testing if the name already
104 // exist in of the the dm-s in the <src>dminfo</src> record.
105 // If so, a suffix _i is added where i makes the name unique.
106 // The excludeDM-th dm is excluded, so comparing to itself can be avoided.
107 static String uniqueName(const Record& dminfo, const String& name, Int excludeDM = -1);
108
109 // Merge the second DataManagerInfo record into the first one.
110 // If the same column occurs in both records, the second one is used.
111 // Columns having the same data manager name are combined in one data manager.
112 // If the second one has no name, it is considered to be equal to the first
113 // data manager of that type.
114 static void mergeInfo(Record&, const Record&);
115
116 // Finalize the merge by merging the dminfo record with the table description
117 // to create the final dminfo record.
118 // The final dminfo record gets all columns in the TableDesc object.
119 // The given dminfo object is leading in determining a column's data manager.
120 // If not present, the data manager type given in the TableDesc is used.
121 // If empty, StandardStMan is used.
122 static Record finalizeMerge(const TableDesc&, const Record& dminfo);
123
124 // Adapt data manager names in dminfo if already used in the table.
125 static void adaptNames(Record& dminfo, const Table&);
126
127 // Set the data managers of the given column(s) to the given tiled storage
128 // manager (normally TiledShapeStMan or TiledColumnStMan).
129 // The columns are combined in a single storage manager, so the function
130 // has to be called multiple times if, say, one per column is needed.
131 // The columns already having a tiled storage manager are not changed.
132 static void setTiledStMan(Record& dminfo, const Vector<String>& columns, const String& dmType,
133 const String& dmName, const IPosition& defaultTileShape);
134
135 // Remove the given columns from the dminfo record and return a vector
136 // containing the names of the columns actually removed.
137 // The columns having a data manager matching <src>keepType</src> are not
138 // removed. Matching means that the beginning of the data manager name
139 // has to match, so "Tiled" matches all tiled storagemanagers.
141 const std::string& keepType = std::string());
142
143 // Adjust the data manager types and groups and the
144 // hypercolumn definitions to the actual data manager info.
145 static void adjustDesc(TableDesc& tabDesc, const Record& dminfo);
146
147 // Show the Table IO statistics.
148 static void showDataManStats(const Table&, std::ostream&);
149
150 private:
151 // Merge the column info of data manager definitions.
152 // It is used by <src>mergeInfo</src> to merge the new dm definitions into
153 // the existing one defined in <src>dminfo</src>. It is called for each new
154 // dm, whose name/type already exists as the dmindex-th record in dminfo.
155 // It does two things:
156 // <ul>
157 // <li>Columns mentioned in newdm are removed from dm definitions in dminfo.
158 // <li>Columns in the dmindex-th dminfo record are merged into newdm,
159 // so mergeInfo can redefine that dm in the overall dminfo.
160 // </ul>
161 static void mergeColumns(Record& dminfo, uInt dmindex, Record& newdm);
162};
163
164} // namespace casacore
165
166#endif
static String uniqueName(const Record &dminfo, const String &name, Int excludeDM=-1)
Return a unique data manager name by testing if the name already exist in of the the dm-s in the dmin...
static void adaptNames(Record &dminfo, const Table &)
Adapt data manager names in dminfo if already used in the table.
static void mergeColumns(Record &dminfo, uInt dmindex, Record &newdm)
Merge the column info of data manager definitions.
static void showDataManStats(const Table &, std::ostream &)
Show the Table IO statistics.
static void removeHypercolumns(TableDesc &tabDesc)
Remove hypercolumn definitions from the table description.
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 TiledShapeS...
static Record finalizeMerge(const TableDesc &, const Record &dminfo)
Finalize the merge by merging the dminfo record with the table description to create the final dminfo...
static void adjustDesc(TableDesc &tabDesc, const Record &dminfo)
Adjust the data manager types and groups and the hypercolumn definitions to the actual data manager i...
static void makeUniqueNames(Record &dminfo)
Ensure all data manager names in dminfo are unique by adding a unique suffix as needed (using functio...
static void adjustTSM(TableDesc &tabDesc, Record &dminfo)
Replace TiledDataStMan by TiledShapeStMan in the DataManagerInfo record.
static Vector< String > removeDminfoColumns(Record &dminfo, const Vector< String > &columns, const std::string &keepType=std::string())
Remove the given columns from the dminfo record and return a vector containing the names of the colum...
static Record adjustStMan(const Record &dminfo, const String &dmType, Bool replaceMSM=True)
Replace non-writable storage managers by the given storage manager (usually StandardStMan or Incremen...
static void mergeInfo(Record &, const Record &)
Merge the second DataManagerInfo record into the first one.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
String name() const
Return the name of the field.
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41