Loading...
Searching...
No Matches
ExprDerNode.h
Go to the documentation of this file.
//# 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: casa-feedback@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
#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() override = default;
Bool getBool (const TableExprId& id) override;
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() override = default;
Int64 getInt (const TableExprId& id) override;
Double getDouble (const TableExprId& id) override;
DComplex getDComplex (const TableExprId& id) override;
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() override = default;
Double getDouble (const TableExprId& id) override;
DComplex getDComplex (const TableExprId& id) override;
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() override = default;
DComplex getDComplex (const TableExprId& id) override;
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() override = default;
String getString (const TableExprId& id) override;
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() override = default;
TaqlRegex getRegex (const TableExprId& id) override;
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() override = default;
Double getDouble(const TableExprId& id) override;
MVTime getDate (const TableExprId& id) override;
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 TableExprInfo&, const String& columnName);
~TableExprNodeColumn() override = default;
// Get the table info for this column.
TableExprInfo getTableInfo() const override;
// Do not apply the selection.
void disableApplySelection() override;
// Re-create the column object for a selection of rows.
void applySelection (const Vector<rownr_t>& rownrs) override;
// Get the data type of this scalar column.
Bool getColumnDataType (DataType&) const override;
// Get the data for the given id.
Bool getBool (const TableExprId& id) override;
Int64 getInt (const TableExprId& id) override;
Double getDouble (const TableExprId& id) override;
DComplex getDComplex (const TableExprId& id) override;
String getString (const TableExprId& id) override;
const TableColumn& getColumn() const;
// Get the data for the given rows.
Array<Bool> getColumnBool (const Vector<rownr_t>& rownrs) override;
Array<uChar> getColumnuChar (const Vector<rownr_t>& rownrs) override;
Array<Short> getColumnShort (const Vector<rownr_t>& rownrs) override;
Array<uShort> getColumnuShort (const Vector<rownr_t>& rownrs) override;
Array<Int> getColumnInt (const Vector<rownr_t>& rownrs) override;
Array<uInt> getColumnuInt (const Vector<rownr_t>& rownrs) override;
Array<Int64> getColumnInt64 (const Vector<rownr_t>& rownrs) override;
Array<Float> getColumnFloat (const Vector<rownr_t>& rownrs) override;
Array<Double> getColumnDouble (const Vector<rownr_t>& rownrs) override;
Array<Complex> getColumnComplex (const Vector<rownr_t>& rownrs) override;
Array<DComplex> getColumnDComplex (const Vector<rownr_t>& rownrs) override;
Array<String> getColumnString (const Vector<rownr_t>& rownrs) override;
// Get the column unit (can be empty).
static Unit getColumnUnit (const TableColumn&);
protected:
TableExprInfo tableInfo_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 TableExprInfo&, uInt origin);
~TableExprNodeRownr() override = default;
TableExprInfo getTableInfo() const override;
Int64 getInt (const TableExprId& id) override;
private:
TableExprInfo tableInfo_p;
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 TableExprInfo&);
~TableExprNodeRowid() override = default;
TableExprInfo getTableInfo() const override;
void applySelection (const Vector<rownr_t>& rownrs) override;
Int64 getInt (const TableExprId& id) override;
private:
TableExprInfo tableInfo_p;
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 TableExprInfo&);
~TableExprNodeRandom() override = default;
TableExprInfo getTableInfo() const override;
Double getDouble (const TableExprId& id) override;
private:
TableExprInfo tableInfo_p;
MLCG generator_p;
Uniform random_p;
};
} //# NAMESPACE CASACORE - END
#endif
casacore::Array
Definition Array.h:155
casacore::MLCG
Multiplicative linear congruential generator.
Definition Random.h:304
casacore::MVTime
Definition MVTime.h:268
casacore::StringDistance
Definition StringDistance.h:68
casacore::String
String: the storage and methods of handling collections of characters.
Definition String.h:223
casacore::TableColumn
Definition TableColumn.h:97
casacore::TableExprId
Definition TableExprId.h:95
casacore::TableExprInfo
Class to connect a Table and its alias name.
Definition ExprNodeRep.h:125
casacore::TableExprNodeBinary::TableExprNodeBinary
TableExprNodeBinary(NodeDataType, ValueType, OperType, ExprType)
Constructor.
casacore::TableExprNodeColumn::getColumnFloat
Array< Float > getColumnFloat(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::getColumnDComplex
Array< DComplex > getColumnDComplex(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::getColumnString
Array< String > getColumnString(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::getDouble
Double getDouble(const TableExprId &id) override
casacore::TableExprNodeColumn::getColumnuInt
Array< uInt > getColumnuInt(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::disableApplySelection
void disableApplySelection() override
Do not apply the selection.
casacore::TableExprNodeColumn::getColumnUnit
static Unit getColumnUnit(const TableColumn &)
Get the column unit (can be empty).
casacore::TableExprNodeColumn::getColumn
const TableColumn & getColumn() const
casacore::TableExprNodeColumn::~TableExprNodeColumn
~TableExprNodeColumn() override=default
casacore::TableExprNodeColumn::getColumnDouble
Array< Double > getColumnDouble(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::getColumnBool
Array< Bool > getColumnBool(const Vector< rownr_t > &rownrs) override
Get the data for the given rows.
casacore::TableExprNodeColumn::getColumnInt
Array< Int > getColumnInt(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::applySelection_p
Bool applySelection_p
Definition ExprDerNode.h:343
casacore::TableExprNodeColumn::tableInfo_p
TableExprInfo tableInfo_p
Definition ExprDerNode.h:341
casacore::TableExprNodeColumn::getTableInfo
TableExprInfo getTableInfo() const override
Get the table info for this column.
casacore::TableExprNodeColumn::getColumnDataType
Bool getColumnDataType(DataType &) const override
Get the data type of this scalar column.
casacore::TableExprNodeColumn::getColumnComplex
Array< Complex > getColumnComplex(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::getInt
Int64 getInt(const TableExprId &id) override
casacore::TableExprNodeColumn::getString
String getString(const TableExprId &id) override
casacore::TableExprNodeColumn::getColumnuShort
Array< uShort > getColumnuShort(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::getColumnInt64
Array< Int64 > getColumnInt64(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::getBool
Bool getBool(const TableExprId &id) override
Get the data for the given id.
casacore::TableExprNodeColumn::TableExprNodeColumn
TableExprNodeColumn(const TableExprInfo &, const String &columnName)
casacore::TableExprNodeColumn::applySelection
void applySelection(const Vector< rownr_t > &rownrs) override
Re-create the column object for a selection of rows.
casacore::TableExprNodeColumn::getDComplex
DComplex getDComplex(const TableExprId &id) override
casacore::TableExprNodeColumn::getColumnShort
Array< Short > getColumnShort(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::getColumnuChar
Array< uChar > getColumnuChar(const Vector< rownr_t > &rownrs) override
casacore::TableExprNodeColumn::tabCol_p
TableColumn tabCol_p
Definition ExprDerNode.h:342
casacore::TableExprNodeConstBool::getBool
Bool getBool(const TableExprId &id) override
Get a scalar value for this node in the given row.
casacore::TableExprNodeConstBool::value_p
Bool value_p
Definition ExprDerNode.h:80
casacore::TableExprNodeConstBool::TableExprNodeConstBool
TableExprNodeConstBool(const Bool &value)
casacore::TableExprNodeConstBool::~TableExprNodeConstBool
~TableExprNodeConstBool() override=default
casacore::TableExprNodeConstDComplex::TableExprNodeConstDComplex
TableExprNodeConstDComplex(const DComplex &value)
casacore::TableExprNodeConstDComplex::~TableExprNodeConstDComplex
~TableExprNodeConstDComplex() override=default
casacore::TableExprNodeConstDComplex::getDComplex
DComplex getDComplex(const TableExprId &id) override
casacore::TableExprNodeConstDComplex::value_p
DComplex value_p
Definition ExprDerNode.h:176
casacore::TableExprNodeConstDate::getDate
MVTime getDate(const TableExprId &id) override
casacore::TableExprNodeConstDate::TableExprNodeConstDate
TableExprNodeConstDate(const MVTime &value)
casacore::TableExprNodeConstDate::getDouble
Double getDouble(const TableExprId &id) override
casacore::TableExprNodeConstDate::~TableExprNodeConstDate
~TableExprNodeConstDate() override=default
casacore::TableExprNodeConstDate::value_p
MVTime value_p
Definition ExprDerNode.h:271
casacore::TableExprNodeConstDouble::getDComplex
DComplex getDComplex(const TableExprId &id) override
casacore::TableExprNodeConstDouble::value_p
Double value_p
Definition ExprDerNode.h:145
casacore::TableExprNodeConstDouble::~TableExprNodeConstDouble
~TableExprNodeConstDouble() override=default
casacore::TableExprNodeConstDouble::getDouble
Double getDouble(const TableExprId &id) override
casacore::TableExprNodeConstDouble::TableExprNodeConstDouble
TableExprNodeConstDouble(const Double &value)
casacore::TableExprNodeConstInt::getDComplex
DComplex getDComplex(const TableExprId &id) override
casacore::TableExprNodeConstInt::getDouble
Double getDouble(const TableExprId &id) override
casacore::TableExprNodeConstInt::value_p
Int64 value_p
Definition ExprDerNode.h:113
casacore::TableExprNodeConstInt::TableExprNodeConstInt
TableExprNodeConstInt(const Int64 &value)
casacore::TableExprNodeConstInt::~TableExprNodeConstInt
~TableExprNodeConstInt() override=default
casacore::TableExprNodeConstInt::getInt
Int64 getInt(const TableExprId &id) override
casacore::TableExprNodeConstRegex::value_p
TaqlRegex value_p
Definition ExprDerNode.h:238
casacore::TableExprNodeConstRegex::~TableExprNodeConstRegex
~TableExprNodeConstRegex() override=default
casacore::TableExprNodeConstRegex::TableExprNodeConstRegex
TableExprNodeConstRegex(const TaqlRegex &value)
casacore::TableExprNodeConstRegex::getRegex
TaqlRegex getRegex(const TableExprId &id) override
casacore::TableExprNodeConstRegex::dist_p
StringDistance dist_p
Definition ExprDerNode.h:239
casacore::TableExprNodeConstString::value_p
String value_p
Definition ExprDerNode.h:207
casacore::TableExprNodeConstString::~TableExprNodeConstString
~TableExprNodeConstString() override=default
casacore::TableExprNodeConstString::TableExprNodeConstString
TableExprNodeConstString(const String &value)
casacore::TableExprNodeConstString::getString
String getString(const TableExprId &id) override
casacore::TableExprNodeRandom::getTableInfo
TableExprInfo getTableInfo() const override
Get the table info.
casacore::TableExprNodeRandom::TableExprNodeRandom
TableExprNodeRandom(const TableExprInfo &)
casacore::TableExprNodeRandom::random_p
Uniform random_p
Definition ExprDerNode.h:449
casacore::TableExprNodeRandom::tableInfo_p
TableExprInfo tableInfo_p
Definition ExprDerNode.h:447
casacore::TableExprNodeRandom::~TableExprNodeRandom
~TableExprNodeRandom() override=default
casacore::TableExprNodeRandom::generator_p
MLCG generator_p
Definition ExprDerNode.h:448
casacore::TableExprNodeRandom::getDouble
Double getDouble(const TableExprId &id) override
casacore::TableExprNodeRowid::getTableInfo
TableExprInfo getTableInfo() const override
Get the table info.
casacore::TableExprNodeRowid::applySelection
void applySelection(const Vector< rownr_t > &rownrs) override
Re-create the column object for a selection of rows.
casacore::TableExprNodeRowid::~TableExprNodeRowid
~TableExprNodeRowid() override=default
casacore::TableExprNodeRowid::getInt
Int64 getInt(const TableExprId &id) override
casacore::TableExprNodeRowid::tableInfo_p
TableExprInfo tableInfo_p
Definition ExprDerNode.h:414
casacore::TableExprNodeRowid::TableExprNodeRowid
TableExprNodeRowid(const TableExprInfo &)
casacore::TableExprNodeRowid::rownrs_p
Vector< rownr_t > rownrs_p
Definition ExprDerNode.h:415
casacore::TableExprNodeRownr::~TableExprNodeRownr
~TableExprNodeRownr() override=default
casacore::TableExprNodeRownr::tableInfo_p
TableExprInfo tableInfo_p
Definition ExprDerNode.h:377
casacore::TableExprNodeRownr::TableExprNodeRownr
TableExprNodeRownr(const TableExprInfo &, uInt origin)
casacore::TableExprNodeRownr::getInt
Int64 getInt(const TableExprId &id) override
casacore::TableExprNodeRownr::getTableInfo
TableExprInfo getTableInfo() const override
Get the table info.
casacore::TableExprNodeRownr::origin_p
uInt origin_p
Definition ExprDerNode.h:378
casacore::Table
Definition Table.h:157
casacore::TaqlRegex
Definition ExprNodeRep.h:80
casacore::Uniform
Uniform distribution.
Definition Random.h:1271
casacore::Unit
Definition Unit.h:187
casacore::Vector
Definition Vector.h:82
casacore
this file contains all the compiler specific defines
Definition mainpage.dox:28
casacore::uInt
unsigned int uInt
Definition aipstype.h:49
casacore::Int64
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
casacore::value
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:368
casacore::Double
double Double
Definition aipstype.h:53