casacore
Loading...
Searching...
No Matches
TSMOption.h
Go to the documentation of this file.
1// # TSMOption.h: Options for the Tiled Storage Manager Access
2// # Copyright (C) 2010
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 receied 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_TSMOPTION_H
27#define TABLES_TSMOPTION_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31
32namespace casacore { // # NAMESPACE CASACORE - BEGIN
33
34// <summary>
35// Options for the Tiled Storage Manager Access
36// </summary>
37
38// <use visibility=export>
39
40// <reviewed reviewer="TPPR" date="08.11.94" tests="tTiledShapeStMan.cc">
41// </reviewed>
42
43// <prerequisite>
44// # Classes you should understand before using this one.
45// <li> <linkto class=TiledStMan>TiledStMan</linkto>
46// </prerequisite>
47
48// <synopsis>
49// This class can be used to define how the Tiled Storage Manager accesses
50// its data. There are three ways:
51// <ol>
52// <li> Using a cache of its own. The cache size is derived using the hinted
53// access pattern. The cache can be (too) large when using large tables
54// with bad access patterns.
55// A maximum cache size can be defined to overcome this problem, but
56// that may result in poor caching behaviour.
57// Until January 2010 this was the only way to access the data.
58// <li> Use memory-mapped IO (mmap); the operating system take care of caching.
59// On 32-bit systems mmap cannot be used for larger tables due to the
60// 4 GB address space limit.
61// When creating or extending files, mmap can be disadvantageous because
62// extending the file requires remapping it.
63// <li> Use buffered IO; the kernel's file cache should avoid unnecessary IO.
64// Its performance is less than mmap, but it works well on 32-bit systems.
65// The buffer size to be used can be defined.
66// </ol>
67//
68// The constructor of the class can be used to define the options or
69// to read options from the aipsrc file.
70// <ul>
71// <li> <src>TSMOption::Cache</src>
72// Use unbuffered file IO with internal TSM caching. This is the old
73// behaviour.
74// The maximum cache size can be given as a constructor argument.
75// <li> <src>TSMOption::MMap</src>
76// Use memory-mapped IO.
77// <li> <src>TSMOption::Buffer</src>
78// Use buffered file IO without.
79// The buffer size can be given as a constructor argument.
80// <li> <src>TSMOption::Default</src>
81// Use default. This is MMap for existing files on 64-bit systems,
82// otherwise Buffer.
83// <li> <src>TSMOption::Aipsrc</src>
84// Use the option as defined in the aipsrc file.
85// </ul>
86// The aipsrc variables are:
87// <ul>
88// <li> <src>table.tsm.option</src> gives the option as the case-insensitive
89// string value:
90// <ul>
91// <li> <src>cache</src> means TSMCache.
92// <li> <src>mmap</src> (or <src>map</src>) means TSMMap.
93// <li> <src>mmapold</src> (or <src>mapold</src>) means TSMMap for existing
94// tables and TSMDefault for new tables.
95// <li> <src>buffer</src> means TSMBuffer.
96// <li> <src>default</src> means TSMDefault.
97// </ul>
98// It defaults to value <src>default</src>.
99// Note that <src>mmapold</src> is almost the same as <src>default</src>.
100// Only on 32-bit systems it is different.
101// <li> <src>table.tsm.maxcachesizemb</src> gives the maximum cache size in
102// MibiByte for option <src>TSMOption::Cache</src>. A value -1 means
103// that the system determines the maximum. A value 0 means unlimited.
104// It defaults to -1.
105// Note it can always be overridden using class ROTiledStManAccessor.
106// <li> <src>table.tsm.buffersize</src> gives the buffer size for option
107// <src>TSMOption::Buffer</src>. A value <=0 means use the default 4096.
108// It defaults to 0.
109// </ul>
110// </synopsis>
111
113 public:
114 // Define the possible options how the TiledStMan accesses its data.
115 enum Option {
116 // Use unbuffered file IO with internal TSM caching.
118 // Use buffered file IO without internal TSM caching.
120 // Use memory-mapped IO.
122 // Use default.
124 // Use as defined in the aipsrc file.
126 };
127
128 // Create an option object.
129 // The parameter values are described in the synopsis.
130 // A size value -2 means reading that size from the aipsrc file.
131 // The buffer size has to be given in bytes.
132 // The maximum cache size has to be given in MibiBytes (1024*1024 bytes).
134
135 // Fill the option in case Aipsrc or Default was given.
136 // It is done as explained in the synopsis.
137 void fillOption(Bool newFile);
138
139 // Get the option.
140 Option option() const { return itsOption; }
141
142 // Get the buffer size.
143 Int bufferSize() const { return itsBufferSize; }
144
145 // Get the maximum cache size (in MibiByte). -1 means undefined.
147
148 private:
152};
153
154} // namespace casacore
155
156#endif
Int bufferSize() const
Get the buffer size.
Definition TSMOption.h:143
Option option() const
Get the option.
Definition TSMOption.h:140
TSMOption(Option option=Aipsrc, Int bufferSize=-2, Int maxCacheSizeMB=-2)
Create an option object.
Int maxCacheSizeMB() const
Get the maximum cache size (in MibiByte).
Definition TSMOption.h:146
void fillOption(Bool newFile)
Fill the option in case Aipsrc or Default was given.
Option
Define the possible options how the TiledStMan accesses its data.
Definition TSMOption.h:115
@ Default
Use default.
Definition TSMOption.h:123
@ MMap
Use memory-mapped IO.
Definition TSMOption.h:121
@ Buffer
Use buffered file IO without internal TSM caching.
Definition TSMOption.h:119
@ Aipsrc
Use as defined in the aipsrc file.
Definition TSMOption.h:125
@ Cache
Use unbuffered file IO with internal TSM caching.
Definition TSMOption.h:117
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40