casacore
|
Class representing a function in table select expression. More...
#include <ExprFuncNode.h>
Public Member Functions | |
TableExprFuncNode (FunctionType, NodeDataType, ValueType, const TableExprNodeSet &source) | |
Constructor. More... | |
~TableExprFuncNode () | |
Destructor. More... | |
Bool | getBool (const TableExprId &id) |
'get' Functions to get the desired result of a function More... | |
Int64 | getInt (const TableExprId &id) |
Double | getDouble (const TableExprId &id) |
DComplex | getDComplex (const TableExprId &id) |
String | getString (const TableExprId &id) |
TaqlRegex | getRegex (const TableExprId &id) |
MVTime | getDate (const TableExprId &id) |
void | setScale (Double scale) |
Set unit scale factor (needed for sqrt). More... | |
Double | getScale () const |
Get possible unit scale factor (needed for sqrt). More... | |
const PtrBlock< TableExprNodeRep * > & | operands () const |
Some functions to be used by TableExprNodeFuncArray. More... | |
PtrBlock< TableExprNodeRep * > & | rwOperands () |
FunctionType | funcType () const |
NodeDataType | argDataType () const |
![]() | |
TableExprNodeMulti (NodeDataType, ValueType, OperType, const TableExprNodeRep &source) | |
Constructor. More... | |
virtual | ~TableExprNodeMulti () |
Destructor. More... | |
virtual void | show (ostream &, uInt indent) const |
Show the expression tree. More... | |
virtual void | getAggrNodes (vector< TableExprNodeRep *> &aggr) |
Get the nodes representing an aggregate function. More... | |
virtual void | getColumnNodes (vector< TableExprNodeRep *> &cols) |
Get the nodes representing a table column. More... | |
const PtrBlock< TableExprNodeRep * > & | getChildren () const |
Get the child nodes. More... | |
![]() | |
TableExprNodeRep (NodeDataType, ValueType, OperType, ArgType, ExprType, Int ndim, const IPosition &shape, const Table &table) | |
Construct a node. More... | |
TableExprNodeRep (NodeDataType, ValueType, OperType, const Table &) | |
This constructor is called from the derived TableExprNodeRep. More... | |
TableExprNodeRep (const TableExprNodeRep &) | |
Copy constructor. More... | |
virtual | ~TableExprNodeRep () |
The destructor deletes all the underlying TableExprNode objects. More... | |
TableExprNodeRep * | link () |
Link to this object, i.e. More... | |
virtual void | disableApplySelection () |
Do not apply the selection. More... | |
virtual void | applySelection (const Vector< uInt > &rownrs) |
Re-create the column object for a selection of rows. More... | |
virtual Double | getUnitFactor () const |
Get the unit conversion factor. More... | |
virtual CountedPtr< TableExprGroupFuncBase > | makeGroupAggrFunc () |
Create the correct immediate aggregate function object. More... | |
virtual Bool | isLazyAggregate () const |
Is the aggregate function a lazy or an immediate one? The default implementation returns True (because all UDF aggregate functions have to be lazy). More... | |
virtual Array< Bool > | getArrayBool (const TableExprId &id) |
Get an array value for this node in the given row. More... | |
virtual Array< Int64 > | getArrayInt (const TableExprId &id) |
virtual Array< Double > | getArrayDouble (const TableExprId &id) |
virtual Array< DComplex > | getArrayDComplex (const TableExprId &id) |
virtual Array< String > | getArrayString (const TableExprId &id) |
virtual Array< MVTime > | getArrayDate (const TableExprId &id) |
void | get (const TableExprId &id, Bool &value) |
General get functions for template purposes. More... | |
void | get (const TableExprId &id, Int64 &value) |
void | get (const TableExprId &id, Double &value) |
void | get (const TableExprId &id, DComplex &value) |
void | get (const TableExprId &id, MVTime &value) |
void | get (const TableExprId &id, String &value) |
void | get (const TableExprId &id, Array< Bool > &value) |
void | get (const TableExprId &id, Array< Int64 > &value) |
void | get (const TableExprId &id, Array< Double > &value) |
void | get (const TableExprId &id, Array< DComplex > &value) |
void | get (const TableExprId &id, Array< MVTime > &value) |
void | get (const TableExprId &id, Array< String > &value) |
Array< Bool > | getBoolAS (const TableExprId &id) |
Get a value as an array, even it it is a scalar. More... | |
Array< Int64 > | getIntAS (const TableExprId &id) |
Array< Double > | getDoubleAS (const TableExprId &id) |
Array< DComplex > | getDComplexAS (const TableExprId &id) |
Array< String > | getStringAS (const TableExprId &id) |
Array< MVTime > | getDateAS (const TableExprId &id) |
virtual Bool | hasBool (const TableExprId &id, Bool value) |
Does a value occur in an array or set? The default implementation tests if it is in an array. More... | |
virtual Bool | hasInt (const TableExprId &id, Int64 value) |
virtual Bool | hasDouble (const TableExprId &id, Double value) |
virtual Bool | hasDComplex (const TableExprId &id, const DComplex &value) |
virtual Bool | hasString (const TableExprId &id, const String &value) |
virtual Bool | hasDate (const TableExprId &id, const MVTime &value) |
virtual Array< Bool > | hasArrayBool (const TableExprId &id, const Array< Bool > &value) |
virtual Array< Bool > | hasArrayInt (const TableExprId &id, const Array< Int64 > &value) |
virtual Array< Bool > | hasArrayDouble (const TableExprId &id, const Array< Double > &value) |
virtual Array< Bool > | hasArrayDComplex (const TableExprId &id, const Array< DComplex > &value) |
virtual Array< Bool > | hasArrayString (const TableExprId &id, const Array< String > &value) |
virtual Array< Bool > | hasArrayDate (const TableExprId &id, const Array< MVTime > &value) |
uInt | nrow () const |
Get the number of rows in the table associated with this expression. More... | |
virtual Bool | getColumnDataType (DataType &) const |
Get the data type of the column. More... | |
virtual Array< Bool > | getColumnBool (const Vector< uInt > &rownrs) |
Get the value of the expression evaluated for the entire column. More... | |
virtual Array< uChar > | getColumnuChar (const Vector< uInt > &rownrs) |
virtual Array< Short > | getColumnShort (const Vector< uInt > &rownrs) |
virtual Array< uShort > | getColumnuShort (const Vector< uInt > &rownrs) |
virtual Array< Int > | getColumnInt (const Vector< uInt > &rownrs) |
virtual Array< uInt > | getColumnuInt (const Vector< uInt > &rownrs) |
virtual Array< Float > | getColumnFloat (const Vector< uInt > &rownrs) |
virtual Array< Double > | getColumnDouble (const Vector< uInt > &rownrs) |
virtual Array< Complex > | getColumnComplex (const Vector< uInt > &rownrs) |
virtual Array< DComplex > | getColumnDComplex (const Vector< uInt > &rownrs) |
virtual Array< String > | getColumnString (const Vector< uInt > &rownrs) |
virtual void | ranges (Block< TableExprRange > &) |
Convert the tree to a number of range vectors which at least select the same things. More... | |
NodeDataType | dataType () const |
Get the data type of the derived TableExprNode object. More... | |
ValueType | valueType () const |
Get the value type. More... | |
void | setValueType (ValueType vtype) |
Set the value type. More... | |
OperType | operType () const |
Get the operator type. More... | |
ExprType | exprType () const |
Get the expression type. More... | |
Bool | isConstant () const |
Is the expression a constant? More... | |
const Unit & | unit () const |
Get the unit. More... | |
void | setUnit (const Unit &unit) |
Set the unit. More... | |
Int | ndim () const |
Get the fixed dimensionality (same for all rows). More... | |
const IPosition & | shape () const |
Get the fixed shape (same for all rows). More... | |
const IPosition & | shape (const TableExprId &id) |
Get the shape for the given row. More... | |
virtual Bool | isDefined (const TableExprId &id) |
Is the value in the given row defined? The default implementation returns True. More... | |
Table & | table () |
Get table. More... | |
const Table & | table () const |
virtual void | adaptSetUnits (const Unit &) |
Let a set node convert itself to the given unit. More... | |
Static Public Member Functions | |
static NodeDataType | checkOperands (Block< Int > &dtypeOper, ValueType &resVT, Block< Int > &vtypeOper, FunctionType, PtrBlock< TableExprNodeRep *> &) |
Check the data and value types of the operands. More... | |
static Double | fillUnits (TableExprNodeRep *node, PtrBlock< TableExprNodeRep *> &nodes, FunctionType func) |
Fill the result unit in the node. More... | |
static TableExprNodeRep * | fillNode (TableExprFuncNode *thisNode, PtrBlock< TableExprNodeRep *> &nodes, const Block< Int > &dtypeOper) |
Link the children to the node and convert the children to constants if possible. More... | |
static void | fillChildNodes (TableExprFuncNode *thisNode, PtrBlock< TableExprNodeRep *> &nodes, const Block< Int > &dtypeOper) |
Link the children to the node and convert the children to constants if possible. More... | |
static void | getPrintFormat (String &fmt, Int &width, Int &prec, const PtrBlock< TableExprNodeRep *> &operands, const TableExprId &id) |
Get the possible print format, width, and/or precision. More... | |
static String | stringDT (const MVTime &dt, Int prec, MVTime::formatTypes) |
Convert the date and/or time to a string. More... | |
static String | stringDateTime (const MVTime &dt, Int prec) |
static String | stringDate (const MVTime &dt) |
static String | stringTime (const MVTime &dt, Int prec) |
static String | stringValue (Bool val, const String &fmt, Int width) |
Convert a value to a string. More... | |
static String | stringValue (Int64 val, const String &fmt, Int width) |
static String | stringValue (Double val, const String &fmt, Int width, Int prec, const std::pair< int, int > &mvFormat, const Unit &unit) |
static String | stringValue (const DComplex &val, const String &fmt, Int width, Int prec) |
static String | stringValue (const String &val, const String &fmt, Int width) |
static String | stringValue (const MVTime &val, const String &fmt, Int width, const std::pair< int, int > &mvFormat) |
static String | stringAngle (double val, Int prec, MVAngle::formatTypes type) |
Convert angle to a string (hms or dms). More... | |
static String | stringHMS (double val, Int prec) |
static String | stringDMS (double val, Int prec) |
static std::pair< int, int > | getMVFormat (const String &fmt) |
Get the MVTime/Angle format and optional precision. More... | |
static double | angdist (double ra1, double dec1, double ra2, double dec2) |
Get the angular distance between two positions on a sphere. More... | |
![]() | |
static uInt | checkNumOfArg (uInt low, uInt high, const PtrBlock< TableExprNodeRep *> &nodes) |
Check number of arguments low <= number_of_args <= high It throws an exception if wrong number of arguments. More... | |
static NodeDataType | checkDT (Block< Int > &dtypeOper, NodeDataType dtIn, NodeDataType dtOut, const PtrBlock< TableExprNodeRep *> &nodes) |
Check datatype of nodes and return output type. More... | |
![]() | |
static void | unlink (TableExprNodeRep *) |
Unlink from the given object. More... | |
static void | checkAggrFuncs (const TableExprNodeRep *node) |
Throw an exception if an aggregate function is used in the expression node. More... | |
static void | createRange (Block< TableExprRange > &, TableExprNodeColumn *, Double start, Double end) |
Create a range object from a column and an interval. More... | |
static void | createRange (Block< TableExprRange > &) |
Create a empty range object. More... | |
static String | typeString (NodeDataType) |
Convert a NodeDataType to a string. More... | |
static String | typeString (ValueType) |
Convert a ValueType to a string. More... | |
Private Member Functions | |
void | tryToConst () |
Try if the function gives a constant result. More... | |
Static Private Member Functions | |
static const Unit & | makeEqualUnits (PtrBlock< TableExprNodeRep *> &nodes, uInt starg, uInt endarg) |
Make the units of nodes from starg till endarg equal. More... | |
Private Attributes | |
FunctionType | funcType_p |
NodeDataType | argDataType_p |
Double | scale_p |
Additional Inherited Members | |
![]() | |
virtual const IPosition & | getShape (const TableExprId &id) |
Get the shape for the given row. More... | |
virtual void | convertConstChild () |
When one of the children is a constant, convert its data type to that of the other operand. More... | |
void | checkTablePtr (const TableExprNodeRep *node) |
Check if this node uses the same table pointer. More... | |
void | fillExprType (const TableExprNodeRep *node) |
Set expression type to Variable if node is Variable. More... | |
![]() | |
static TableExprNodeRep * | getRep (TableExprNode &) |
Get pointer to REPresentation object. More... | |
static void | checkTablePtr (Table &table, const TableExprNodeRep *node) |
static void | fillExprType (ExprType &, const TableExprNodeRep *node) |
static TableExprNodeRep * | convertNode (TableExprNodeRep *thisNode, Bool convertConstType) |
When the node is constant, it is evaluated and replaced by the appropriate TableExprNodeConst object. More... | |
![]() | |
PtrBlock< TableExprNodeRep * > | operands_p |
![]() | |
uInt | count_p |
Table | table_p |
NodeDataType | dtype_p |
ValueType | vtype_p |
OperType | optype_p |
ArgType | argtype_p |
ExprType | exprtype_p |
Int | ndim_p |
IPosition | shape_p |
Unit | unit_p |
Class representing a function in table select expression.
Internal
This class represents a function in a table select tree. The rownumber
function is represented by class TableExprNodeRownr . The rowid
function is represented by class TableExprNodeRowid . The rand
function is represented by class TableExprNodeRandom .
When one wants to add a function to the table selection grammar, the following has to be done:
Definition at line 76 of file ExprFuncNode.h.
Enumerator | |
---|---|
piFUNC | |
eFUNC | |
cFUNC | |
near2FUNC | for Int, or Double or Complex returning Bool (2 is with default tolerance) |
near3FUNC | |
nearabs2FUNC | |
nearabs3FUNC | |
sinFUNC | for Int, Double or DComplex returning Double or Complex |
sinhFUNC | |
cosFUNC | |
coshFUNC | |
expFUNC | |
logFUNC | |
log10FUNC | |
sqrtFUNC | |
powFUNC | |
conjFUNC | |
squareFUNC | for Int, Double or DComplex returning Int, Double or Complex |
cubeFUNC | |
minFUNC | |
maxFUNC | |
normFUNC | for Int, Double or DComplex returning Int or Double |
absFUNC | |
argFUNC | |
realFUNC | for Int, Double or DComplex returning Double |
imagFUNC | |
intFUNC | for Int or Double returning Int (using floor) |
asinFUNC | for Int or Double returning Double |
acosFUNC | |
atanFUNC | |
atan2FUNC | |
tanFUNC | |
tanhFUNC | |
signFUNC | for Int or Double returning Int or Double |
roundFUNC | |
floorFUNC | |
ceilFUNC | |
fmodFUNC | |
complexFUNC | for Int, Double or DComplex returning DComplex |
arrsumFUNC | for Int, Double or Complex array returning the same |
arrsumsFUNC | |
arrproductFUNC | |
arrproductsFUNC | |
arrsumsqrFUNC | |
arrsumsqrsFUNC | |
arrminFUNC | for Int or Double array returning Int or Double |
arrminsFUNC | |
runminFUNC | |
boxminFUNC | |
arrmaxFUNC | |
arrmaxsFUNC | |
runmaxFUNC | |
boxmaxFUNC | |
arrmeanFUNC | for Int or Double array returning Double |
arrmeansFUNC | |
runmeanFUNC | |
boxmeanFUNC | |
arrvarianceFUNC | |
arrvariancesFUNC | |
runvarianceFUNC | |
boxvarianceFUNC | |
arrstddevFUNC | |
arrstddevsFUNC | |
runstddevFUNC | |
boxstddevFUNC | |
arravdevFUNC | |
arravdevsFUNC | |
runavdevFUNC | |
boxavdevFUNC | |
arrrmsFUNC | |
arrrmssFUNC | |
runrmsFUNC | |
boxrmsFUNC | |
arrmedianFUNC | |
arrmediansFUNC | |
runmedianFUNC | |
boxmedianFUNC | |
arrfractileFUNC | |
arrfractilesFUNC | |
anyFUNC | for Bool array returning Bool |
anysFUNC | |
runanyFUNC | |
boxanyFUNC | |
allFUNC | |
allsFUNC | |
runallFUNC | |
boxallFUNC | |
ntrueFUNC | for Bool array returning Int scalar |
ntruesFUNC | |
nfalseFUNC | |
nfalsesFUNC | |
arrayFUNC | for any type returning array of that type |
transposeFUNC | |
resizeFUNC | |
isnanFUNC | for Int, Double or DComplex array returning Bool |
isinfFUNC | |
isfiniteFUNC | |
isdefFUNC | for any array returning Bool scalar |
ndimFUNC | for any array returning Int scalar |
nelemFUNC | |
shapeFUNC | for any array returning Int array |
strlengthFUNC | for String |
upcaseFUNC | |
downcaseFUNC | |
capitalizeFUNC | |
trimFUNC | |
ltrimFUNC | |
rtrimFUNC | |
substrFUNC | |
replaceFUNC | |
regexFUNC | |
patternFUNC | |
sqlpatternFUNC | |
datetimeFUNC | for Date |
mjdtodateFUNC | |
mjdFUNC | |
dateFUNC | |
timeFUNC | |
yearFUNC | |
monthFUNC | |
dayFUNC | |
cmonthFUNC | |
weekdayFUNC | |
cdowFUNC | |
weekFUNC | |
ctodFUNC | |
cdateFUNC | |
ctimeFUNC | |
stringFUNC | return values as strings |
hmsFUNC | return angles as hms strings |
dmsFUNC | return angles as dms strings |
hdmsFUNC | return angles as hms/dms strings |
randFUNC | special function returning a random Double number |
rownrFUNC | special function returning Int row number |
rowidFUNC | special function returning Int row id (meant for GIVING) |
iifFUNC | special function resembling if statement |
angdistFUNC | angular distance returning radians |
angdistxFUNC | |
conesFUNC | other functions, implemented in derived class |
cones3FUNC | |
anyconeFUNC | |
anycone3FUNC | |
findconeFUNC | |
findcone3FUNC | |
FirstAggrFunc | |
countallFUNC | |
gcountFUNC | |
gfirstFUNC | |
glastFUNC | |
gminFUNC | |
gmaxFUNC | |
gsumFUNC | |
gproductFUNC | |
gsumsqrFUNC | |
gmeanFUNC | |
gvarianceFUNC | |
gstddevFUNC | |
grmsFUNC | |
ganyFUNC | |
gallFUNC | |
gntrueFUNC | |
gnfalseFUNC | |
FirstAggrArrayFunc | |
gminsFUNC | |
gmaxsFUNC | |
gsumsFUNC | |
gproductsFUNC | |
gsumsqrsFUNC | |
gmeansFUNC | |
gvariancesFUNC | |
gstddevsFUNC | |
grmssFUNC | |
ganysFUNC | |
gallsFUNC | |
gntruesFUNC | |
gnfalsesFUNC | |
LastAggrArrayFunc | |
ghistFUNC | |
gaggrFUNC | |
growidFUNC | |
gmedianFUNC | |
gfractileFUNC | |
gexpridFUNC | |
NRFUNC |
Definition at line 80 of file ExprFuncNode.h.
casacore::TableExprFuncNode::TableExprFuncNode | ( | FunctionType | , |
NodeDataType | , | ||
ValueType | , | ||
const TableExprNodeSet & | source | ||
) |
Constructor.
casacore::TableExprFuncNode::~TableExprFuncNode | ( | ) |
Destructor.
|
inlinestatic |
Get the angular distance between two positions on a sphere.
Definition at line 416 of file ExprFuncNode.h.
References casacore::acos(), casacore::cos(), makeEqualUnits(), casacore::sin(), and tryToConst().
|
inline |
Definition at line 367 of file ExprFuncNode.h.
References argDataType_p, getMVFormat(), getPrintFormat(), operands(), stringAngle(), stringDate(), stringDateTime(), stringDMS(), stringDT(), stringHMS(), stringTime(), stringValue(), and casacore::TableExprNodeRep::unit().
Referenced by casacore::TableExprFuncNodeArray::argDataType().
|
static |
Check the data and value types of the operands.
It sets the exptected data and value types of the operands. Set the value type of the function result and returns the data type of the function result.
|
static |
Link the children to the node and convert the children to constants if possible.
|
static |
Link the children to the node and convert the children to constants if possible.
Also convert the node to constant if possible.
|
static |
Fill the result unit in the node.
Adapt the children nodes if their units need to be converted. It returns a possible scale factor in case result unit is SI (for sqrt).
|
inline |
Definition at line 365 of file ExprFuncNode.h.
References funcType_p.
Referenced by casacore::TableExprFuncNodeArray::funcType().
|
virtual |
'get' Functions to get the desired result of a function
Reimplemented from casacore::TableExprNodeRep.
|
virtual |
Reimplemented from casacore::TableExprNodeRep.
|
virtual |
Reimplemented from casacore::TableExprNodeRep.
|
virtual |
Reimplemented from casacore::TableExprNodeRep.
|
virtual |
Reimplemented from casacore::TableExprNodeRep.
|
static |
Get the MVTime/Angle format and optional precision.
0,0 is returned if empty or unknown format.
Referenced by argDataType().
|
static |
Get the possible print format, width, and/or precision.
Referenced by argDataType().
|
virtual |
Reimplemented from casacore::TableExprNodeRep.
|
inline |
Get possible unit scale factor (needed for sqrt).
Definition at line 356 of file ExprFuncNode.h.
References scale_p.
|
virtual |
Reimplemented from casacore::TableExprNodeRep.
|
staticprivate |
Make the units of nodes from starg
till endarg
equal.
Return the unit found.
Referenced by angdist().
|
inline |
Some functions to be used by TableExprNodeFuncArray.
Definition at line 361 of file ExprFuncNode.h.
References casacore::TableExprNodeMulti::operands_p.
Referenced by argDataType(), casacore::TableExprAggrNode::operand(), and casacore::TableExprFuncNodeArray::operands().
|
inline |
Definition at line 363 of file ExprFuncNode.h.
References casacore::TableExprNodeMulti::operands_p.
Referenced by casacore::TableExprFuncNodeArray::rwOperands().
|
inline |
Set unit scale factor (needed for sqrt).
Definition at line 352 of file ExprFuncNode.h.
References scale_p.
Referenced by casacore::TableExprFuncNodeArray::setScale().
|
static |
Convert angle to a string (hms or dms).
Referenced by argDataType().
Referenced by argDataType().
Referenced by argDataType().
Referenced by argDataType().
|
static |
Convert the date and/or time to a string.
Referenced by argDataType().
Referenced by argDataType().
Referenced by argDataType().
|
static |
Convert a value to a string.
If fmt
is empty, ostringstream is used. Otherwise the printf-like format is used. If possible, a double value is converted to radians if formatted as angle.
Referenced by argDataType().
|
static |
|
static |
|
static |
|
static |
|
static |
|
private |
Try if the function gives a constant result.
If so, set the expression type to Constant.
Referenced by angdist().
|
private |
Definition at line 431 of file ExprFuncNode.h.
Referenced by argDataType().
|
private |
Definition at line 430 of file ExprFuncNode.h.
Referenced by funcType().
|
private |
Definition at line 432 of file ExprFuncNode.h.
Referenced by getScale(), and setScale().