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