casacore
Loading...
Searching...
No Matches
StandardStMan.h
Go to the documentation of this file.
1// # StandardStMan.h: The Standard Storage Manager
2// # Copyright (C) 2000,2002
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_STANDARDSTMAN_H
27#define TABLES_STANDARDSTMAN_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/DataMan/SSMBase.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// <summary>
36// The Standard Storage Manager
37// </summary>
38
39// <use visibility=export>
40
41// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tStandardStMan.cc">
42// </reviewed>
43
44// <prerequisite>
45// # Classes you should understand before using this one.
46// <li> The Table Data Managers concept as described in module file
47// <linkto module="Tables:Data Managers">Tables.h</linkto>
48// <li> <linkto class=ROStandardStManAccessor>
49// ROStandardStManAccessor</linkto>
50// for a discussion of the cache size
51// </prerequisite>
52
53// <etymology>
54// StandardStMan is the data manager which stores the data in a
55// standard way. I.e. it does not use special techniques like
56// other storage managers do.
57// </etymology>
58
59// <synopsis>
60// StandardStMan is meant as the storage manager to be used standardly.
61// Other storage managers like
62// <linkto class=IncrementalStMan>IncrementalStMan</linkto> and the
63// <linkto class=TiledStMan>TiledStMan</linkto> derivatives should
64// only be used when appropriate.
65// <br>
66// Like the other storage managers StandardStMan uses
67// <linkto class=BucketCache>bucket-based</linkto> access to its data.
68// where a bucket contains the number of columns and rows that fit best.
69// Variable length strings are stored in separate buckets because they do
70// not fit in the fixed bucket layout used for the other columns.
71// Only fixed length strings and strings <= 8 characters are stored directly.
72// Note that, in fact, fixed length string means maximum length strings.
73// It can be set using the <src>setMaxLength</src> function in
74// class <linkto class=ColumnDesc>ColumnDesc</linkto> or
75// class <linkto class=BaseColumnDesc>BaseColumnDesc</linkto>.
76// <p>
77// The file size is at least the size of a bucket, even if only the table
78// contains only a few rows, thus uses only a fraction of a bucket.
79// The default bucketsize is 32 rows. This means that if it is known
80// in advance that the table will contain many more rows, it might make
81// sense to construct the StandardStMan with a larger bucketsize.
82// <p>
83// StandardStMan is a robust storage manager. Care has been taken
84// that its index cannot be corrupted in case of exceptions like
85// device full or crash.
86// <p>
87// StandardStMan supports the following functionality:
88// <ol>
89// <li> Removal of rows. This leaves some empty space in a bucket.
90// An empty bucket will be reused.
91// <li> Addition of rows. This is always done in the last bucket
92// and a new bucket is added when needed.
93// <li> Removal of a column. This also leaves empty space, which will
94// be reused when a newly added column fits in it.
95// <li> Addition of a column. If available, empty column space is used.
96// Otherwise it creates as many new buckets as needed.
97// </ol>
98// All direct data (scalars and direct arrays) is stored in the main file.
99// Indirect arrays (except strings) are stored in a second file.
100// Indirect string arrays are also stored in the main file, because in
101// that way frequently rewriting indirect strings arrays wastes far
102// less space.
103// <p>
104// As said above all string arrays and variable length scalar strings
105// are stored in separate string buckets.
106// </synopsis>
107
108// <motivation>
109// StManAipsIO is the standard storage manager used so far.
110// Its major drawback is that it is memory based which makes it
111// not usable for large tables. Furthermore it is not a very robust
112// storage manager. When a system crashes, tables might get corrupted.
113// <br>
114// These drawbacks have been adressed in this new StandardStman.
115// It uses a bucket-based access scheme and makes sure that its
116// indices are stored in a way that they can hardly get corrupted.
117// </motivation>
118
119// <example>
120// The following example shows how to create a table and how to attach
121// the storage manager to some columns.
122// <srcblock>
123// SetupNewTable newtab("name.data", tableDesc, Table::New);
124// StandardStMan stman; // define storage manager
125// newtab.bindColumn ("column1", stman); // bind column to st.man.
126// newtab.bindColumn ("column2", stman); // bind column to st.man.
127// Table tab(newtab); // actually create table
128// </srcblock>
129//
130// The following example shows how to create a StandardStMan storage
131// manager for a table with 16 rows. By giving the (expected) nr of rows
132// to the storage manager, it can optimize its bucket size.
133// <srcblock>
134// SetupNewTable newtab("name.data", tableDesc, Table::New);
135// StandardStMan stman(-16);
136// newtab.bindAll ("column1", stman); // bind all columns to st.man.
137// Table tab(newtab); // actually create table
138// </srcblock>
139// </example>
140
141// # <todo asof="$DATE:$">
142// # A List of bugs, limitations, extensions or planned refinements.
143// # </todo>
144
145class StandardStMan : public SSMBase {
146 public:
147 // Create a Standard storage manager with the given name.
148 // If no name is used, it is set to "SSM"
149 // The name can be used to construct a
150 // <linkto class=ROStandardStManAccessor>ROStandardStManAccessor
151 // </linkto> object (e.g. to set the cache size).
152 // <br>
153 // The cache size has to be given in buckets.
154 // <br>
155 // The bucket size can be given in 2 ways:
156 // <br>- A positive number gives the bucket size in bytes.
157 // The number of rows per bucket will be calculated from it.
158 // <br>- A negative number gives the number of rows per bucket.
159 // The bucket size in bytes will be calculated from it.
160 // Note that in this way the maximum bucketsize is 32768 (minimum is 128).
161 // <br>- The default 0 means that 32 rows will be stored in a bucket.
162 // <br>Note that the default is only suitable for small tables.
163 // In general it makes sense to give the expected number of table rows.
164 // In that way the buckets will be small enough for small tables
165 // and not too small for large tables.
166 // <group>
167 explicit StandardStMan(Int bucketSize = 0, uInt cacheSize = 1);
168 explicit StandardStMan(const String& dataManagerName, Int bucketSize = 0, uInt cacheSize = 1);
169 // </group>
170
172
173 // Copy constructor cannot be used.
174 StandardStMan(const StandardStMan&) = delete;
175
176 // Assignment cannot be used.
178};
179
180} // namespace casacore
181
182#endif
SSMBase(Int aBucketSize=0, uInt aCacheSize=1)
Create a Standard storage manager with default name SSM.
virtual String dataManagerName() const
Get the name given to the storage manager (in the constructor).
StandardStMan(Int bucketSize=0, uInt cacheSize=1)
Create a Standard storage manager with the given name.
StandardStMan(const StandardStMan &)=delete
Copy constructor cannot be used.
StandardStMan(const String &dataManagerName, Int bucketSize=0, uInt cacheSize=1)
StandardStMan & operator=(const StandardStMan &)=delete
Assignment cannot be used.
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
int Int
Definition aipstype.h:48