casacore
IncrStManAccessor.h
Go to the documentation of this file.
1 //# IncrStManAccessor.h: Gives access to some IncrementalStMan functions
2 //# Copyright (C) 1996,1999,2000,2001
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_INCRSTMANACCESSOR_H
29 #define TABLES_INCRSTMANACCESSOR_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/tables/DataMan/DataManAccessor.h>
34 #include <casacore/casa/iosfwd.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 class ISMBase;
40 class DataManager;
41 class Table;
42 class String;
43 
44 // <summary>
45 // Give access to some IncrementalStMan functions
46 // </summary>
47 
48 // <use visibility=export>
49 
50 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // <li> <linkto class=IncrementalStMan>IncrementalStMan</linkto>
56 // </prerequisite>
57 
58 // <synopsis>
59 // The Table system has one or more storage managers underneath.
60 // One of these possible storage managers is the
61 // <linkto class=IncrementalStMan>IncrementalStMan</linkto>.
62 // This storage manager uses a cache of buckets. The default
63 // cache size is defined when the IncrementalStMan object was
64 // constructed at the time the table was created.
65 // <p>
66 // Sometimes it can be useful to change the cache size. E.g. when
67 // the table is accessed in a random way, the hit rate may drop
68 // when the cache is too small. The class ROIncrStManAccessor makes
69 // it possible to change the cache size in a temporary way.
70 // <br>
71 // Furthermore this class makes it possible to show the cache size
72 // and to show the cache statistics.
73 
74 // <motivation>
75 // In principle a pointer to IncrementalStMan could be used.
76 // However, that would give access to all public functions.
77 // Furthermore it could not distinguish between read/write and readonly
78 // tables.
79 // </motivation>
80 
81 // <example>
82 // This example shows how to set the cache size for
83 // the incremental storage manager with the name "ISMExample". The cache
84 // size is not persistent, i.e. when the same table is reopened
85 // at a later time, this cache size is not remembered.
86 // <srcblock>
87 // // Open a table.
88 // Table table("someName.data");
89 // // Set the cache size of its incremental storage manager ISMExample
90 // // to 5 buckets.
91 // ROIncrementalStManAccessor accessor(table, "ISMExample");
92 // accessor.setCacheSize (5);
93 // </srcblock>
94 // </example>
95 
96 //# <todo asof="$DATE:$">
97 //# </todo>
98 
99 
101 {
102 public:
103 
104  // Construct the object for a data manager in the table given the name
105  // of the data manager or the column.
106  // An exception is thrown if the data manager type is not the incremental
107  // storage manager.
108  ROIncrementalStManAccessor (const Table& table, const String& name,
109  Bool byColumn=False);
110 
112 
113  // Copy constructor (reference semantics).
115 
116  // Assignment (reference semantics).
118  (const ROIncrementalStManAccessor& that);
119 
120  // Set the cache size (in buckets) to be used by the
121  // storage manager.
122  // The cache size given in this way is not persistent.
123  // Only the cache size given to the constructors of the incremental
124  // storage managers, is persistent.
125  // If <src>canExceedNrBuckets=True</src>, the given cache size can be
126  // larger than the nr of buckets in the file. In this way the cache can
127  // be made large enough for a future file extnsion.
128  // Otherwise, it is limited to the actual number of buckets. This is useful
129  // if one wants the entire file to be cached.
130  void setCacheSize (uInt aSize, Bool canExceedNrBuckets=True);
131 
132  // Get the cache size (in buckets).
133  uInt cacheSize() const;
134 
135  // Clear the caches used by the hypercubes in this storage manager.
136  // It will flush the caches as needed and remove all buckets from them
137  // resulting in a possibly large drop in memory used.
138  void clearCache();
139 
140  // Show the index used by this storage manager.
141  void showIndexStatistics (ostream& os) const;
142 
143  // Show the layout of the buckets used by this storage manager.
144  void showBucketLayout (ostream& os) const;
145 
146  // Check that there are no repeated rowIds in the buckets comprising this ISM
147  Bool checkBucketLayout (uInt& offendingCursor,
148  rownr_t& offendingBucketStartRow,
149  uInt& offendingBucketNrow,
150  uInt& offendingBucketNr,
151  uInt& offendingCol,
152  uInt& offendingIndex,
153  rownr_t& offendingRow,
154  rownr_t& offendingPrevRow) const;
155 
156 private:
157  //# Declare the data members.
159 };
160 
161 
162 
163 } //# NAMESPACE CASACORE - END
164 
165 #endif
void setCacheSize(uInt aSize, Bool canExceedNrBuckets=True)
Set the cache size (in buckets) to be used by the storage manager.
void clearCache()
Clear the caches used by the hypercubes in this storage manager.
ROIncrementalStManAccessor(const ROIncrementalStManAccessor &that)
Copy constructor (reference semantics).
void showIndexStatistics(ostream &os) const
Show the index used by this storage manager.
uInt cacheSize() const
Get the cache size (in buckets).
ROIncrementalStManAccessor(const Table &table, const String &name, Bool byColumn=False)
Construct the object for a data manager in the table given the name of the data manager or the column...
void showBucketLayout(ostream &os) const
Show the layout of the buckets used by this storage manager.
Bool checkBucketLayout(uInt &offendingCursor, rownr_t &offendingBucketStartRow, uInt &offendingBucketNrow, uInt &offendingBucketNr, uInt &offendingCol, uInt &offendingIndex, rownr_t &offendingRow, rownr_t &offendingPrevRow) const
Check that there are no repeated rowIds in the buckets comprising this ISM.
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
const Bool False
Definition: aipstype.h:44
unsigned int uInt
Definition: aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46