casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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  virtual ~ISMIndColumn();
109 
110  // Add (newNrrow-oldNrrow) rows to the column.
111  virtual void addRow (rownr_t newNrrow, rownr_t oldNrrow);
112 
113  // Set the (fixed) shape of the arrays in the entire column.
114  virtual void setShapeColumn (const IPosition& shape);
115 
116  // Get the dimensionality of the item in the given row.
117  virtual uInt ndim (rownr_t rownr);
118 
119  // Set the shape of the array in the given row and allocate the array
120  // in the file.
121  virtual void setShape (rownr_t rownr, const IPosition& shape);
122 
123  // Is the shape defined (i.e. is there an array) in this row?
124  virtual Bool isShapeDefined (rownr_t rownr);
125 
126  // Get the shape of the array in the given row.
127  virtual IPosition shape (rownr_t rownr);
128 
129  // This storage manager can handle changing array shapes.
130  virtual Bool canChangeShape() const;
131 
132  // Get an array value in the given row.
133  // The buffer pointed to by dataPtr has to have the correct length
134  // (which is guaranteed by the ArrayColumn get function).
135  virtual void getArrayV (rownr_t rownr, ArrayBase&);
136 
137  // Put an array value into the given row.
138  // The buffer pointed to by dataPtr has to have the correct length
139  // (which is guaranteed by the ArrayColumn put function).
140  virtual void putArrayV (rownr_t rownr, const ArrayBase&);
141 
142  // Get a section of the array in the given row.
143  // The array has to have the correct length
144  // (which is guaranteed by the ArrayColumn getSlice function).
145  virtual void getSliceV (rownr_t rownr, const Slicer&, ArrayBase&);
146 
147  // Put into a section of the array in the given row.
148  // The array has to have the correct length
149  // (which is guaranteed by the ArrayColumn putSlice function).
150  virtual void putSliceV (rownr_t rownr, const Slicer&, const ArrayBase&);
151 
152  // Let the column object create its array file.
153  virtual void doCreate (ISMBucket* bucket);
154 
155  // Let the column object open an existing file.
156  virtual void getFile (rownr_t nrrow);
157 
158  // Flush and optionally fsync the data.
159  virtual Bool flush (rownr_t nrrow, Bool fsync);
160 
161  // Resync the storage manager with the new file contents.
162  virtual void resync (rownr_t nrrow);
163 
164  // Let the column reopen its data files for read/write access.
165  virtual void reopenRW();
166 
167  // Handle the duplication of a value; i.e. increment its reference count.
168  virtual void handleCopy (rownr_t rownr, const char* value);
169 
170  // Handle the removal of a value; i.e. decrement its reference count.
171  virtual void handleRemove (rownr_t rownr, const char* value);
172 
173 private:
174  // Forbid copy constructor.
175  ISMIndColumn (const ISMIndColumn&);
176 
177  // Forbid assignment.
179 
180  // Initialize part of the object and open/create the file.
181  // It is used by doCreate and getFile.
182  void init (ByteIO::OpenOption fileOption);
183 
184  // Clear the object (used by destructor and init).
185  void clear();
186 
187  // Compare the values to check if a value to be put matches the
188  // value in the previous or next row.
189  // It always return False, because comparing large arrays is
190  // too expensive (it could be changed in the future).
191  virtual Bool compareValue (const void* val1, const void* val2) const;
192 
193  // Read the shape at the given row.
194  // This will cache the information in the StIndArray
195  // object for that row.
196  StIndArray* getShape (rownr_t rownr);
197 
198  // Put the shape for an array being put.
199  // When there are multiple rows in the interval, it will
200  // split the interval.
201  StIndArray* putShape (rownr_t rownr, const IPosition& shape);
202 
203  // Put the shape for an array of which a slice is being put.
204  // It gets the shape for the given row.
205  // When there are multiple rows in the interval, it will
206  // split the interval and copy the data.
208 
209  // Return a pointer to the array in the given row (for a get).
210  StIndArray* getArrayPtr (rownr_t rownr);
211 
212  // When needed, create an array in the given row with the given shape.
213  // When the array is created, its data are copied when the flag is set.
214  StIndArray* putArrayPtr (rownr_t rownr, const IPosition& shape,
215  Bool copyData);
216 
217 
218  // The (unique) sequence number of the column.
220  // The shape of all arrays in case it is fixed.
222  // Switch indicating if the shape is fixed.
224  // The file containing the arrays.
226  // The indirect array object.
228  // The indirect array exists for the row interval last accessed.
230 };
231 
232 
233 
234 
235 } //# NAMESPACE CASACORE - END
236 
237 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
StIndArray indArray_p
The indirect array object.
Definition: ISMIndColumn.h:227
Non-templated base class for templated Array class.
Definition: ArrayBase.h:72
StManArrayFile * iosfile_p
The file containing the arrays.
Definition: ISMIndColumn.h:225
ISMIndColumn & operator=(const ISMIndColumn &)
Forbid assignment.
StIndArray * getArrayPtr(rownr_t rownr)
Return a pointer to the array in the given row (for a get).
void clear()
Clear the object (used by destructor and init).
virtual void reopenRW()
Let the column reopen its data files for read/write access.
Read/write indirect arrays.
Definition: StIndArray.h:141
virtual void getArrayV(rownr_t rownr, ArrayBase &)
Get an array value in the given row.
void init()
Initialize part of the object.
StIndArray * putArrayPtr(rownr_t rownr, const IPosition &shape, Bool copyData)
When needed, create an array in the given row with the given shape.
Base class of the Incremental Storage Manager.
Definition: ISMBase.h:87
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 addRow(rownr_t newNrrow, rownr_t oldNrrow)
Add (newNrrow-oldNrrow) rows to the column.
StIndArray * putShape(rownr_t rownr, const IPosition &shape)
Put the shape for an array being put.
virtual Bool canChangeShape() const
This storage manager can handle changing array shapes.
virtual uInt ndim(rownr_t rownr)
Get the dimensionality of the item in the given row.
virtual void setShapeColumn(const IPosition &shape)
Set the (fixed) shape of the arrays in the entire column.
virtual int dataType() const
Return the data type of the column.
A column of Incremental storage manager for indirect arrays.
Definition: ISMIndColumn.h:99
ISMIndColumn(ISMBase *parent, int dataType, uInt colnr)
Create a column of the given data type.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void getSliceV(rownr_t rownr, const Slicer &, ArrayBase &)
Get a section of the array in the given row.
virtual IPosition shape(rownr_t rownr)
Get the shape of the array in the given row.
IPosition fixedShape_p
The shape of all arrays in case it is fixed.
Definition: ISMIndColumn.h:221
A Column in the Incremental Storage Manager.
Definition: ISMColumn.h:115
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:288
virtual Bool isShapeDefined(rownr_t rownr)
Is the shape defined (i.e.
A bucket in the Incremental Storage Manager.
Definition: ISMBucket.h:132
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
virtual void handleCopy(rownr_t rownr, const char *value)
Handle the duplication of a value; i.e.
OpenOption
Define the possible ByteIO open options.
Definition: ByteIO.h:65
StIndArray * putShapeSliced(rownr_t rownr)
Put the shape for an array of which a slice is being put.
uInt seqnr_p
The (unique) sequence number of the column.
Definition: ISMIndColumn.h:219
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.
Definition: ISMIndColumn.h:229
StIndArray * getShape(rownr_t rownr)
Read the shape at the given row.
virtual void handleRemove(rownr_t rownr, const char *value)
Handle the removal of a value; i.e.
Bool shapeIsFixed_p
Switch indicating if the shape is fixed.
Definition: ISMIndColumn.h:223
virtual void doCreate(ISMBucket *bucket)
Let the column object create its array file.
Read/write array in external format for a storage manager.
Definition: StArrayFile.h:129
virtual void putSliceV(rownr_t rownr, const Slicer &, const ArrayBase &)
Put into a section of the array in the given row.
virtual void getFile(rownr_t nrrow)
Let the column object open an existing file.
virtual Bool flush(rownr_t nrrow, Bool fsync)
Flush and optionally fsync the data.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
virtual void resync(rownr_t nrrow)
Resync the storage manager with the new file contents.
virtual ~ISMIndColumn()
Frees up the storage.
unsigned int uInt
Definition: aipstype.h:51
virtual void putArrayV(rownr_t rownr, const ArrayBase &)
Put an array value into the given row.