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