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