casacore
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: 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_ISMINDCOLUMN_H
29 #define TABLES_ISMINDCOLUMN_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/DataMan/ISMColumn.h>
35 #include <casacore/tables/DataMan/StIndArray.h>
36 #include <casacore/casa/Arrays/IPosition.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class StManArrayFile;
42 class AipsIO;
43 
44 
45 // <summary>
46 // A column of Incremental storage manager for indirect arrays.
47 // </summary>
48 
49 // <use visibility=local>
50 
51 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
52 // </reviewed>
53 
54 // <prerequisite>
55 //# Classes you should understand before using this one.
56 // <li> <linkto class=ISMColumn>ISMColumn</linkto>
57 // <li> <linkto class=StIndArray>StIndArray</linkto>
58 // </prerequisite>
59 
60 // <etymology>
61 // ISMIndColumn represents a Column in the Incremental Storage Manager
62 // containing INDirect arrays.
63 // </etymology>
64 
65 // <synopsis>
66 // ISMIndColumn is the implementation of an
67 // <linkto class=ISMColumn>ISMColumn</linkto> class
68 // to handle indirect arrays. The arrays (shape and data) are stored in
69 // a separate file using class <linkto class=StIndArray>StIndArray</linkto>.
70 // The file offset of the beginning of the array in stored in the
71 // ISM using the standard ISMColumn functions.
72 // <p>
73 // ISMIndColumn contains functions which are called when ISMColumn
74 // duplicates or removes a value. In that way the array can also be
75 // duplicated or removed in the StIndArray file by incrementing or
76 // decrementing the reference count manitained in the file.
77 // <p>
78 // Unlike ISMColumn it is not tested if a value put is equal to
79 // the value in the previous or next row, because it is too time-consuming
80 // to do so (although this behaviour could be changed in the future).
81 // Instead the user should not put equal values to prevent storing
82 // equal values.
83 // <p>
84 // Note that an indirect array can have a fixed shape. In that case
85 // adding a row results in reserving space for the array in the StIndArray
86 // file, so for each row an array is present.
87 // On the other hand adding a row does nothing for variable shaped arrays.
88 // So when no data is put or shape is set, a row may contain no array at all.
89 // In that case the function <src>isShapeDefined</src> returns False for
90 // that row.
91 // </synopsis>
92 
93 // <todo asof="$DATE:$">
94 //# A List of bugs, limitations, extensions or planned refinements.
95 // <li> Maybe TpArrayInt, etc. should be used instead of TpInt.
96 // </todo>
97 
98 
99 class ISMIndColumn : public ISMColumn
100 {
101 public:
102 
103  // Create a column of the given data type.
104  // It keeps the pointer to its parent (but does not own it).
105  ISMIndColumn (ISMBase* parent, int dataType, uInt colnr);
106 
107  // Frees up the storage.
108  ~ISMIndColumn();
109 
110  // It can handle access to a slice in a cell.
111  virtual Bool canAccessSlice (Bool& reask) const;
112 
113  // Add (newNrrow-oldNrrow) rows to the column.
114  virtual void addRow (uInt newNrrow, uInt oldNrrow);
115 
116  // Set the (fixed) shape of the arrays in the entire column.
117  virtual void setShapeColumn (const IPosition& shape);
118 
119  // Get the dimensionality of the item in the given row.
120  virtual uInt ndim (uInt rownr);
121 
122  // Set the shape of the array in the given row and allocate the array
123  // in the file.
124  void setShape (uInt rownr, const IPosition& shape);
125 
126  // Is the shape defined (i.e. is there an array) in this row?
127  virtual Bool isShapeDefined (uInt rownr);
128 
129  // Get the shape of the array in the given row.
130  virtual IPosition shape (uInt rownr);
131 
132  // This storage manager can handle changing array shapes.
133  Bool canChangeShape() const;
134 
135  // Get an array value in the given row.
136  // The buffer pointed to by dataPtr has to have the correct length
137  // (which is guaranteed by the ArrayColumn get function).
138  // <group>
139  virtual void getArrayBoolV (uInt rownr, Array<Bool>* dataPtr);
140  virtual void getArrayuCharV (uInt rownr, Array<uChar>* dataPtr);
141  virtual void getArrayShortV (uInt rownr, Array<Short>* dataPtr);
142  virtual void getArrayuShortV (uInt rownr, Array<uShort>* dataPtr);
143  virtual void getArrayIntV (uInt rownr, Array<Int>* dataPtr);
144  virtual void getArrayuIntV (uInt rownr, Array<uInt>* dataPtr);
145  virtual void getArrayInt64V (uInt rownr, Array<Int64>* dataPtr);
146  virtual void getArrayfloatV (uInt rownr, Array<float>* dataPtr);
147  virtual void getArraydoubleV (uInt rownr, Array<double>* dataPtr);
148  virtual void getArrayComplexV (uInt rownr, Array<Complex>* dataPtr);
149  virtual void getArrayDComplexV (uInt rownr, Array<DComplex>* dataPtr);
150  virtual void getArrayStringV (uInt rownr, Array<String>* dataPtr);
151  // </group>
152 
153  // Put an array value into the given row.
154  // The buffer pointed to by dataPtr has to have the correct length
155  // (which is guaranteed by the ArrayColumn put function).
156  // <group>
157  virtual void putArrayBoolV (uInt rownr, const Array<Bool>* dataPtr);
158  virtual void putArrayuCharV (uInt rownr, const Array<uChar>* dataPtr);
159  virtual void putArrayShortV (uInt rownr, const Array<Short>* dataPtr);
160  virtual void putArrayuShortV (uInt rownr, const Array<uShort>* dataPtr);
161  virtual void putArrayIntV (uInt rownr, const Array<Int>* dataPtr);
162  virtual void putArrayuIntV (uInt rownr, const Array<uInt>* dataPtr);
163  virtual void putArrayInt64V (uInt rownr, const Array<Int64>* dataPtr);
164  virtual void putArrayfloatV (uInt rownr, const Array<float>* dataPtr);
165  virtual void putArraydoubleV (uInt rownr, const Array<double>* dataPtr);
166  virtual void putArrayComplexV (uInt rownr, const Array<Complex>* dataPtr);
167  virtual void putArrayDComplexV (uInt rownr, const Array<DComplex>* dataPtr);
168  virtual void putArrayStringV (uInt rownr, const Array<String>* dataPtr);
169  // </group>
170 
171  // Get a section of the array in the given row.
172  // The buffer pointed to by dataPtr has to have the correct length
173  // (which is guaranteed by the ArrayColumn getSlice function).
174  // <group>
175  virtual void getSliceBoolV (uInt rownr, const Slicer&,
176  Array<Bool>* dataPtr);
177  virtual void getSliceuCharV (uInt rownr, const Slicer&,
178  Array<uChar>* dataPtr);
179  virtual void getSliceShortV (uInt rownr, const Slicer&,
180  Array<Short>* dataPtr);
181  virtual void getSliceuShortV (uInt rownr, const Slicer&,
182  Array<uShort>* dataPtr);
183  virtual void getSliceIntV (uInt rownr, const Slicer&,
184  Array<Int>* dataPtr);
185  virtual void getSliceuIntV (uInt rownr, const Slicer&,
186  Array<uInt>* dataPtr);
187  virtual void getSliceInt64V (uInt rownr, const Slicer&,
188  Array<Int64>* dataPtr);
189  virtual void getSlicefloatV (uInt rownr, const Slicer&,
190  Array<float>* dataPtr);
191  virtual void getSlicedoubleV (uInt rownr, const Slicer&,
192  Array<double>* dataPtr);
193  virtual void getSliceComplexV (uInt rownr, const Slicer&,
194  Array<Complex>* dataPtr);
195  virtual void getSliceDComplexV (uInt rownr, const Slicer&,
196  Array<DComplex>* dataPtr);
197  virtual void getSliceStringV (uInt rownr, const Slicer&,
198  Array<String>* dataPtr);
199  // </group>
200 
201  // Put into a section of the array in the given row.
202  // The buffer pointed to by dataPtr has to have the correct length
203  // (which is guaranteed by the ArrayColumn putSlice function).
204  // <group>
205  virtual void putSliceBoolV (uInt rownr, const Slicer&,
206  const Array<Bool>* dataPtr);
207  virtual void putSliceuCharV (uInt rownr, const Slicer&,
208  const Array<uChar>* dataPtr);
209  virtual void putSliceShortV (uInt rownr, const Slicer&,
210  const Array<Short>* dataPtr);
211  virtual void putSliceuShortV (uInt rownr, const Slicer&,
212  const Array<uShort>* dataPtr);
213  virtual void putSliceIntV (uInt rownr, const Slicer&,
214  const Array<Int>* dataPtr);
215  virtual void putSliceuIntV (uInt rownr, const Slicer&,
216  const Array<uInt>* dataPtr);
217  virtual void putSliceInt64V (uInt rownr, const Slicer&,
218  const Array<Int64>* dataPtr);
219  virtual void putSlicefloatV (uInt rownr, const Slicer&,
220  const Array<float>* dataPtr);
221  virtual void putSlicedoubleV (uInt rownr, const Slicer&,
222  const Array<double>* dataPtr);
223  virtual void putSliceComplexV (uInt rownr, const Slicer&,
224  const Array<Complex>* dataPtr);
225  virtual void putSliceDComplexV (uInt rownr, const Slicer&,
226  const Array<DComplex>* dataPtr);
227  virtual void putSliceStringV (uInt rownr, const Slicer&,
228  const Array<String>* dataPtr);
229  // </group>
230 
231  // Let the column object create its array file.
232  virtual void doCreate (ISMBucket* bucket);
233 
234  // Let the column object open an existing file.
235  virtual void getFile (uInt nrrow);
236 
237  // Flush and optionally fsync the data.
238  virtual Bool flush (uInt nrrow, Bool fsync);
239 
240  // Resync the storage manager with the new file contents.
241  virtual void resync (uInt nrrow);
242 
243  // Let the column reopen its data files for read/write access.
244  virtual void reopenRW();
245 
246  // Handle the duplication of a value; i.e. increment its reference count.
247  virtual void handleCopy (uInt rownr, const char* value);
248 
249  // Handle the removal of a value; i.e. decrement its reference count.
250  virtual void handleRemove (uInt rownr, const char* value);
251 
252 private:
253  // Forbid copy constructor.
254  ISMIndColumn (const ISMIndColumn&);
255 
256  // Forbid assignment.
258 
259  // Initialize part of the object and open/create the file.
260  // It is used by doCreate and getFile.
261  void init (ByteIO::OpenOption fileOption);
262 
263  // Clear the object (used by destructor and init).
264  void clear();
265 
266  // Compare the values to check if a value to be put matches the
267  // value in the previous or next row.
268  // It always return False, because comparing large arrays is
269  // too expensive (it could be changed in the future).
270  virtual Bool compareValue (const void* val1, const void* val2) const;
271 
272  // Read the shape at the given row.
273  // This will cache the information in the StIndArray
274  // object for that row.
275  StIndArray* getShape (uInt rownr);
276 
277  // Put the shape for an array being put.
278  // When there are multiple rows in the interval, it will
279  // split the interval.
280  StIndArray* putShape (uInt rownr, const IPosition& shape);
281 
282  // Put the shape for an array of which a slice is being put.
283  // It gets the shape for the given row.
284  // When there are multiple rows in the interval, it will
285  // split the interval and copy the data.
286  StIndArray* putShapeSliced (uInt rownr);
287 
288  // Return a pointer to the array in the given row (for a get).
289  StIndArray* getArrayPtr (uInt rownr);
290 
291  // When needed, create an array in the given row with the given shape.
292  // When the array is created, its data are copied when the flag is set.
293  StIndArray* putArrayPtr (uInt rownr, const IPosition& shape,
294  Bool copyData);
295 
296 
297  // The (unique) sequence number of the column.
299  // The shape of all arrays in case it is fixed.
301  // Switch indicating if the shape is fixed.
303  // The file containing the arrays.
305  // The indirect array object.
307  // The indirect array exists for the row interval last accessed.
309 };
310 
311 
312 
313 
314 } //# NAMESPACE CASACORE - END
315 
316 #endif
virtual void getSliceDComplexV(uInt rownr, const Slicer &, Array< DComplex > *dataPtr)
virtual void putSliceInt64V(uInt rownr, const Slicer &, const Array< Int64 > *dataPtr)
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
virtual void getArrayuShortV(uInt rownr, Array< uShort > *dataPtr)
virtual void putArrayShortV(uInt rownr, const Array< Short > *dataPtr)
StIndArray * getArrayPtr(uInt rownr)
Return a pointer to the array in the given row (for a get).
StIndArray indArray_p
The indirect array object.
Definition: ISMIndColumn.h:306
virtual void getSlicefloatV(uInt rownr, const Slicer &, Array< float > *dataPtr)
virtual void getArrayDComplexV(uInt rownr, Array< DComplex > *dataPtr)
virtual void putArrayIntV(uInt rownr, const Array< Int > *dataPtr)
StManArrayFile * iosfile_p
The file containing the arrays.
Definition: ISMIndColumn.h:304
virtual void putSlicefloatV(uInt rownr, const Slicer &, const Array< float > *dataPtr)
ISMIndColumn & operator=(const ISMIndColumn &)
Forbid assignment.
virtual void addRow(uInt newNrrow, uInt oldNrrow)
Add (newNrrow-oldNrrow) rows to the column.
virtual void getSlicedoubleV(uInt rownr, const Slicer &, Array< double > *dataPtr)
void clear()
Clear the object (used by destructor and init).
virtual void reopenRW()
Let the column reopen its data files for read/write access.
virtual void putSliceuIntV(uInt rownr, const Slicer &, const Array< uInt > *dataPtr)
virtual Bool isShapeDefined(uInt rownr)
Is the shape defined (i.e.
virtual void getSliceuIntV(uInt rownr, const Slicer &, Array< uInt > *dataPtr)
virtual void getSliceComplexV(uInt rownr, const Slicer &, Array< Complex > *dataPtr)
Read/write indirect arrays.
Definition: StIndArray.h:141
virtual void handleRemove(uInt rownr, const char *value)
Handle the removal of a value; i.e.
virtual void getFile(uInt nrrow)
Let the column object open an existing file.
virtual void putArraydoubleV(uInt rownr, const Array< double > *dataPtr)
virtual void putSliceBoolV(uInt rownr, const Slicer &, const Array< Bool > *dataPtr)
Put into a section of the array in the given row.
virtual void getArrayStringV(uInt rownr, Array< String > *dataPtr)
virtual void putArrayfloatV(uInt rownr, const Array< float > *dataPtr)
void init()
Initialize part of the object.
StIndArray * getShape(uInt rownr)
Read the shape at the given row.
virtual void putArrayStringV(uInt rownr, const Array< String > *dataPtr)
virtual void getArrayfloatV(uInt rownr, Array< float > *dataPtr)
virtual void getSliceIntV(uInt rownr, const Slicer &, Array< Int > *dataPtr)
virtual void putArrayDComplexV(uInt rownr, const Array< DComplex > *dataPtr)
virtual uInt ndim(uInt rownr)
Get the dimensionality of the item in the given row.
int dataType() const
Return the data type of the column.
virtual void getSliceuCharV(uInt rownr, const Slicer &, Array< uChar > *dataPtr)
void setShape(uInt rownr, const IPosition &shape)
Set the shape of the array in the given row and allocate the array in the file.
Base class of the Incremental Storage Manager.
Definition: ISMBase.h:87
virtual void getSliceStringV(uInt rownr, const Slicer &, Array< String > *dataPtr)
virtual void putArrayuIntV(uInt rownr, const Array< uInt > *dataPtr)
virtual void putArrayBoolV(uInt rownr, const Array< Bool > *dataPtr)
Put an array value into the given row.
virtual void getArrayuCharV(uInt rownr, Array< uChar > *dataPtr)
virtual void getArrayInt64V(uInt rownr, Array< Int64 > *dataPtr)
virtual void getArraydoubleV(uInt rownr, Array< double > *dataPtr)
virtual void putArrayComplexV(uInt rownr, const Array< Complex > *dataPtr)
virtual void putArrayInt64V(uInt rownr, const Array< Int64 > *dataPtr)
virtual void getSliceShortV(uInt rownr, const Slicer &, Array< Short > *dataPtr)
virtual void putSliceStringV(uInt rownr, const Slicer &, const Array< String > *dataPtr)
virtual void putSlicedoubleV(uInt rownr, const Slicer &, const Array< double > *dataPtr)
StIndArray * putArrayPtr(uInt rownr, const IPosition &shape, Bool copyData)
When needed, create an array in the given row with the given shape.
virtual void getArrayIntV(uInt rownr, Array< Int > *dataPtr)
virtual void putArrayuShortV(uInt rownr, const Array< uShort > *dataPtr)
virtual void putSliceComplexV(uInt rownr, const Slicer &, const Array< Complex > *dataPtr)
virtual void setShapeColumn(const IPosition &shape)
Set the (fixed) shape of the arrays in the entire column.
virtual void getArrayuIntV(uInt rownr, Array< uInt > *dataPtr)
A column of Incremental storage manager for indirect arrays.
Definition: ISMIndColumn.h:99
virtual void resync(uInt nrrow)
Resync the storage manager with the new file contents.
ISMIndColumn(ISMBase *parent, int dataType, uInt colnr)
Create a column of the given data type.
virtual void getSliceBoolV(uInt rownr, const Slicer &, Array< Bool > *dataPtr)
Get a section of the array in the given row.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
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 putSliceShortV(uInt rownr, const Slicer &, const Array< Short > *dataPtr)
StIndArray * putShape(uInt rownr, const IPosition &shape)
Put the shape for an array being put.
virtual void getArrayBoolV(uInt rownr, Array< Bool > *dataPtr)
Get an array value in the given row.
~ISMIndColumn()
Frees up the storage.
virtual void putArrayuCharV(uInt rownr, const Array< uChar > *dataPtr)
virtual void putSliceuShortV(uInt rownr, const Slicer &, const Array< uShort > *dataPtr)
IPosition fixedShape_p
The shape of all arrays in case it is fixed.
Definition: ISMIndColumn.h:300
virtual void putSliceIntV(uInt rownr, const Slicer &, const Array< Int > *dataPtr)
A Column in the Incremental Storage Manager.
Definition: ISMColumn.h:115
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
virtual Bool canAccessSlice(Bool &reask) const
It can handle access to a slice in a cell.
virtual void getArrayShortV(uInt rownr, Array< Short > *dataPtr)
A bucket in the Incremental Storage Manager.
Definition: ISMBucket.h:132
OpenOption
Define the possible ByteIO open options.
Definition: ByteIO.h:65
virtual void getArrayComplexV(uInt rownr, Array< Complex > *dataPtr)
uInt seqnr_p
The (unique) sequence number of the column.
Definition: ISMIndColumn.h:298
virtual void handleCopy(uInt rownr, const char *value)
Handle the duplication of a value; i.e.
Bool canChangeShape() const
This storage manager can handle changing array shapes.
Bool foundArray_p
The indirect array exists for the row interval last accessed.
Definition: ISMIndColumn.h:308
virtual void getSliceInt64V(uInt rownr, const Slicer &, Array< Int64 > *dataPtr)
Bool shapeIsFixed_p
Switch indicating if the shape is fixed.
Definition: ISMIndColumn.h:302
virtual void doCreate(ISMBucket *bucket)
Let the column object create its array file.
virtual void putSliceDComplexV(uInt rownr, const Slicer &, const Array< DComplex > *dataPtr)
Read/write array in external format for a storage manager.
Definition: StArrayFile.h:129
virtual IPosition shape(uInt rownr)
Get the shape of the array in the given row.
StIndArray * putShapeSliced(uInt rownr)
Put the shape for an array of which a slice is being put.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
virtual void getSliceuShortV(uInt rownr, const Slicer &, Array< uShort > *dataPtr)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
virtual void putSliceuCharV(uInt rownr, const Slicer &, const Array< uChar > *dataPtr)
unsigned int uInt
Definition: aipstype.h:51
virtual Bool flush(uInt nrrow, Bool fsync)
Flush and optionally fsync the data.