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