casacore
Loading...
Searching...
No Matches
ISMIndex.h
Go to the documentation of this file.
1// # ISMIndex.h: The Index of the Incremental Storage Manager
2// # Copyright (C) 1996,1997,1999,2005
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_ISMINDEX_H
27#define TABLES_ISMINDEX_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Containers/Block.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// # Forward declarations
36class ISMBase;
37class AipsIO;
38
39// <summary>
40// The Index of the Incremental Storage Manager
41// </summary>
42
43// <use visibility=local>
44
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
46// </reviewed>
47
48// <prerequisite>
49// # Classes you should understand before using this one.
50// <li> <linkto class=ISMBase>ISMBase</linkto>
51// </prerequisite>
52
53// <etymology>
54// ISMIndex represents the index in the Incremental Storage Manager.
55// </etymology>
56
57// <synopsis>
58// ISMIndex maintains an index of all buckets in an ISM (Incremental Storage
59// Manager). The index consists of the starting row number and the
60// bucket number of each bucket in the BucketCache object of the ISM.
61// When the ISM is opened, the entire index is read in and kept in memory.
62// When the ISM is closed or flushed, the index is written back after
63// all buckets in the file. A little header at the beginning of the file
64// indicates the starting offset of the index.
65// </synopsis>
66
67// <motivation>
68// ISMIndex encapsulates all operations on the ISM index.
69// </motivation>
70
71// # <todo asof="$DATE:$">
72// # A List of bugs, limitations, extensions or planned refinements.
73// # </todo>
74
75class ISMIndex {
76 public:
78
79 // The destructor closes the file (if opened).
81
82 // Forbid copy constructor.
83 ISMIndex(const ISMIndex&) = delete;
84
85 // Forbid assignment.
86 ISMIndex& operator=(const ISMIndex&) = delete;
87
88 // Add a row.
89 void addRow(rownr_t nrrow);
90
91 // Remove a row from the index.
92 // If the result of this is that the entire bucket gets empty,
93 // that bucketnr is returned. Otherwise -1 is returned.
95
96 // Get the bucket number for the given row.
97 // Also return the start row of the bucket and the number of rows in it.
98 uInt getBucketNr(rownr_t rownr, rownr_t& bucketStartRow, rownr_t& bucketNrrow) const;
99
100 // Read the bucket index from the AipsIO object.
101 void get(AipsIO& os);
102
103 // Write the bucket index into the AipsIO object.
104 void put(AipsIO& os);
105
106 // Add a bucket number to the index.
107 // Argument <src>rownr</src> gives the starting row of the bucket.
108 // It is used to add the bucket number at the correct place
109 // (such that the row numbers are kept in ascending order).
110 void addBucketNr(rownr_t rownr, uInt bucketNr);
111
112 // Get the number of the next bucket from the index and return
113 // it in <src>bucketNr</src>. The starting row of that bucket and
114 // the number of rows in the bucket are also returned.
115 // Return status False indicates that no more buckets are available.
116 // <br>The start of the iteration is indicated by cursor=0.
117 // The first bucket returned is the bucket containing the rownr
118 // given in <src>bucketStartRow</src> (thus set bucketStartRow
119 // to 0 if you want to start at the first bucket).
120 // <br>The next iterations return the next bucket number and fill
121 // the starting row and number of rows.
122 Bool nextBucketNr(uInt& cursor, rownr_t& bucketStartRow, rownr_t& bucketNrrow,
123 uInt& bucketNr) const;
124
125 // Show the index.
126 void show(std::ostream&) const;
127
128 private:
129 // Get the index of the bucket containing the given row.
130 uInt getIndex(rownr_t rownr) const;
131
132 // # Declare member variables.
133 // Number of entries used.
135 // Rownr index (i.e. row rows_p[i] starts in bucketNr_p[i]).
137 // Corresponding bucket number.
139};
140
141} // namespace casacore
142
143#endif
void get(AipsIO &os)
Read the bucket index from the AipsIO object.
uInt nused_p
Number of entries used.
Definition ISMIndex.h:134
void addBucketNr(rownr_t rownr, uInt bucketNr)
Add a bucket number to the index.
uInt getBucketNr(rownr_t rownr, rownr_t &bucketStartRow, rownr_t &bucketNrrow) const
Get the bucket number for the given row.
Int removeRow(rownr_t rownr)
Remove a row from the index.
uInt getIndex(rownr_t rownr) const
Get the index of the bucket containing the given row.
void show(std::ostream &) const
Show the index.
Block< rownr_t > rows_p
Rownr index (i.e.
Definition ISMIndex.h:136
void put(AipsIO &os)
Write the bucket index into the AipsIO object.
Block< uInt > bucketNr_p
Corresponding bucket number.
Definition ISMIndex.h:138
ISMIndex(const ISMIndex &)=delete
Forbid copy constructor.
void addRow(rownr_t nrrow)
Add a row.
~ISMIndex()
The destructor closes the file (if opened).
Bool nextBucketNr(uInt &cursor, rownr_t &bucketStartRow, rownr_t &bucketNrrow, uInt &bucketNr) const
Get the number of the next bucket from the index and return it in bucketNr.
ISMIndex & operator=(const ISMIndex &)=delete
Forbid assignment.
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
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44