casacore
Loading...
Searching...
No Matches
ConcatColumn.h
Go to the documentation of this file.
1//# ConcatColumn.h: A column in a concatenated table
2//# Copyright (C) 2008
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_CONCATCOLUMN_H
27#define TABLES_CONCATCOLUMN_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/tables/Tables/BaseColumn.h>
33#include <casacore/tables/Tables/ColumnCache.h>
34#include <casacore/tables/Tables/TableRecord.h>
35#include <casacore/casa/Arrays/ArrayFwd.h>
36
37namespace casacore { //# NAMESPACE CASACORE - BEGIN
38
39 //# Forward Declarations
40 class ConcatTable;
41 class BaseColumnDesc;
42 class TableRecord;
43 class Slicer;
44 class IPosition;
45
46 // <summary>
47 // A column in a concatenated table
48 // </summary>
49
50 // <use visibility=local>
51
52 // <reviewed reviewer="UNKNOWN" date="" tests="">
53 // </reviewed>
54
55 // <prerequisite>
56 //# Classes you should understand before using this one.
57 // <li> ConcatTable
58 // <li> BaseColumn
59 // </prerequisite>
60
61 // <etymology>
62 // ConcatTable represents a column in a ConcatTable. A ConcatTable is a table
63 // referencing another table, usually as the result of a select, etc..
64 // </etymology>
65
66 // <synopsis>
67 // ConcatColumn handles the access of a column in a ConcatTable.
68 // It calls the corresponding function in the referenced column
69 // while converting the given row number to the row number in the
70 // referenced table.
71 // </synopsis>
72
73 // <motivation>
74 // This class is untyped, i.e. not templated.
75 // Every call is sent to the underlying referenced BaseColumn which
76 // is typed by the virtual function mechanism.
77 // A ConcatColumn can never be used directly. A user always has to
78 // construct a typed ArrayColumn or ScalarColumn object to access a column.
79 // This means everyting is fully type safe.
80 // </motivation>
81
82 // <todo asof="$DATE:$">
83 //# A List of bugs, limitations, extensions or planned refinements.
84 // <li> Act upon removal of rows or the underlying column
85 // </todo>
86
87
88 class ConcatColumn : public BaseColumn
89 {
90 public:
91 // Construct the ConcatColumn. It will point to the given column
92 // description, ConcatTable and referenced column.
93 // The ConcatTable will be used to convert the rownr to the rownr
94 // in the referenced column.
96
98
99 // Test if the column is writable in the parent table.
100 virtual Bool isWritable() const;
101
102 // Test if the column is stored (otherwise it is virtual).
103 virtual Bool isStored() const;
104
105 // Get access to the column keyword set.
106 // The initial keyword set is a copy of the keyword set of the first table.
107 // <group>
110 // </group>
111
112 // Get nr of rows in the column.
113 virtual rownr_t nrow() const;
114
115 // Test if a value in a particular cell has been defined.
116 virtual Bool isDefined (rownr_t rownr) const;
117
118 // Set the shape of the array in the given row.
119 virtual void setShape (rownr_t rownr, const IPosition& shape);
120
121 // Set the shape and tile shape of the array in the given row.
122 virtual void setShape (rownr_t rownr, const IPosition& shape,
123 const IPosition& tileShape);
124
125 // Get the global #dimensions of an array (i.e. for all rows).
126 virtual uInt ndimColumn() const;
127
128 // Get the global shape of an array (i.e. for all rows).
129 virtual IPosition shapeColumn() const;
130
131 // Get the #dimensions of an array in a particular cell.
132 virtual uInt ndim (rownr_t rownr) const;
133
134 // Get the shape of an array in a particular cell.
135 virtual IPosition shape (rownr_t rownr) const;
136
137 // Get the tile shape of an array in a particular cell.
138 virtual IPosition tileShape (rownr_t rownr) const;
139
140 // It can change shape if the underlying column can.
141 virtual Bool canChangeShape() const;
142
143 // Initialize the rows from startRownr till endRownr (inclusive)
144 // with the default value defined in the column description (if defined).
145 virtual void initialize (rownr_t startRownr, rownr_t endRownr);
146
147 // Get a value from a particular cell.
148 virtual void get (rownr_t rownr, void* dataPtr) const;
149
150 // Get a slice of an N-dimensional array in a particular cell.
151 virtual void getSlice (rownr_t rownr, const Slicer&, ArrayBase& dataPtr) const;
152
153 // Get the array of all array values in a column.
154 // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
155 // The arrays in the column have to have the same shape in all cells.
156 virtual void getArrayColumn (ArrayBase& dataPtr) const;
157
158 // Get subsections from all arrays in the column.
159 // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
160 // The arrays in the column have to have the same shape in all cells.
161 virtual void getColumnSlice (const Slicer&, ArrayBase& dataPtr) const;
162
163 // Get an array from a particular cell.
164 virtual void getArray (rownr_t rownr, ArrayBase& dataPtr) const;
165
166 // Get the array of some array values in a column.
167 // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
168 // The arrays in the column have to have the same shape in all cells.
169 virtual void getArrayColumnCells (const RefRows& rownrs,
170 ArrayBase& dataPtr) const;
171
172 // Get subsections from some arrays in the column.
173 // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
174 // The arrays in the column have to have the same shape in all cells.
175 virtual void getColumnSliceCells (const RefRows& rownrs,
176 const Slicer&, ArrayBase& dataPtr) const;
177
178 // Put the scalar value in a particular cell.
179 virtual void put (rownr_t rownr, const void* dataPtr);
180
181 // Put the array value in a particular cell.
182 virtual void putArray (rownr_t rownr, const ArrayBase& dataPtr);
183
184 // Put a slice of an N-dimensional array in a particular cell.
185 virtual void putSlice (rownr_t rownr, const Slicer&, const ArrayBase& dataPtr);
186
187 // Put the array of all array values in the column.
188 // If the column contains n-dim arrays, the source array is (n+1)-dim.
189 // The arrays in the column have to have the same shape in all cells.
190 virtual void putArrayColumn (const ArrayBase& dataPtr);
191
192 // Put into subsections of all table arrays in the column.
193 // If the column contains n-dim arrays, the source array is (n+1)-dim.
194 // The arrays in the column have to have the same shape in all cells.
195 virtual void putColumnSlice (const Slicer&, const ArrayBase& dataPtr);
196
197 // Get the array of some array values in a column.
198 // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
199 // The arrays in the column have to have the same shape in all cells.
200 virtual void putArrayColumnCells (const RefRows& rownrs,
201 const ArrayBase& dataPtr);
202
203 // Put subsections of some arrays in the column.
204 // If the column contains n-dim arrays, the source array is (n+1)-dim.
205 // The arrays in the column have to have the same shape in all cells.
206 virtual void putColumnSliceCells (const RefRows& rownrs,
207 const Slicer&, const ArrayBase& dataPtr);
208
209 // Get the underlying column cache.
211
212 // Set the maximum cache size (in bytes) to be used by a storage manager.
213 virtual void setMaximumCacheSize (uInt nbytes);
214
215 // Allocate value buffers for the table iterator.
216 // Also get a comparison function if undefined.
217 // The function freeIterBuf must be called to free the buffers.
218 virtual void allocIterBuf (void*& lastVal, void*& curVal,
219 std::shared_ptr<BaseCompare>& cmpObj);
220
221 // Free the value buffers allocated by allocIterBuf.
222 virtual void freeIterBuf (void*& lastVal, void*& curVal);
223
224 private:
225 // Define the function to handle access to an entire column.
226 typedef void AccessColumnFunc (BaseColumn* col,
227 const Slicer*, ArrayBase& array);
228
229 // Define the function to handle access to a number of rows.
230 typedef void AccessRowsFunc (BaseColumn* col, const RefRows& rows,
231 const Slicer*, ArrayBase& array);
232
233 // Access the data for an entire column.
234 void accessColumn (const Slicer* ns,
235 ArrayBase& dataPtr,
236 AccessColumnFunc*) const;
237
238 // Access the data with multiple rows combined.
239 void accessRows (const RefRows& rownrs,
240 const Slicer* ns,
241 ArrayBase& dataPtr,
242 AccessRowsFunc*) const;
243
244 // Define the access functions.
245 static void getColumnPart (BaseColumn* col,
246 const Slicer*, ArrayBase& arr);
247 static void putColumnPart (BaseColumn* col,
248 const Slicer*, ArrayBase& arr);
250 const Slicer* ns, ArrayBase& arr);
252 const Slicer* ns, ArrayBase& arr);
253 static void getRowsPart (BaseColumn* col, const RefRows& rows,
254 const Slicer*, ArrayBase& array);
255 static void putRowsPart (BaseColumn* col, const RefRows& rows,
256 const Slicer*, ArrayBase& array);
257 static void getRowsSlicePart (BaseColumn* col, const RefRows& rows,
258 const Slicer*, ArrayBase& array);
259 static void putRowsSlicePart (BaseColumn* col, const RefRows& rows,
260 const Slicer*, ArrayBase& array);
261 // </group>
262
263 protected:
264 // Set the column cache to the cache of the given table.
265 // The row numbers will be adjusted as needed.
266 void setColumnCache (uInt tableNr, const ColumnCache&) const;
267
268 //# Data members
273 };
274
275} //# NAMESPACE CASACORE - END
276
277#endif
Non-templated base class for templated Array class.
Definition ArrayBase.h:71
simple 1-D array
Definition Block.h:198
virtual void putArrayColumnCells(const RefRows &rownrs, const ArrayBase &dataPtr)
Get the array of some array values in a column.
virtual void putColumnSliceCells(const RefRows &rownrs, const Slicer &, const ArrayBase &dataPtr)
Put subsections of some arrays in the column.
static void putColumnSlicePart(BaseColumn *col, const Slicer *ns, ArrayBase &arr)
static void putColumnPart(BaseColumn *col, const Slicer *, ArrayBase &arr)
virtual void allocIterBuf(void *&lastVal, void *&curVal, std::shared_ptr< BaseCompare > &cmpObj)
Allocate value buffers for the table iterator.
virtual IPosition tileShape(rownr_t rownr) const
Get the tile shape of an array in a particular cell.
virtual void freeIterBuf(void *&lastVal, void *&curVal)
Free the value buffers allocated by allocIterBuf.
ConcatColumn(const BaseColumnDesc *, ConcatTable *)
Construct the ConcatColumn.
virtual void get(rownr_t rownr, void *dataPtr) const
Get a value from a particular cell.
void accessRows(const RefRows &rownrs, const Slicer *ns, ArrayBase &dataPtr, AccessRowsFunc *) const
Access the data with multiple rows combined.
virtual Bool isDefined(rownr_t rownr) const
Test if a value in a particular cell has been defined.
static void getRowsSlicePart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase &array)
static void getColumnPart(BaseColumn *col, const Slicer *, ArrayBase &arr)
Define the access functions.
virtual void putArray(rownr_t rownr, const ArrayBase &dataPtr)
Put the array value in a particular cell.
virtual void getArrayColumn(ArrayBase &dataPtr) const
Get the array of all array values in a column.
virtual void putArrayColumn(const ArrayBase &dataPtr)
Put the array of all array values in the column.
virtual uInt ndim(rownr_t rownr) const
Get the #dimensions of an array in a particular cell.
virtual IPosition shape(rownr_t rownr) const
Get the shape of an array in a particular cell.
virtual void initialize(rownr_t startRownr, rownr_t endRownr)
Initialize the rows from startRownr till endRownr (inclusive) with the default value defined in the c...
virtual void getColumnSlice(const Slicer &, ArrayBase &dataPtr) const
Get subsections from all arrays in the column.
void AccessColumnFunc(BaseColumn *col, const Slicer *, ArrayBase &array)
Define the function to handle access to an entire column.
virtual void getArray(rownr_t rownr, ArrayBase &dataPtr) const
Get an array from a particular cell.
virtual void putColumnSlice(const Slicer &, const ArrayBase &dataPtr)
Put into subsections of all table arrays in the column.
virtual void setMaximumCacheSize(uInt nbytes)
Set the maximum cache size (in bytes) to be used by a storage manager.
static void getColumnSlicePart(BaseColumn *col, const Slicer *ns, ArrayBase &arr)
virtual void putSlice(rownr_t rownr, const Slicer &, const ArrayBase &dataPtr)
Put a slice of an N-dimensional array in a particular cell.
virtual ColumnCache & columnCache()
Get the underlying column cache.
virtual void put(rownr_t rownr, const void *dataPtr)
Put the scalar value in a particular cell.
virtual uInt ndimColumn() const
Get the global #dimensions of an array (i.e.
virtual void setShape(rownr_t rownr, const IPosition &shape, const IPosition &tileShape)
Set the shape and tile shape of the array in the given row.
virtual void getColumnSliceCells(const RefRows &rownrs, const Slicer &, ArrayBase &dataPtr) const
Get subsections from some arrays in the column.
static void getRowsPart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase &array)
virtual Bool isStored() const
Test if the column is stored (otherwise it is virtual).
virtual Bool isWritable() const
Test if the column is writable in the parent table.
static void putRowsPart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase &array)
void accessColumn(const Slicer *ns, ArrayBase &dataPtr, AccessColumnFunc *) const
Access the data for an entire column.
virtual IPosition shapeColumn() const
Get the global shape of an array (i.e.
virtual void getSlice(rownr_t rownr, const Slicer &, ArrayBase &dataPtr) const
Get a slice of an N-dimensional array in a particular cell.
virtual void getArrayColumnCells(const RefRows &rownrs, ArrayBase &dataPtr) const
Get the array of some array values in a column.
static void putRowsSlicePart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase &array)
virtual TableRecord & keywordSet()
virtual TableRecord & rwKeywordSet()
Get access to the column keyword set.
virtual Bool canChangeShape() const
It can change shape if the underlying column can.
virtual void setShape(rownr_t rownr, const IPosition &shape)
Set the shape of the array in the given row.
virtual rownr_t nrow() const
Get nr of rows in the column.
void AccessRowsFunc(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase &array)
Define the function to handle access to a number of rows.
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
Block< BaseColumn * > refColPtr_p
void setColumnCache(uInt tableNr, const ColumnCache &) const
Set the column cache to the cache of the given table.
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition ExprNode.h:1933
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
TableRecord keywordSet_p
ConcatTable * refTabPtr_p
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44
ColumnCache colCache_p