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