casacore
Loading...
Searching...
No Matches
ISMIndColumn.h
Go to the documentation of this file.
1//# ISMIndColumn.h: A column in Incremental storage manager for indirect arrays
2//# Copyright (C) 1996,1997,1998,1999,2002
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_ISMINDCOLUMN_H
27#define TABLES_ISMINDCOLUMN_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/tables/DataMan/ISMColumn.h>
33#include <casacore/tables/DataMan/StIndArray.h>
34#include <casacore/casa/Arrays/IPosition.h>
35
36namespace casacore { //# NAMESPACE CASACORE - BEGIN
37
38//# Forward Declarations
39class StManArrayFile;
40class AipsIO;
41
42
43// <summary>
44// A column of Incremental storage manager for indirect arrays.
45// </summary>
46
47// <use visibility=local>
48
49// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
50// </reviewed>
51
52// <prerequisite>
53//# Classes you should understand before using this one.
54// <li> <linkto class=ISMColumn>ISMColumn</linkto>
55// <li> <linkto class=StIndArray>StIndArray</linkto>
56// </prerequisite>
57
58// <etymology>
59// ISMIndColumn represents a Column in the Incremental Storage Manager
60// containing INDirect arrays.
61// </etymology>
62
63// <synopsis>
64// ISMIndColumn is the implementation of an
65// <linkto class=ISMColumn>ISMColumn</linkto> class
66// to handle indirect arrays. The arrays (shape and data) are stored in
67// a separate file using class <linkto class=StIndArray>StIndArray</linkto>.
68// The file offset of the beginning of the array in stored in the
69// ISM using the standard ISMColumn functions.
70// <p>
71// ISMIndColumn contains functions which are called when ISMColumn
72// duplicates or removes a value. In that way the array can also be
73// duplicated or removed in the StIndArray file by incrementing or
74// decrementing the reference count manitained in the file.
75// <p>
76// Unlike ISMColumn it is not tested if a value put is equal to
77// the value in the previous or next row, because it is too time-consuming
78// to do so (although this behaviour could be changed in the future).
79// Instead the user should not put equal values to prevent storing
80// equal values.
81// <p>
82// Note that an indirect array can have a fixed shape. In that case
83// adding a row results in reserving space for the array in the StIndArray
84// file, so for each row an array is present.
85// On the other hand adding a row does nothing for variable shaped arrays.
86// So when no data is put or shape is set, a row may contain no array at all.
87// In that case the function <src>isShapeDefined</src> returns False for
88// that row.
89// </synopsis>
90
91// <todo asof="$DATE:$">
92//# A List of bugs, limitations, extensions or planned refinements.
93// <li> Maybe TpArrayInt, etc. should be used instead of TpInt.
94// </todo>
95
96
97class ISMIndColumn : public ISMColumn
98{
99public:
100
101 // Create a column of the given data type.
102 // It keeps the pointer to its parent (but does not own it).
103 ISMIndColumn (ISMBase* parent, int dataType, uInt colnr);
104
105 // Frees up the storage.
106 virtual ~ISMIndColumn();
107
108 // Forbid copy constructor.
109 ISMIndColumn (const ISMIndColumn&) = delete;
110
111 // Forbid assignment.
113
114 // Add (newNrrow-oldNrrow) rows to the column.
115 virtual void addRow (rownr_t newNrrow, rownr_t oldNrrow);
116
117 // Set the (fixed) shape of the arrays in the entire column.
118 virtual void setShapeColumn (const IPosition& shape);
119
120 // Get the dimensionality of the item in the given row.
121 virtual uInt ndim (rownr_t rownr);
122
123 // Set the shape of the array in the given row and allocate the array
124 // in the file.
125 virtual void setShape (rownr_t rownr, const IPosition& shape);
126
127 // Is the shape defined (i.e. is there an array) in this row?
128 virtual Bool isShapeDefined (rownr_t rownr);
129
130 // Get the shape of the array in the given row.
131 virtual IPosition shape (rownr_t rownr);
132
133 // This storage manager can handle changing array shapes.
134 virtual Bool canChangeShape() const;
135
136 // Get an array value in the given row.
137 // The buffer pointed to by dataPtr has to have the correct length
138 // (which is guaranteed by the ArrayColumn get function).
139 virtual void getArrayV (rownr_t rownr, ArrayBase&);
140
141 // Put an array value into the given row.
142 // The buffer pointed to by dataPtr has to have the correct length
143 // (which is guaranteed by the ArrayColumn put function).
144 virtual void putArrayV (rownr_t rownr, const ArrayBase&);
145
146 // Get a section of the array in the given row.
147 // The array has to have the correct length
148 // (which is guaranteed by the ArrayColumn getSlice function).
149 virtual void getSliceV (rownr_t rownr, const Slicer&, ArrayBase&);
150
151 // Put into a section of the array in the given row.
152 // The array has to have the correct length
153 // (which is guaranteed by the ArrayColumn putSlice function).
154 virtual void putSliceV (rownr_t rownr, const Slicer&, const ArrayBase&);
155
156 // Let the column object create its array file.
157 virtual void doCreate (ISMBucket* bucket);
158
159 // Let the column object open an existing file.
160 virtual void getFile (rownr_t nrrow);
161
162 // Flush and optionally fsync the data.
163 virtual Bool flush (rownr_t nrrow, Bool fsync);
164
165 // Resync the storage manager with the new file contents.
166 virtual void resync (rownr_t nrrow);
167
168 // Let the column reopen its data files for read/write access.
169 virtual void reopenRW();
170
171 // Handle the duplication of a value; i.e. increment its reference count.
172 virtual void handleCopy (rownr_t rownr, const char* value);
173
174 // Handle the removal of a value; i.e. decrement its reference count.
175 virtual void handleRemove (rownr_t rownr, const char* value);
176
177private:
178 // Initialize part of the object and open/create the file.
179 // It is used by doCreate and getFile.
180 void init (ByteIO::OpenOption fileOption);
181
182 // Clear the object (used by destructor and init).
183 void clear();
184
185 // Compare the values to check if a value to be put matches the
186 // value in the previous or next row.
187 // It always return False, because comparing large arrays is
188 // too expensive (it could be changed in the future).
189 virtual Bool compareValue (const void* val1, const void* val2) const;
190
191 // Read the shape at the given row.
192 // This will cache the information in the StIndArray
193 // object for that row.
195
196 // Put the shape for an array being put.
197 // When there are multiple rows in the interval, it will
198 // split the interval.
200
201 // Put the shape for an array of which a slice is being put.
202 // It gets the shape for the given row.
203 // When there are multiple rows in the interval, it will
204 // split the interval and copy the data.
206
207 // Return a pointer to the array in the given row (for a get).
209
210 // When needed, create an array in the given row with the given shape.
211 // When the array is created, its data are copied when the flag is set.
213 Bool copyData);
214
215
216 // The (unique) sequence number of the column.
218 // The shape of all arrays in case it is fixed.
220 // Switch indicating if the shape is fixed.
222 // The file containing the arrays.
224 // The indirect array object.
226 // The indirect array exists for the row interval last accessed.
228};
229
230
231
232
233} //# NAMESPACE CASACORE - END
234
235#endif
Non-templated base class for templated Array class.
Definition ArrayBase.h:71
OpenOption
Define the possible ByteIO open options.
Definition ByteIO.h:63
StIndArray * putArrayPtr(rownr_t rownr, const IPosition &shape, Bool copyData)
When needed, create an array in the given row with the given shape.
Bool shapeIsFixed_p
Switch indicating if the shape is fixed.
virtual void getSliceV(rownr_t rownr, const Slicer &, ArrayBase &)
Get a section of the array in the given row.
virtual void putSliceV(rownr_t rownr, const Slicer &, const ArrayBase &)
Put into a section of the array in the given row.
virtual void putArrayV(rownr_t rownr, const ArrayBase &)
Put an array value into the given row.
virtual Bool flush(rownr_t nrrow, Bool fsync)
Flush and optionally fsync the data.
virtual uInt ndim(rownr_t rownr)
Get the dimensionality of the item in the given row.
virtual void handleRemove(rownr_t rownr, const char *value)
Handle the removal of a value; i.e.
virtual void addRow(rownr_t newNrrow, rownr_t oldNrrow)
Add (newNrrow-oldNrrow) rows to the column.
virtual Bool isShapeDefined(rownr_t rownr)
Is the shape defined (i.e.
virtual void reopenRW()
Let the column reopen its data files for read/write access.
virtual void doCreate(ISMBucket *bucket)
Let the column object create its array file.
virtual void handleCopy(rownr_t rownr, const char *value)
Handle the duplication of a value; i.e.
ISMIndColumn(ISMBase *parent, int dataType, uInt colnr)
Create a column of the given data type.
virtual void resync(rownr_t nrrow)
Resync the storage manager with the new file contents.
virtual Bool canChangeShape() const
This storage manager can handle changing array shapes.
virtual Bool compareValue(const void *val1, const void *val2) const
Compare the values to check if a value to be put matches the value in the previous or next row.
virtual void setShapeColumn(const IPosition &shape)
Set the (fixed) shape of the arrays in the entire column.
virtual void getFile(rownr_t nrrow)
Let the column object open an existing file.
virtual void getArrayV(rownr_t rownr, ArrayBase &)
Get an array value in the given row.
ISMIndColumn & operator=(const ISMIndColumn &)=delete
Forbid assignment.
StIndArray * putShape(rownr_t rownr, const IPosition &shape)
Put the shape for an array being put.
uInt seqnr_p
The (unique) sequence number of the column.
StIndArray * getShape(rownr_t rownr)
Read the shape at the given row.
StManArrayFile * iosfile_p
The file containing the arrays.
StIndArray indArray_p
The indirect array object.
void init(ByteIO::OpenOption fileOption)
Initialize part of the object and open/create the file.
virtual IPosition shape(rownr_t rownr)
Get the shape of the array in the given row.
ISMIndColumn(const ISMIndColumn &)=delete
Forbid copy constructor.
StIndArray * putShapeSliced(rownr_t rownr)
Put the shape for an array of which a slice is being put.
void clear()
Clear the object (used by destructor and init).
IPosition fixedShape_p
The shape of all arrays in case it is fixed.
StIndArray * getArrayPtr(rownr_t rownr)
Return a pointer to the array in the given row (for a get).
virtual void setShape(rownr_t rownr, const IPosition &shape)
Set the shape of the array in the given row and allocate the array in the file.
Bool foundArray_p
The indirect array exists for the row interval last accessed.
virtual ~ISMIndColumn()
Frees up the storage.
virtual int dataType() const
Return the data type of the column.
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44