casacore
Loading...
Searching...
No Matches
ExprDerNode.h
Go to the documentation of this file.
1// # ExprDerNode.h: Nodes representing scalars in table select expression tree
2// # Copyright (C) 1994,1995,1996,1997,1999,2000,2001
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_EXPRDERNODE_H
27#define TABLES_EXPRDERNODE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/TaQL/ExprNodeRep.h>
32#include <casacore/tables/Tables/TableColumn.h>
33#include <casacore/casa/Arrays/Vector.h>
34#include <casacore/casa/BasicMath/Random.h>
35
36namespace casacore { // # NAMESPACE CASACORE - BEGIN
37
38// # Forward Declarations
39class TableColumn;
40class Table;
41
42// # This file defines classes derived from TableExprNode representing
43// # the data type and operator in a table expression.
44// #
45// # Data types Bool, Int64, Double, DComplex and String are used.
46// # Char, uChar, Short, uShort, Int, and uInt are converted to Int64,
47// # Float to Double, and Complex to DComplex.
48// # Binary operators +, -, *, /, ==, >=, >, <, <= and != are recognized.
49// # Also &&, ||, parentheses and unary +, - and ! are recognized.
50
51// <summary>
52// Constant Bool in table select expression tree
53// </summary>
54
55// <use visibility=local>
56
57// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
58// </reviewed>
59
60// <prerequisite>
61// # Classes you should understand before using this one.
62// <li> TableExprNode
63// </prerequisite>
64
65// <synopsis>
66// This class represents a constant in a table select expression tree.
67// This is also used to hold the value of a table keyword, which is
68// constant over the entire table.
69// </synopsis>
70
72 public:
74 ~TableExprNodeConstBool() override = default;
75 Bool getBool(const TableExprId& id) override;
76
77 private:
79};
80
81// <summary>
82// Constant Int64 in table select expression tree
83// </summary>
84
85// <use visibility=local>
86
87// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
88// </reviewed>
89
90// <prerequisite>
91// # Classes you should understand before using this one.
92// <li> TableExprNode
93// </prerequisite>
94
95// <synopsis>
96// This class represents a constant in a table select expression tree.
97// This is also used to hold the value of a table keyword, which is
98// constant over the entire table.
99// </synopsis>
100
102 public:
104 ~TableExprNodeConstInt() override = default;
105 Int64 getInt(const TableExprId& id) override;
106 Double getDouble(const TableExprId& id) override;
107 DComplex getDComplex(const TableExprId& id) override;
108
109 private:
111};
112
113// <summary>
114// Constant Double in table select expression tree
115// </summary>
116
117// <use visibility=local>
118
119// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
120// </reviewed>
121
122// <prerequisite>
123// # Classes you should understand before using this one.
124// <li> TableExprNode
125// </prerequisite>
126
127// <synopsis>
128// This class represents a constant in a table select expression tree.
129// This is also used to hold the value of a table keyword, which is
130// constant over the entire table.
131// </synopsis>
132
134 public:
136 ~TableExprNodeConstDouble() override = default;
137 Double getDouble(const TableExprId& id) override;
138 DComplex getDComplex(const TableExprId& id) override;
139
140 private:
142};
143
144// <summary>
145// Constant DComplex in table select expression tree
146// </summary>
147
148// <use visibility=local>
149
150// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
151// </reviewed>
152
153// <prerequisite>
154// # Classes you should understand before using this one.
155// <li> TableExprNode
156// </prerequisite>
157
158// <synopsis>
159// This class represents a constant in a table select expression tree.
160// This is also used to hold the value of a table keyword, which is
161// constant over the entire table.
162// </synopsis>
163
165 public:
167 ~TableExprNodeConstDComplex() override = default;
168 DComplex getDComplex(const TableExprId& id) override;
169
170 private:
171 DComplex value_p;
172};
173
174// <summary>
175// Constant String in table select expression tree
176// </summary>
177
178// <use visibility=local>
179
180// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
181// </reviewed>
182
183// <prerequisite>
184// # Classes you should understand before using this one.
185// <li> TableExprNode
186// </prerequisite>
187
188// <synopsis>
189// This class represents a constant in a table select expression tree.
190// This is also used to hold the value of a table keyword, which is
191// constant over the entire table.
192// </synopsis>
193
195 public:
197 ~TableExprNodeConstString() override = default;
198 String getString(const TableExprId& id) override;
199
200 private:
202};
203
204// <summary>
205// Constant Regex or StringDistance in table select expression tree
206// </summary>
207
208// <use visibility=local>
209
210// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
211// </reviewed>
212
213// <prerequisite>
214// # Classes you should understand before using this one.
215// <li> TableExprNode
216// </prerequisite>
217
218// <synopsis>
219// This class represents a constant in a table select expression tree.
220// This is also used to hold the value of a table keyword, which is
221// constant over the entire table.
222// </synopsis>
223
234
235// <summary>
236// Constant Date in table select expression tree
237// </summary>
238
239// <use visibility=local>
240
241// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
242// </reviewed>
243
244// <prerequisite>
245// # Classes you should understand before using this one.
246// <li> TableExprNode
247// </prerequisite>
248
249// <synopsis>
250// This class represents a constant in a table select expression tree.
251// This is also used to hold the value of a table keyword, which is
252// constant over the entire table.
253// </synopsis>
254
256 public:
258 ~TableExprNodeConstDate() override = default;
259 Double getDouble(const TableExprId& id) override;
260 MVTime getDate(const TableExprId& id) override;
261
262 private:
264};
265
266// <summary>
267// Scalar column in table select expression tree
268// </summary>
269
270// <use visibility=local>
271
272// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
273// </reviewed>
274//
275// <prerequisite>
276// # Classes you should understand before using this one.
277// <li> TableExprNode
278// </prerequisite>
279
280// <synopsis>
281// This class represents a scalar column in a table select expression tree.
282// When the select expression gets evaluated, the value of the
283// given row in the column is used.
284// </synopsis>
285
287 public:
288 TableExprNodeColumn(const TableExprInfo&, const String& columnName);
289 ~TableExprNodeColumn() override = default;
290
291 // Get the table info for this column.
292 TableExprInfo getTableInfo() const override;
293
294 // Do not apply the selection.
295 void disableApplySelection() override;
296
297 // Re-create the column object for a selection of rows.
298 void applySelection(const Vector<rownr_t>& rownrs) override;
299
300 // Get the data type of this scalar column.
301 Bool getColumnDataType(DataType&) const override;
302
303 // Get the data for the given id.
304 Bool getBool(const TableExprId& id) override;
305 Int64 getInt(const TableExprId& id) override;
306 Double getDouble(const TableExprId& id) override;
307 DComplex getDComplex(const TableExprId& id) override;
308 String getString(const TableExprId& id) override;
309 const TableColumn& getColumn() const;
310
311 // Get the data for the given rows.
316 Array<Int> getColumnInt(const Vector<rownr_t>& rownrs) override;
324
325 // Get the column unit (can be empty).
327
328 protected:
332};
333
334// <summary>
335// Rownumber in table select expression tree
336// </summary>
337
338// <use visibility=local>
339
340// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
341// </reviewed>
342
343// <prerequisite>
344// # Classes you should understand before using this one.
345// <li> TableExprNode
346// </prerequisite>
347
348// <synopsis>
349// This class represents the rownumber() function in a table
350// select expression tree.
351// The origin is stored to indicate whether the first rownumber
352// should be zero (in C++) or another value (1 in TaQL).
353// </synopsis>
354
356 public:
358 ~TableExprNodeRownr() override = default;
359 TableExprInfo getTableInfo() const override;
360 Int64 getInt(const TableExprId& id) override;
361
362 private:
365};
366
367// <summary>
368// Rowid in table select expression tree
369// </summary>
370
371// <use visibility=local>
372
373// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
374// </reviewed>
375
376// <prerequisite>
377// # Classes you should understand before using this one.
378// <li> TableExprNode
379// </prerequisite>
380
381// <synopsis>
382// This class represents the rowid() function in a table
383// select expression tree.
384// It is meant to get the original row number in a GIVING clause,
385// but, of course, it can also be used in the SELECT clause.
386// The row number returned is 0-based.
387// </synopsis>
388
390 public:
392 ~TableExprNodeRowid() override = default;
393 TableExprInfo getTableInfo() const override;
394 void applySelection(const Vector<rownr_t>& rownrs) override;
395 Int64 getInt(const TableExprId& id) override;
396
397 private:
400};
401
402// <summary>
403// Random number in table select expression tree
404// </summary>
405
406// <use visibility=local>
407
408// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
409// </reviewed>
410
411// <prerequisite>
412// # Classes you should understand before using this one.
413// <li> TableExprNode
414// </prerequisite>
415
416// <synopsis>
417// This class represents the rand() function in a table
418// select expression tree.
419// </synopsis>
420
433
434} // namespace casacore
435
436#endif
Multiplicative linear congruential generator.
Definition Random.h:303
String: the storage and methods of handling collections of characters.
Definition String.h:355
Class to connect a Table and its alias name.
TableExprNodeBinary(NodeDataType, ValueType, OperType, ExprType)
Constructor.
Array< Float > getColumnFloat(const Vector< rownr_t > &rownrs) override
Array< DComplex > getColumnDComplex(const Vector< rownr_t > &rownrs) override
Array< String > getColumnString(const Vector< rownr_t > &rownrs) override
Double getDouble(const TableExprId &id) override
Array< uInt > getColumnuInt(const Vector< rownr_t > &rownrs) override
void disableApplySelection() override
Do not apply the selection.
static Unit getColumnUnit(const TableColumn &)
Get the column unit (can be empty).
const TableColumn & getColumn() const
~TableExprNodeColumn() override=default
Array< Double > getColumnDouble(const Vector< rownr_t > &rownrs) override
Array< Bool > getColumnBool(const Vector< rownr_t > &rownrs) override
Get the data for the given rows.
Array< Int > getColumnInt(const Vector< rownr_t > &rownrs) override
TableExprInfo getTableInfo() const override
Get the table info for this column.
Bool getColumnDataType(DataType &) const override
Get the data type of this scalar column.
Array< Complex > getColumnComplex(const Vector< rownr_t > &rownrs) override
Int64 getInt(const TableExprId &id) override
String getString(const TableExprId &id) override
Array< uShort > getColumnuShort(const Vector< rownr_t > &rownrs) override
Array< Int64 > getColumnInt64(const Vector< rownr_t > &rownrs) override
Bool getBool(const TableExprId &id) override
Get the data for the given id.
TableExprNodeColumn(const TableExprInfo &, const String &columnName)
void applySelection(const Vector< rownr_t > &rownrs) override
Re-create the column object for a selection of rows.
DComplex getDComplex(const TableExprId &id) override
Array< Short > getColumnShort(const Vector< rownr_t > &rownrs) override
Array< uChar > getColumnuChar(const Vector< rownr_t > &rownrs) override
Bool getBool(const TableExprId &id) override
Get a scalar value for this node in the given row.
TableExprNodeConstBool(const Bool &value)
~TableExprNodeConstBool() override=default
TableExprNodeConstDComplex(const DComplex &value)
~TableExprNodeConstDComplex() override=default
DComplex getDComplex(const TableExprId &id) override
MVTime getDate(const TableExprId &id) override
TableExprNodeConstDate(const MVTime &value)
Double getDouble(const TableExprId &id) override
~TableExprNodeConstDate() override=default
DComplex getDComplex(const TableExprId &id) override
~TableExprNodeConstDouble() override=default
Double getDouble(const TableExprId &id) override
TableExprNodeConstDouble(const Double &value)
DComplex getDComplex(const TableExprId &id) override
Double getDouble(const TableExprId &id) override
TableExprNodeConstInt(const Int64 &value)
~TableExprNodeConstInt() override=default
Int64 getInt(const TableExprId &id) override
~TableExprNodeConstRegex() override=default
TableExprNodeConstRegex(const TaqlRegex &value)
TaqlRegex getRegex(const TableExprId &id) override
~TableExprNodeConstString() override=default
TableExprNodeConstString(const String &value)
String getString(const TableExprId &id) override
TableExprInfo getTableInfo() const override
Get the table info.
TableExprNodeRandom(const TableExprInfo &)
~TableExprNodeRandom() override=default
Double getDouble(const TableExprId &id) override
TableExprInfo getTableInfo() const override
Get the table info.
void applySelection(const Vector< rownr_t > &rownrs) override
Re-create the column object for a selection of rows.
~TableExprNodeRowid() override=default
Int64 getInt(const TableExprId &id) override
TableExprNodeRowid(const TableExprInfo &)
Vector< rownr_t > rownrs_p
~TableExprNodeRownr() override=default
TableExprNodeRownr(const TableExprInfo &, uInt origin)
Int64 getInt(const TableExprId &id) override
TableExprInfo getTableInfo() const override
Get the table info.
Uniform distribution.
Definition Random.h:1214
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:360
double Double
Definition aipstype.h:53