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