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