26#ifndef TABLES_EXPRNODEREP_H
27#define TABLES_EXPRNODEREP_H
30#include <casacore/casa/aips.h>
31#include <casacore/tables/Tables/Table.h>
32#include <casacore/tables/TaQL/TableExprId.h>
33#include <casacore/tables/TaQL/ExprRange.h>
34#include <casacore/tables/TaQL/MArray.h>
35#include <casacore/casa/Containers/Record.h>
36#include <casacore/casa/BasicSL/Complex.h>
37#include <casacore/casa/Quanta/MVTime.h>
38#include <casacore/casa/Quanta/Unit.h>
39#include <casacore/casa/Utilities/DataType.h>
40#include <casacore/casa/Utilities/Regex.h>
41#include <casacore/casa/Utilities/StringDistance.h>
42#include <casacore/casa/iosfwd.h>
49class TableExprNodeColumn;
50class TableExprGroupFuncBase;
51template<
class T>
class Block;
54class TableExprNodeRep;
55typedef std::shared_ptr<TableExprNodeRep>
TENShPtr;
537 Bool convertConstType);
700 const std::vector<TENShPtr>& nodes);
711 const std::vector<TENShPtr>& nodes,
const String & regexp() const
Get the regular expression string.
Bool match(const String &target) const
Test if the given target string is within the maximum distance.
String: the storage and methods of handling collections of characters.
Bool matches(const string &str, Int pos=0) const
Matches entire string from pos (or till pos if negative pos).
Bool empty() const
Test for empty.
Class to connect a Table and its alias name.
const Table & table() const
Get the Table object.
void apply(const Vector< rownr_t > &rownrs)
Apply a selection of row numbers to the Table.
const String & alias() const
Get the alias.
Bool isJoinTable() const
Is the table a join table?
TableExprInfo(const Table &table=Table(), const String &alias=String(), Bool isJoinTable=False)
Construct from a table and its alias.
Abstract base class for a node having 0, 1, or 2 child nodes.
void setChildren(const TENShPtr &left, const TENShPtr &right, Bool adapt=True)
Set the children.
TableExprNodeBinary(NodeDataType, const TableExprNodeRep &, OperType)
static TableExprNodeRep getCommonTypes(const TENShPtr &left, const TENShPtr &right, OperType operType)
Check the data and value types and get the common one.
void show(ostream &, uInt indent) const override
Show the expression tree.
void adaptDataTypes()
If one of the children is a constant, convert its data type to that of the other operand.
~TableExprNodeBinary() override=default
Destructor.
const TENShPtr & getRightChild() const
virtual void handleUnits()
Handle the units of the children and possibly set the parent's unit.
TableExprNodeBinary(NodeDataType, ValueType, OperType, ExprType)
Constructor.
static const Unit & makeEqualUnits(const TENShPtr &left, TENShPtr &right)
Make the units equal.
const TENShPtr & getLeftChild() const
Get the child nodes.
void flattenTree(std::vector< TableExprNodeRep * > &) override
Flatten the node tree by adding the node and its children to the vector.
static NodeDataType getDT(NodeDataType leftDtype, NodeDataType rightDype, OperType operType)
Check the data types and get the common one.
Scalar column in table select expression tree.
Abstract base class for a node having multiple child nodes.
static uInt checkNumOfArg(uInt low, uInt high, const std::vector< TENShPtr > &nodes)
Check number of arguments low <= number_of_args <= high It throws an exception if wrong number of arg...
TableExprNodeMulti(NodeDataType, ValueType, OperType, const TableExprNodeRep &source)
Constructor.
~TableExprNodeMulti() override=default
Destructor.
const std::vector< TENShPtr > & getChildren() const
Get the child nodes.
static NodeDataType checkDT(Block< Int > &dtypeOper, NodeDataType dtIn, NodeDataType dtOut, const std::vector< TENShPtr > &nodes, Bool dateConv=True)
Check datatype of nodes and return output type.
void flattenTree(std::vector< TableExprNodeRep * > &) override
Flatten the node tree by adding the node and its children to the vector.
void show(ostream &, uInt indent) const override
Show the expression tree.
std::vector< TENShPtr > operands_p
Abstract base class for a node in a table column expression tree.
void setAttributes(const Record &)
Set the attributes.
void setValueType(ValueType vtype)
Set the value type.
static void createRange(Block< TableExprRange > &, TableExprNodeColumn *, Double start, Double end)
Create a range object from a column and an interval.
const Unit & unit() const
Get the unit.
virtual Array< DComplex > getColumnDComplex(const Vector< rownr_t > &rownrs)
void get(const TableExprId &id, MArray< Double > &value)
virtual MArray< Bool > contains(const TableExprId &id, const MArray< DComplex > &value)
void get(const TableExprId &id, DComplex &value)
rownr_t nrow()
Get the number of rows in the table associated with this expression.
virtual Bool isDefined(const TableExprId &id)
Is the value in the given row defined? The default implementation returns True.
virtual String getString(const TableExprId &id)
virtual Array< Short > getColumnShort(const Vector< rownr_t > &rownrs)
const IPosition & shape(const TableExprId &id)
Get the shape for the given row.
virtual Array< uShort > getColumnuShort(const Vector< rownr_t > &rownrs)
MArray< String > getStringAS(const TableExprId &id)
void get(const TableExprId &id, MArray< Int64 > &value)
NodeDataType dataType() const
Get the data type of the derived TableExprNode object.
virtual void optimize()
Try to optimize the node (meant for the right hand of the IN operator).
Bool isReal() const
Is the data type real (i.e., integer or double)?
static String typeString(ValueType)
Convert a ValueType to a string.
virtual Array< Int64 > getColumnInt64(const Vector< rownr_t > &rownrs)
virtual Bool contains(const TableExprId &id, String value)
virtual MArray< Bool > contains(const TableExprId &id, const MArray< Int64 > &value)
MArray< Double > getDoubleAS(const TableExprId &id)
void setUnit(const Unit &unit)
Set the unit.
virtual Bool contains(const TableExprId &id, MVTime value)
void get(const TableExprId &id, String &value)
OperType
Define the operator types.
virtual const IPosition & getShape(const TableExprId &id)
Get the shape for the given row.
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
virtual void adaptSetUnits(const Unit &)
Let a set node convert itself to the given unit.
Bool isConstant() const
Is the expression a constant?
virtual Bool isAggregate() const
Is the node an aggegation node.
virtual MArray< Double > getArrayDouble(const TableExprId &id)
ArgType
Define the value types of the 2 arguments when arrays are involved.
ExprType
Define (sub-)expression type.
@ Constant
A constant subexpression which can be evaluated immediately.
@ Variable
A variable (i.e.
virtual Bool getBool(const TableExprId &id)
Get a scalar value for this node in the given row.
virtual DComplex getDComplex(const TableExprId &id)
TableExprNodeRep(NodeDataType, ValueType, OperType, ExprType)
This constructor is called from the derived TableExprNodeRep.
virtual MArray< Bool > contains(const TableExprId &id, const MArray< Double > &value)
NodeDataType
Define the data types of a node.
MArray< DComplex > getDComplexAS(const TableExprId &id)
void get(const TableExprId &id, MArray< String > &value)
virtual Bool getColumnDataType(DataType &) const
Get the data type of the column.
MArray< Int64 > getIntAS(const TableExprId &id)
virtual ~TableExprNodeRep()=default
The destructor deletes all the underlying TableExprNode objects.
virtual Bool contains(const TableExprId &id, DComplex value)
virtual MArray< DComplex > getArrayDComplex(const TableExprId &id)
TableExprNodeRep(const TableExprNodeRep &)=default
Copy constructor.
void get(const TableExprId &id, Bool &value)
General get functions for template purposes.
virtual std::shared_ptr< TableExprGroupFuncBase > makeGroupAggrFunc()
Create the correct immediate aggregate function object.
virtual MArray< MVTime > getArrayDate(const TableExprId &id)
const Record & attributes() const
Get the attributes.
static TENShPtr replaceConstNode(const TENShPtr &node)
Replace a node with a constant expression by node with its value.
ExprType exprType() const
Get the expression type.
virtual Bool contains(const TableExprId &id, Double value)
MArray< MVTime > getDateAS(const TableExprId &id)
virtual MArray< String > getArrayString(const TableExprId &id)
void get(const TableExprId &id, MArray< MVTime > &value)
virtual Bool isLazyAggregate() const
Is the aggregate function a lazy or an immediate one? The default implementation returns True (becaus...
virtual Array< Double > getColumnDouble(const Vector< rownr_t > &rownrs)
virtual Array< uInt > getColumnuInt(const Vector< rownr_t > &rownrs)
virtual Array< uChar > getColumnuChar(const Vector< rownr_t > &rownrs)
void get(const TableExprId &id, MArray< Bool > &value)
const IPosition & shape() const
Get the fixed shape (same for all rows).
virtual void ranges(Block< TableExprRange > &)
Convert the tree to a number of range vectors which at least select the same things.
virtual TableExprInfo getTableInfo() const
Get the table info.
virtual TaqlRegex getRegex(const TableExprId &id)
virtual Bool contains(const TableExprId &id, Int64 value)
virtual MArray< Bool > getArrayBool(const TableExprId &id)
Get an array value for this node in the given row.
virtual MArray< Bool > contains(const TableExprId &id, const MArray< String > &value)
MArray< Bool > getBoolAS(const TableExprId &id)
Get a value as an array, even it it is a scalar.
virtual Bool contains(const TableExprId &id, Bool value)
Does a set or array contain the value? The default implementation assumes the set is a single scalar,...
virtual Array< Complex > getColumnComplex(const Vector< rownr_t > &rownrs)
virtual Double getDouble(const TableExprId &id)
virtual Int64 getInt(const TableExprId &id)
virtual MArray< Bool > contains(const TableExprId &id, const MArray< MVTime > &value)
TableExprNodeRep & operator=(const TableExprNodeRep &)=delete
Assign to a TableExprNodeRep cannot be done.
virtual Double getUnitFactor() const
Get the unit conversion factor.
void get(const TableExprId &id, MVTime &value)
virtual Array< Float > getColumnFloat(const Vector< rownr_t > &rownrs)
virtual void show(ostream &, uInt indent) const
Show the expression tree.
virtual MVTime getDate(const TableExprId &id)
virtual Array< Bool > getColumnBool(const Vector< rownr_t > &rownrs)
Get the value of the expression evaluated for the entire column.
Int ndim() const
Get the fixed dimensionality (same for all rows).
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
static void createRange(Block< TableExprRange > &)
Create a empty range object.
void get(const TableExprId &id, Int64 &value)
virtual MArray< Bool > contains(const TableExprId &id, const MArray< Bool > &value)
static TENShPtr convertNode(const TENShPtr &thisNode, Bool convertConstType)
If the node is constant, it is evaluated and replaced by the appropriate TableExprNodeConst object.
static String typeString(NodeDataType)
Convert a NodeDataType to a string.
virtual void flattenTree(std::vector< TableExprNodeRep * > &)
Flatten the node tree by adding the node and its children to the vector.
OperType operType() const
Get the operator type.
TableExprNodeRep(NodeDataType, ValueType, OperType, ArgType, ExprType, Int ndim, const IPosition &shape)
Construct a node.
void get(const TableExprId &id, Double &value)
void get(const TableExprId &id, MArray< DComplex > &value)
ValueType
Define the value types.
virtual Array< Int > getColumnInt(const Vector< rownr_t > &rownrs)
virtual void disableApplySelection()
Do not apply the selection.
ValueType valueType() const
Get the value type.
virtual Array< String > getColumnString(const Vector< rownr_t > &rownrs)
void fillExprType(const TableExprNodeRep *node)
Set expression type to Variable if node is Variable.
TaqlRegex(const Regex ®ex)
Construct from a regex.
Bool match(const String &str) const
Does the regex or maximum string distance match?
TaqlRegex(const StringDistance &dist)
Construct from a StringDistance.
const Regex & regex() const
Return the regular expression.
this file contains all the compiler specific defines
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
std::shared_ptr< TableExprNodeRep > TENShPtr
bool Bool
Define the standard types used by Casacore.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
uInt64 rownr_t
Define the type of a row number in a table.