1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
|
//# ExprDerNode.h: Nodes representing scalars in table select expression tree
//# Copyright (C) 1994,1995,1996,1997,1999,2000,2001
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//# $Id: ExprDerNode.h 21521 2014-12-10 08:06:42Z gervandiepen $
#ifndef TABLES_EXPRDERNODE_H
#define TABLES_EXPRDERNODE_H
//# Includes
#include <casacore/casa/aips.h>
#include <casacore/tables/TaQL/ExprNodeRep.h>
#include <casacore/tables/Tables/TableColumn.h>
#include <casacore/casa/Arrays/Vector.h>
#include <casacore/casa/BasicMath/Random.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
//# Forward Declarations
class TableColumn;
class Table;
//# This file defines classes derived from TableExprNode representing
//# the data type and operator in a table expression.
//#
//# Data types Bool, Int64, Double, DComplex and String are used.
//# Char, uChar, Short, uShort, Int, and uInt are converted to Int64,
//# Float to Double, and Complex to DComplex.
//# Binary operators +, -, *, /, ==, >=, >, <, <= and != are recognized.
//# Also &&, ||, parentheses and unary +, - and ! are recognized.
// <summary>
// Constant Bool in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents a constant in a table select expression tree.
// This is also used to hold the value of a table keyword, which is
// constant over the entire table.
// </synopsis>
class TableExprNodeConstBool : public TableExprNodeBinary
{
public:
TableExprNodeConstBool (const Bool& value);
~TableExprNodeConstBool();
Bool getBool (const TableExprId& id);
private:
Bool value_p;
};
// <summary>
// Constant Int64 in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents a constant in a table select expression tree.
// This is also used to hold the value of a table keyword, which is
// constant over the entire table.
// </synopsis>
class TableExprNodeConstInt : public TableExprNodeBinary
{
public:
TableExprNodeConstInt (const Int64& value);
~TableExprNodeConstInt();
Int64 getInt (const TableExprId& id);
Double getDouble (const TableExprId& id);
DComplex getDComplex (const TableExprId& id);
private:
Int64 value_p;
};
// <summary>
// Constant Double in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents a constant in a table select expression tree.
// This is also used to hold the value of a table keyword, which is
// constant over the entire table.
// </synopsis>
class TableExprNodeConstDouble : public TableExprNodeBinary
{
public:
TableExprNodeConstDouble (const Double& value);
~TableExprNodeConstDouble();
Double getDouble (const TableExprId& id);
DComplex getDComplex (const TableExprId& id);
private:
Double value_p;
};
// <summary>
// Constant DComplex in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents a constant in a table select expression tree.
// This is also used to hold the value of a table keyword, which is
// constant over the entire table.
// </synopsis>
class TableExprNodeConstDComplex : public TableExprNodeBinary
{
public:
TableExprNodeConstDComplex (const DComplex& value);
~TableExprNodeConstDComplex();
DComplex getDComplex (const TableExprId& id);
private:
DComplex value_p;
};
// <summary>
// Constant String in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents a constant in a table select expression tree.
// This is also used to hold the value of a table keyword, which is
// constant over the entire table.
// </synopsis>
class TableExprNodeConstString : public TableExprNodeBinary
{
public:
TableExprNodeConstString (const String& value);
~TableExprNodeConstString();
String getString (const TableExprId& id);
private:
String value_p;
};
// <summary>
// Constant Regex or StringDistance in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents a constant in a table select expression tree.
// This is also used to hold the value of a table keyword, which is
// constant over the entire table.
// </synopsis>
class TableExprNodeConstRegex : public TableExprNodeBinary
{
public:
TableExprNodeConstRegex (const TaqlRegex& value);
~TableExprNodeConstRegex();
TaqlRegex getRegex (const TableExprId& id);
private:
TaqlRegex value_p;
StringDistance dist_p;
};
// <summary>
// Constant Date in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents a constant in a table select expression tree.
// This is also used to hold the value of a table keyword, which is
// constant over the entire table.
// </synopsis>
class TableExprNodeConstDate : public TableExprNodeBinary
{
public:
TableExprNodeConstDate (const MVTime& value);
~TableExprNodeConstDate();
Double getDouble(const TableExprId& id);
MVTime getDate (const TableExprId& id);
private:
MVTime value_p;
};
// <summary>
// Scalar column in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
//
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents a scalar column in a table select expression tree.
// When the select expression gets evaluated, the value of the
// given row in the column is used.
// </synopsis>
class TableExprNodeColumn : public TableExprNodeBinary
{
public:
TableExprNodeColumn (const Table&, const String& columnName);
~TableExprNodeColumn();
// This node represents a table column.
virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
// Do not apply the selection.
virtual void disableApplySelection();
// Re-create the column object for a selection of rows.
virtual void applySelection (const Vector<rownr_t>& rownrs);
// Get the data type of this scalar column.
Bool getColumnDataType (DataType&) const;
// Get the data for the given id.
Bool getBool (const TableExprId& id);
Int64 getInt (const TableExprId& id);
Double getDouble (const TableExprId& id);
DComplex getDComplex (const TableExprId& id);
String getString (const TableExprId& id);
const TableColumn& getColumn() const;
// Get the data for the given rows.
Array<Bool> getColumnBool (const Vector<rownr_t>& rownrs);
Array<uChar> getColumnuChar (const Vector<rownr_t>& rownrs);
Array<Short> getColumnShort (const Vector<rownr_t>& rownrs);
Array<uShort> getColumnuShort (const Vector<rownr_t>& rownrs);
Array<Int> getColumnInt (const Vector<rownr_t>& rownrs);
Array<uInt> getColumnuInt (const Vector<rownr_t>& rownrs);
Array<Int64> getColumnInt64 (const Vector<rownr_t>& rownrs);
Array<Float> getColumnFloat (const Vector<rownr_t>& rownrs);
Array<Double> getColumnDouble (const Vector<rownr_t>& rownrs);
Array<Complex> getColumnComplex (const Vector<rownr_t>& rownrs);
Array<DComplex> getColumnDComplex (const Vector<rownr_t>& rownrs);
Array<String> getColumnString (const Vector<rownr_t>& rownrs);
// Get the column unit (can be empty).
static Unit getColumnUnit (const TableColumn&);
protected:
Table selTable_p;
TableColumn tabCol_p;
Bool applySelection_p;
};
// <summary>
// Rownumber in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents the rownumber() function in a table
// select expression tree.
// The origin is stored to indicate whether the first rownumber
// should be zero (in C++) or another value (1 in TaQL).
// </synopsis>
class TableExprNodeRownr : public TableExprNodeBinary
{
public:
TableExprNodeRownr (const Table&, uInt origin);
~TableExprNodeRownr();
Int64 getInt (const TableExprId& id);
private:
uInt origin_p;
};
// <summary>
// Rowid in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents the rowid() function in a table
// select expression tree.
// It is meant to get the original row number in a GIVING clause,
// but, of course, it can also be used in the SELECT clause.
// The row number returned is 0-based.
// </synopsis>
class TableExprNodeRowid : public TableExprNodeBinary
{
public:
TableExprNodeRowid (const Table&);
~TableExprNodeRowid();
virtual void applySelection (const Vector<rownr_t>& rownrs);
Int64 getInt (const TableExprId& id);
private:
Vector<rownr_t> rownrs_p;
};
// <summary>
// Random number in table select expression tree
// </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
// </reviewed>
// <prerequisite>
//# Classes you should understand before using this one.
// <li> TableExprNode
// </prerequisite>
// <synopsis>
// This class represents the rand() function in a table
// select expression tree.
// </synopsis>
class TableExprNodeRandom : public TableExprNodeBinary
{
public:
TableExprNodeRandom (const Table&);
~TableExprNodeRandom();
Double getDouble (const TableExprId& id);
private:
MLCG generator_p;
Uniform random_p;
};
} //# NAMESPACE CASACORE - END
#endif
|