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
30//# Includes
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
43// <summary>
44// Class with static functions to manipulate a datamanager record.
45// </summary>
46
47// <use visibility=export>
48
49// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tTableCopy.cc">
50// </reviewed>
51
52// <prerequisite>
53//# Classes you should understand before using this one.
54// <li> Table
55// </prerequisite>
56
57// <synopsis>
58// DataManInfo is a class to manipulate a datamanager info record and/or table
59// description. A datamanager info record tells how the columns are stored.
60// It is a Record containing the following fields. If omitted, a default is used.
61// <ul>
62// <li> TYPE: data manager type (default StandardStMan)
63// <li> NAME: unique data manager name
64// <li> COLUMNS: string vector containing columns stored with this data manager
65// <li> SPEC: subrecord containing data manager specific parameters
66// </ul>
67// Often an existing table description and datamanager info record are used to
68// construct a new table, but it might be necessary to change it somewhat.
69// <ul>
70// <li> Remove hypercolumn definitions from a table description. They are
71// not needed anymore and can be a burden.
72// <li> Replace non-writable storage managers (like LofarStMan) by a
73// writable one.
74// <li> Replace the deprecated TiledDataStMan by TiledShapeStMan.
75// <li> Merge two datamanager info records.
76// </ul>
77// </synopsis>
78
79//# <todo asof="$DATE:$">
80//# </todo>
81
82
84{
85public:
86 // Remove hypercolumn definitions from the table description.
87 static void removeHypercolumns (TableDesc& tabDesc);
88
89 // Replace TiledDataStMan by TiledShapeStMan in the DataManagerInfo record.
90 // Since TiledShapeStMan does not support ID columns, they are
91 // adjusted as well in tabDesc and dminfo.
92 static void adjustTSM (TableDesc& tabDesc, Record& dminfo);
93
94 // Replace non-writable storage managers by the given storage manager
95 // (usually StandardStMan or IncrementalStMan).
96 // It is possible to specify the new data manager type to use.
97 // This is needed for special storage managers like LofarStMan.
98 // If replaceMSM is set, MemoryStMan is also replaced.
99 static Record adjustStMan (const Record& dminfo, const String& dmType,
100 Bool replaceMSM = True);
101
102 // Ensure all data manager names in <src>dminfo</src> are unique by
103 // adding a unique suffix as needed (using function <src>uniqueName</src>).
104 // Empty names are set to the name of the first column (DM if no columns).
105 static void makeUniqueNames (Record& dminfo);
106
107 // Return a unique data manager name by testing if the name already
108 // exist in of the the dm-s in the <src>dminfo</src> record.
109 // If so, a suffix _i is added where i makes the name unique.
110 // The excludeDM-th dm is excluded, so comparing to itself can be avoided.
111 static String uniqueName (const Record& dminfo, const String& name,
112 Int excludeDM=-1);
113
114 // Merge the second DataManagerInfo record into the first one.
115 // If the same column occurs in both records, the second one is used.
116 // Columns having the same data manager name are combined in one data manager.
117 // If the second one has no name, it is considered to be equal to the first
118 // data manager of that type.
119 static void mergeInfo (Record&, const Record&);
120
121 // Finalize the merge by merging the dminfo record with the table description
122 // to create the final dminfo record.
123 // The final dminfo record gets all columns in the TableDesc object.
124 // The given dminfo object is leading in determining a column's data manager.
125 // If not present, the data manager type given in the TableDesc is used.
126 // If empty, StandardStMan is used.
127 static Record finalizeMerge (const TableDesc&, const Record& dminfo);
128
129 // Adapt data manager names in dminfo if already used in the table.
130 static void adaptNames (Record& dminfo, const Table&);
131
132 // Set the data managers of the given column(s) to the given tiled storage
133 // manager (normally TiledShapeStMan or TiledColumnStMan).
134 // The columns are combined in a single storage manager, so the function
135 // has to be called multiple times if, say, one per column is needed.
136 // The columns already having a tiled storage manager are not changed.
137 static void setTiledStMan (Record& dminfo, const Vector<String>& columns,
138 const String& dmType, const String& dmName,
139 const IPosition& defaultTileShape);
140
141 // Remove the given columns from the dminfo record and return a vector
142 // containing the names of the columns actually removed.
143 // The columns having a data manager matching <src>keepType</src> are not
144 // removed. Matching means that the beginning of the data manager name
145 // has to match, so "Tiled" matches all tiled storagemanagers.
147 const Vector<String>& columns,
148 const String& keepType= String());
149
150 // Adjust the data manager types and groups and the
151 // hypercolumn definitions to the actual data manager info.
152 static void adjustDesc (TableDesc& tabDesc, const Record& dminfo);
153
154 // Show the Table IO statistics.
155 static void showDataManStats (const Table&, ostream&);
156
157private:
158 // Merge the column info of data manager definitions.
159 // It is used by <src>mergeInfo</src> to merge the new dm definitions into
160 // the existing one defined in <src>dminfo</src>. It is called for each new
161 // dm, whose name/type already exists as the dmindex-th record in dminfo.
162 // It does two things:
163 // <ul>
164 // <li>Columns mentioned in newdm are removed from dm definitions in dminfo.
165 // <li>Columns in the dmindex-th dminfo record are merged into newdm,
166 // so mergeInfo can redefine that dm in the overall dminfo.
167 // </ul>
168 static void mergeColumns (Record& dminfo, uInt dmindex, Record& newdm);
169};
170
171
172
173} //# NAMESPACE CASACORE - END
174
175#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 &, ostream &)
Show the Table IO statistics.
static void removeHypercolumns(TableDesc &tabDesc)
Remove hypercolumn definitions from the table description.
static Vector< String > removeDminfoColumns(Record &dminfo, const Vector< String > &columns, const String &keepType=String())
Remove the given columns from the dminfo record and return a vector containing the names of the colum...
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 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:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
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