casacore
Loading...
Searching...
No Matches
TSMDataColumn.h
Go to the documentation of this file.
1// # TSMDataColumn.h: A data column in Tiled Storage Manager
2// # Copyright (C) 1995,1996,1997,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_TSMDATACOLUMN_H
27#define TABLES_TSMDATACOLUMN_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/DataMan/TSMColumn.h>
32#include <casacore/tables/DataMan/TSMCube.h>
33#include <casacore/casa/BasicSL/Complex.h>
34#include <casacore/casa/Arrays/IPosition.h>
35#include <casacore/casa/BasicSL/String.h>
36#include <casacore/casa/OS/Conversion.h>
37
38namespace casacore { // # NAMESPACE CASACORE - BEGIN
39
40// # Forward Declarations
41class Slicer;
42
43// <summary>
44// A data column in Tiled Storage Manager.
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=TSMColumn>TSMColumn</linkto>
55// <li> <linkto class=TSMCube>TSMCube</linkto>
56// </prerequisite>
57
58// <etymology>
59// TSMDataColumn handles a data column for a Tiled
60// Storage Manager.
61// </etymology>
62
63// <synopsis>
64// TSMDataColumn is used by
65// <linkto class=TiledStMan>TiledStMan</linkto>
66// to handle the access to
67// a table column containing data of a tiled hypercube axis.
68// The data in a cell can be a scalar or an array (depending on its
69// definition in the table column description).
70// The shapes of the coordinates and the data are related. Therefore
71// the function setShape checks if the data shape matches the coordinates
72// shape.
73// <p>
74// The data are held in a TSMCube object. The row number
75// determines which TSMCube object has to be accessed.
76// <p>
77// The creation of a TSMDataColumn object is done by a TSMColumn object.
78// This process is described in more detail in the class
79// <linkto class=TSMColumn>TSMColumn</linkto>.
80// </synopsis>
81
82// <motivation>
83// Handling data columns in the Tiled Storage Manager is
84// different from other columns.
85// </motivation>
86
87// # <todo asof="$DATE:$">
88// # A List of bugs, limitations, extensions or planned refinements.
89// # </todo>
90
91class TSMDataColumn : public TSMColumn {
92 public:
93 // Create a data column from the given column.
94 TSMDataColumn(const TSMColumn& column);
95
96 // Frees up the storage.
97 virtual ~TSMDataColumn();
98
99 // Forbid copy constructor.
100 TSMDataColumn(const TSMDataColumn&) = delete;
101
102 // Forbid assignment.
104
105 // Return the size of a pixel in the tile in external format.
106 uInt tilePixelSize() const;
107
108 // Return the size of a pixel in the tile in local format.
109 uInt localPixelSize() const;
110
111 // Determine the length to store the given number of pixels.
112 uInt64 dataLength(uInt64 nrPixels) const;
113
114 // Set column sequence number.
115 void setColumnNumber(uInt colnr);
116
117 // Changing array shapes for non-FixedShape columns when the
118 // parent tiled storage manager can handle it.
120
121 // Set the shape of the data array in the given row.
122 // It will check if it matches already defined data and coordinates shapes.
123 // It will define undefined data and coordinates shapes.
124 void setShape(rownr_t rownr, const IPosition& shape);
125
126 // Set the shape and tile shape of the array in the given row.
127 // It will check if it matches already defined data and coordinates shapes.
128 // It will define undefined data and coordinates shapes.
129 // The tile shape is adjusted to the array shape (size 0 gets set to 1;
130 // size > cubesize gets set to the cubesize).
132
133 // Is the value shape defined in the given row?
135
136 // Get the shape of the item in the given row.
138
139 // Get the tile shape of the item in the given row.
141
142 // Get a scalar value in the given row.
143 // The buffer pointed to by dataPtr has to have the correct length
144 // (which is guaranteed by the Scalar/ArrayColumn get function).
145 // <group>
146 virtual void getBool(rownr_t rownr, Bool* dataPtr);
147 virtual void getuChar(rownr_t rownr, uChar* dataPtr);
148 virtual void getShort(rownr_t rownr, Short* dataPtr);
149 virtual void getuShort(rownr_t rownr, uShort* dataPtr);
150 virtual void getInt(rownr_t rownr, Int* dataPtr);
151 virtual void getuInt(rownr_t rownr, uInt* dataPtr);
152 virtual void getInt64(rownr_t rownr, Int64* dataPtr);
153 virtual void getfloat(rownr_t rownr, float* dataPtr);
154 virtual void getdouble(rownr_t rownr, double* dataPtr);
155 virtual void getComplex(rownr_t rownr, Complex* dataPtr);
156 virtual void getDComplex(rownr_t rownr, DComplex* dataPtr);
157 // </group>
158
159 // Put a scalar value into the given row.
160 // The buffer pointed to by dataPtr has to have the correct length
161 // (which is guaranteed by the Scalar/ArrayColumn put function).
162 // <group>
163 virtual void putBool(rownr_t rownr, const Bool* dataPtr);
164 virtual void putuChar(rownr_t rownr, const uChar* dataPtr);
165 virtual void putShort(rownr_t rownr, const Short* dataPtr);
166 virtual void putuShort(rownr_t rownr, const uShort* dataPtr);
167 virtual void putInt(rownr_t rownr, const Int* dataPtr);
168 virtual void putuInt(rownr_t rownr, const uInt* dataPtr);
169 virtual void putInt64(rownr_t rownr, const Int64* dataPtr);
170 virtual void putfloat(rownr_t rownr, const float* dataPtr);
171 virtual void putdouble(rownr_t rownr, const double* dataPtr);
172 virtual void putComplex(rownr_t rownr, const Complex* dataPtr);
173 virtual void putDComplex(rownr_t rownr, const DComplex* dataPtr);
174 // </group>
175
176 // Get the array value in the given row.
177 // The array given in <src>data</src> has to have the correct shape
178 // (which is guaranteed by the ArrayColumn get function).
179 virtual void getArrayV(rownr_t rownr, ArrayBase& data);
180
181 // Put the array value into the given row.
182 // The array given in <src>data</src> has to have the correct shape
183 // (which is guaranteed by the ArrayColumn put function).
184 virtual void putArrayV(rownr_t rownr, const ArrayBase& data);
185
186 // Get into a section of the array in the given row.
187 // The array given in <src>data</src> has to have the correct shape
188 // (which is guaranteed by the ArrayColumn putSlice function).
189 virtual void getSliceV(rownr_t rownr, const Slicer& slicer, ArrayBase& dataPtr);
190
191 // Put into a section of the array in the given row.
192 // The array given in <src>data</src> has to have the correct shape
193 // (which is guaranteed by the ArrayColumn putSlice function).
194 virtual void putSliceV(rownr_t rownr, const Slicer& slicer, const ArrayBase& data);
195
196 // Get all array values in the column.
197 // The array given in <src>data</src> has to have the correct shape
198 // (which is guaranteed by the ArrayColumn getColumn function).
199 virtual void getArrayColumnV(ArrayBase& arr);
200
201 // Put all array values in the column.
202 // The array given in <src>data</src> has to have the correct shape
203 // (which is guaranteed by the ArrayColumn getColumn function).
204 virtual void putArrayColumnV(const ArrayBase& arr);
205
206 // Get the array values in some cells of the column.
207 // The array given in <src>data</src> has to have the correct shape
208 // (which is guaranteed by the ArrayColumn getColumnCells function).
209 virtual void getArrayColumnCellsV(const RefRows& rownrs, ArrayBase& data);
210
211 // Put the array values into some cells of the column.
212 // The array given in <src>data</src> has to have the correct shape
213 // (which is guaranteed by the ArrayColumn getColumn function).
214 virtual void putArrayColumnCellsV(const RefRows& rownrs, const ArrayBase& dataPtr);
215
216 // Get a section of all arrays in the column.
217 // The array given in <src>data</src> has to have the correct shape
218 // (which is guaranteed by the ArrayColumn getColumn function).
219 virtual void getColumnSliceV(const Slicer& slicer, ArrayBase& arr);
220
221 // Put a section into all array values in the column.
222 // The array given in <src>data</src> has to have the correct shape
223 // (which is guaranteed by the ArrayColumn getColumn function).
224 virtual void putColumnSliceV(const Slicer& slicer, const ArrayBase& data);
225
226 // Get a section from some cells of the column.
227 // The array given in <src>data</src> has to have the correct shape
228 // (which is guaranteed by the ArrayColumn getColumnCells function).
229 virtual void getColumnSliceCellsV(const RefRows& rownrs, const Slicer& ns, ArrayBase& data);
230
231 // Put into a section of some cells of the column.
232 // The array given in <src>data</src> has to have the correct shape
233 // (which is guaranteed by the ArrayColumn putColumnSlice function).
234 virtual void putColumnSliceCellsV(const RefRows& rownrs, const Slicer& ns, const ArrayBase& data);
235
236 // Read the data of the column from a tile.
237 // (I.e. convert from external to local format).
238 void readTile(void* to, const void* from, uInt nrPixels);
239
240 // Write the data of the column into a tile.
241 // (I.e. convert from local to external format).
242 void writeTile(void* to, const void* from, uInt nrPixels);
243
244 // Get the function to convert from external to local format
245 // (or vice-versa if <src>writeFlag=True</src>).
247 return writeFlag ? writeFunc_p : readFunc_p;
248 }
249
250 // Get nr of elements in a value to convert (usually 1, but 2 for Complex).
251 size_t getNrConvert() const { return convPixelSize_p; }
252
253 // Does a conversion (byte swap) needs to be done?
255
256 private:
257 // The (canonical) size of a pixel in a tile.
259 // The local size of a pixel.
261 // The multiplication factor for a conversion operation.
262 // This is the pixel size when a memcpy can be used, otherwise it is 1.
264 // Is a conversion necessary?
266 // The column sequence number.
268 // The conversion function needed when reading.
270 // The conversion function needed when writing.
272
273 // Read or write a data cell in the cube.
274 // A cell can contain a scalar or an array (depending on the
275 // column definition).
276 void accessCell(rownr_t rownr, const void* dataPtr, Bool writeFlag);
277
278 // Read or write a slice of a data cell in the cube.
279 void accessCellSlice(rownr_t rownr, const Slicer& ns, const void* dataPtr, Bool writeFlag);
280
281 // Read or write an entire column.
282 // This can only be done if one hypercube is used.
283 void accessColumn(const void* dataPtr, Bool writeFlag);
284
285 // Read or write a slice from the entire column.
286 // This can only be done if one hypercube is used.
287 void accessColumnSlice(const Slicer& ns, const void* dataPtr, Bool writeFlag);
288
289 // Read or write some cells in a column.
290 // It tries to optimize by looking for regular row strides.
291 void accessColumnCells(const RefRows& rownrs, const IPosition& shape, const void* dataPtr,
292 Bool writeFlag);
293
294 // Read or write some cells in a column.
295 // It tries to optimize by looking for regular row strides.
296 void accessColumnSliceCells(const RefRows& rownrs, const Slicer& ns, const IPosition& shape,
297 const void* dataPtr, Bool writeFlag);
298
299 // Read or write the full cells given by start,end,incr.
300 void accessFullCells(TSMCube* hypercube, char* dataPtr, Bool writeFlag, const IPosition& start,
301 const IPosition& end, const IPosition& incr);
302
303 // Read or write the sliced cells given by start,end,incr.
304 void accessSlicedCells(TSMCube* hypercube, char* dataPtr, Bool writeFlag, const IPosition& start,
305 const IPosition& end, const IPosition& incr);
306};
307
310inline void TSMDataColumn::setColumnNumber(uInt colnr) { colnr_p = colnr; }
311inline void TSMDataColumn::readTile(void* to, const void* from, uInt nrPixels) {
312 readFunc_p(to, from, nrPixels * convPixelSize_p);
313}
314inline void TSMDataColumn::writeTile(void* to, const void* from, uInt nrPixels) {
315 writeFunc_p(to, from, nrPixels * convPixelSize_p);
316}
317
318} // namespace casacore
319
320#endif
Non-templated base class for templated Array class.
Definition ArrayBase.h:69
size_t ValueFunction(void *to, const void *from, size_t nvalues)
Define the signature of a function converting nvalues values from internal to external format or vice...
Definition Conversion.h:95
TSMColumn(TiledStMan *stman, int dataType, const String &columnName)
Create a column of the given type.
virtual void getDComplex(rownr_t rownr, DComplex *dataPtr)
virtual void putArrayColumnV(const ArrayBase &arr)
Put all array values in the column.
void accessColumnSliceCells(const RefRows &rownrs, const Slicer &ns, const IPosition &shape, const void *dataPtr, Bool writeFlag)
Read or write some cells in a column.
virtual void putColumnSliceV(const Slicer &slicer, const ArrayBase &data)
Put a section into all array values in the column.
TSMDataColumn(const TSMColumn &column)
Create a data column from the given column.
virtual void putuShort(rownr_t rownr, const uShort *dataPtr)
virtual void getdouble(rownr_t rownr, double *dataPtr)
virtual void getuShort(rownr_t rownr, uShort *dataPtr)
void accessCell(rownr_t rownr, const void *dataPtr, Bool writeFlag)
Read or write a data cell in the cube.
virtual void putArrayColumnCellsV(const RefRows &rownrs, const ArrayBase &dataPtr)
Put the array values into some cells of the column.
virtual void getArrayColumnCellsV(const RefRows &rownrs, ArrayBase &data)
Get the array values in some cells of the column.
virtual void getColumnSliceV(const Slicer &slicer, ArrayBase &arr)
Get a section of all arrays in the column.
virtual ~TSMDataColumn()
Frees up the storage.
void accessColumnCells(const RefRows &rownrs, const IPosition &shape, const void *dataPtr, Bool writeFlag)
Read or write some cells in a column.
virtual void getBool(rownr_t rownr, Bool *dataPtr)
Get a scalar value in the given row.
IPosition shape(rownr_t rownr)
Get the shape of the item in the given row.
void setColumnNumber(uInt colnr)
Set column sequence number.
void setShape(rownr_t rownr, const IPosition &shape)
Set the shape of the data array in the given row.
void accessSlicedCells(TSMCube *hypercube, char *dataPtr, Bool writeFlag, const IPosition &start, const IPosition &end, const IPosition &incr)
Read or write the sliced cells given by start,end,incr.
Bool isShapeDefined(rownr_t rownr)
Is the value shape defined in the given row?
void writeTile(void *to, const void *from, uInt nrPixels)
Write the data of the column into a tile.
void setShapeTiled(rownr_t rownr, const IPosition &shape, const IPosition &tileShape)
Set the shape and tile shape of the array in the given row.
uInt64 dataLength(uInt64 nrPixels) const
Determine the length to store the given number of pixels.
Bool canChangeShape() const
Changing array shapes for non-FixedShape columns when the parent tiled storage manager can handle it.
virtual void getInt64(rownr_t rownr, Int64 *dataPtr)
virtual void getArrayV(rownr_t rownr, ArrayBase &data)
Get the array value in the given row.
Bool mustConvert_p
Is a conversion necessary?
void accessFullCells(TSMCube *hypercube, char *dataPtr, Bool writeFlag, const IPosition &start, const IPosition &end, const IPosition &incr)
Read or write the full cells given by start,end,incr.
uInt localPixelSize_p
The local size of a pixel.
uInt colnr_p
The column sequence number.
virtual void getColumnSliceCellsV(const RefRows &rownrs, const Slicer &ns, ArrayBase &data)
Get a section from some cells of the column.
void accessColumnSlice(const Slicer &ns, const void *dataPtr, Bool writeFlag)
Read or write a slice from the entire column.
Bool isConversionNeeded() const
Does a conversion (byte swap) needs to be done?
virtual void getShort(rownr_t rownr, Short *dataPtr)
Conversion::ValueFunction * getConvertFunction(Bool writeFlag) const
Get the function to convert from external to local format (or vice-versa if writeFlag=True).
virtual void putBool(rownr_t rownr, const Bool *dataPtr)
Put a scalar value into the given row.
virtual void getInt(rownr_t rownr, Int *dataPtr)
uInt tilePixelSize_p
The (canonical) size of a pixel in a tile.
void accessCellSlice(rownr_t rownr, const Slicer &ns, const void *dataPtr, Bool writeFlag)
Read or write a slice of a data cell in the cube.
uInt convPixelSize_p
The multiplication factor for a conversion operation.
virtual void putShort(rownr_t rownr, const Short *dataPtr)
virtual void putDComplex(rownr_t rownr, const DComplex *dataPtr)
virtual void getSliceV(rownr_t rownr, const Slicer &slicer, ArrayBase &dataPtr)
Get into a section of the array in the given row.
virtual void putArrayV(rownr_t rownr, const ArrayBase &data)
Put the array value into the given row.
void readTile(void *to, const void *from, uInt nrPixels)
Read the data of the column from a tile.
virtual void putdouble(rownr_t rownr, const double *dataPtr)
virtual void putInt64(rownr_t rownr, const Int64 *dataPtr)
virtual void putColumnSliceCellsV(const RefRows &rownrs, const Slicer &ns, const ArrayBase &data)
Put into a section of some cells of the column.
virtual void getfloat(rownr_t rownr, float *dataPtr)
virtual void putuChar(rownr_t rownr, const uChar *dataPtr)
uInt tilePixelSize() const
Return the size of a pixel in the tile in external format.
IPosition tileShape(rownr_t rownr)
Get the tile shape of the item in the given row.
virtual void getuChar(rownr_t rownr, uChar *dataPtr)
virtual void putuInt(rownr_t rownr, const uInt *dataPtr)
size_t getNrConvert() const
Get nr of elements in a value to convert (usually 1, but 2 for Complex).
Conversion::ValueFunction * readFunc_p
The conversion function needed when reading.
TSMDataColumn & operator=(const TSMDataColumn &)=delete
Forbid assignment.
virtual void putComplex(rownr_t rownr, const Complex *dataPtr)
virtual void getuInt(rownr_t rownr, uInt *dataPtr)
Conversion::ValueFunction * writeFunc_p
The conversion function needed when writing.
virtual void getComplex(rownr_t rownr, Complex *dataPtr)
virtual void putInt(rownr_t rownr, const Int *dataPtr)
virtual void getArrayColumnV(ArrayBase &arr)
Get all array values in the column.
virtual void putSliceV(rownr_t rownr, const Slicer &slicer, const ArrayBase &data)
Put into a section of the array in the given row.
virtual void putfloat(rownr_t rownr, const float *dataPtr)
void accessColumn(const void *dataPtr, Bool writeFlag)
Read or write an entire column.
TSMDataColumn(const TSMDataColumn &)=delete
Forbid copy constructor.
uInt localPixelSize() const
Return the size of a pixel in the tile in local format.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned char uChar
Definition aipstype.h:45
short Short
Definition aipstype.h:46
unsigned int uInt
Definition aipstype.h:49
unsigned short uShort
Definition aipstype.h:47
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
iterator end()
Definition Block.h:601
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44
unsigned long long uInt64
Definition aipsxtype.h:37