casacore
Loading...
Searching...
No Matches
ExprNodeRep.h
Go to the documentation of this file.
1//# ExprNodeRep.h: Abstract base class for a node in a table column expression tree
2//# Copyright (C) 1994,1995,1996,1997,1998,2000,2001,2003
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: aips2-request@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//# $Id: ExprNodeRep.h 21262 2012-09-07 12:38:36Z gervandiepen $
27
28#ifndef TABLES_EXPRNODEREP_H
29#define TABLES_EXPRNODEREP_H
30
31//# Includes
32#include <casacore/casa/aips.h>
33#include <casacore/tables/Tables/Table.h>
34#include <casacore/tables/TaQL/TableExprId.h>
35#include <casacore/tables/TaQL/ExprRange.h>
36#include <casacore/tables/TaQL/MArray.h>
37#include <casacore/casa/Containers/Record.h>
38#include <casacore/casa/BasicSL/Complex.h>
39#include <casacore/casa/Quanta/MVTime.h>
40#include <casacore/casa/Quanta/Unit.h>
41#include <casacore/casa/Utilities/DataType.h>
42#include <casacore/casa/Utilities/Regex.h>
43#include <casacore/casa/Utilities/StringDistance.h>
44#include <casacore/casa/iosfwd.h>
45#include <vector>
46
47namespace casacore { //# NAMESPACE CASACORE - BEGIN
48
49//# Forward Declarations
50class TableExprNode;
51class TableExprNodeColumn;
52class TableExprGroupFuncBase;
53template<class T> class Block;
54
55//# Define a shared pointer to the Rep class.
56class TableExprNodeRep;
58
59
60// <summary>
61// Class to handle a Regex or StringDistance.
62// </summary>
63
64// <use visibility=local>
65
66// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
67// </reviewed>
68
69// <prerequisite>
70//# Classes you should understand before using this one.
71// <li> <linkto class=Regex>Regex</linkto>
72// <li> <linkto class=StringDistance>StringDistance</linkto>
73// </prerequisite>
74
75// <synopsis>
76// A StringDistance (Levensthein distance) in TaQL is given in the same way
77// as a Regex. This class is needed to have a single object in the parse tree
78// objects containing them (in class TableExprNodeConstRegex).
79// </synopsis>
80
82{
83public:
84 // Construct from a regex.
85 explicit TaqlRegex (const Regex& regex)
87 {}
88
89 // Construct from a StringDistance.
90 explicit TaqlRegex (const StringDistance& dist)
91 : itsDist(dist)
92 {}
93
94 // Does the regex or maximum string distance match?
95 Bool match (const String& str) const
96 { return itsRegex.regexp().empty() ?
97 itsDist.match(str) : str.matches(itsRegex);
98 }
99
100 // Return the regular expression.
101 const Regex& regex() const
102 { return itsRegex; }
103
104private:
107};
108
109
110
111// <summary>
112// Abstract base class for a node in a table column expression tree
113// </summary>
114
115// <use visibility=local>
116
117// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
118// </reviewed>
119
120// <prerequisite>
121//# Classes you should understand before using this one.
122// <li> <linkto class=TableExprNode>TableExprNode</linkto>
123// </prerequisite>
124
125// <etymology>
126// TableExprNodeRep is the (abstract) REPresentation of a node in a table
127// expression tree.
128// </etymology>
129
130// <synopsis>
131// TableExprNodeRep is the base class for all nodes in a table
132// expression tree. It is used by the handle class TableExprNode.
133// <p>
134// The objects of this class are reference-counted to make it possible
135// that the same object is reused.
136// </synopsis>
137
138// <motivation>
139// TableExprNodeRep and its derivations store a table select expression
140// before actually evaluating it. It is also possible that the classes
141// are used by the table expression parser defined in TableParse and
142// TableGram.
143// <br>
144// For each operator a special derived class is implemented.
145// Another approach could have been to store the operator as
146// a flag and switch on that. However, that causes extra overhead
147// and the C++ virtual function mechanism is designed for
148// these purposes.
149// </motivation>
150
151// <todo asof="$DATE:$">
152//# A List of bugs, limitations, extensions or planned refinements.
153// <li> add selection by comparing with a set of values
154// </todo>
155
156
158{
159public:
160 // Define the data types of a node.
169 NTReal, //# NTInt or NTDouble
170 NTDouCom, //# NTDouble or NTComplex
171 NTNumeric, //# NTInt, NTDouble, or NTComplex
172 NTAny //# Any data type
173 };
174
175 // Define the value types.
184
185 // Define the operator types.
186 // LE and LT are handled as GE and GT with swapped operands.
194
195 // Define the value types of the 2 arguments when arrays are involved.
199
200 // Define (sub-)expression type
201 enum ExprType {
202 // A constant subexpression which can be evaluated immediately.
204 // A variable (i.e. row dependent) subexpression which
205 // has to be evaluated for each table row.
207 // An expensive constant subexpression which should only be
208 // evaluated when needed (e.g. a subquery).
209// Lazy
210 };
211
212 // Construct a node.
214 Int ndim, const IPosition& shape,
215 const Table& table);
216
217 // This constructor is called from the derived TableExprNodeRep.
219
220 // Copy constructor.
222
223 // The destructor deletes all the underlying TableExprNode objects.
225
226 // Do not apply the selection.
227 virtual void disableApplySelection();
228
229 // Re-create the column object for a selection of rows.
230 // The default implementation does nothing.
231 virtual void applySelection (const Vector<rownr_t>& rownrs);
232
233 // Get the unit conversion factor.
234 // Default 1 is returned.
235 virtual Double getUnitFactor() const;
236
237 // Throw an exception if an aggregate function is used in
238 // the expression node or its children.
240
241 // Get the nodes representing an aggregate function.
242 virtual void getAggrNodes (std::vector<TableExprNodeRep*>& aggr);
243
244 // Get the nodes representing a table column.
245 virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
246
247 // Create the correct immediate aggregate function object.
248 // The default implementation throws an exception, because it should
249 // only be called for TableExprAggrNode(Array).
251
252 // Is the aggregate function a lazy or an immediate one?
253 // The default implementation returns True
254 // (because all UDF aggregate functions have to be lazy).
255 virtual Bool isLazyAggregate() const;
256
257 // Get a scalar value for this node in the given row.
258 // The appropriate functions are implemented in the derived classes and
259 // will usually invoke the get in their children and apply the
260 // operator on the resulting values.
261 // <group>
262 virtual Bool getBool (const TableExprId& id);
263 virtual Int64 getInt (const TableExprId& id);
264 virtual Double getDouble (const TableExprId& id);
265 virtual DComplex getDComplex (const TableExprId& id);
266 virtual String getString (const TableExprId& id);
267 virtual TaqlRegex getRegex (const TableExprId& id);
268 virtual MVTime getDate (const TableExprId& id);
269 // </group>
270
271 // Get an array value for this node in the given row.
272 // The appropriate functions are implemented in the derived classes and
273 // will usually invoke the get in their children and apply the
274 // operator on the resulting values.
275 // <group>
282 // </group>
283
284 // General get functions for template purposes.
285 // <group>
286 void get (const TableExprId& id, Bool& value)
287 { value = getBool (id); }
288 void get (const TableExprId& id, Int64& value)
289 { value = getInt (id); }
290 void get (const TableExprId& id, Double& value)
291 { value = getDouble (id); }
292 void get (const TableExprId& id, DComplex& value)
293 { value = getDComplex (id); }
294 void get (const TableExprId& id, MVTime& value)
295 { value = getDate (id); }
296 void get (const TableExprId& id, String& value)
297 { value = getString (id); }
299 { value = getArrayBool (id); }
301 { value = getArrayInt (id); }
303 { value = getArrayDouble (id); }
305 { value = getArrayDComplex (id); }
307 { value = getArrayDate (id); }
309 { value = getArrayString (id); }
310 // </group>
311
312 // Get a value as an array, even it it is a scalar.
313 // This is useful if one could give an argument as scalar or array.
314 // <group>
321 // </group>
322
323 // Does a value occur in an array or set?
324 // The default implementation tests if it is in an array.
325 // <group>
326 virtual Bool hasBool (const TableExprId& id, Bool value);
327 virtual Bool hasInt (const TableExprId& id, Int64 value);
328 virtual Bool hasDouble (const TableExprId& id, Double value);
329 virtual Bool hasDComplex (const TableExprId& id, const DComplex& value);
330 virtual Bool hasString (const TableExprId& id, const String& value);
331 virtual Bool hasDate (const TableExprId& id, const MVTime& value);
333 const MArray<Bool>& value);
335 const MArray<Int64>& value);
337 const MArray<Double>& value);
339 const MArray<DComplex>& value);
341 const MArray<String>& value);
343 const MArray<MVTime>& value);
344 // </group>
345
346 // Get the number of rows in the table associated with this expression.
347 // One is returned if the expression is a constant.
348 // Zero is returned if no table is associated with it.
349 rownr_t nrow() const;
350
351 // Get the data type of the column.
352 // It returns True when it could set the data type (which it can
353 // if the expression is a scalar column or a constant array column pixel).
354 // Otherwise it returns False.
355 virtual Bool getColumnDataType (DataType&) const;
356
357 // Get the value of the expression evaluated for the entire column.
358 // The data of function called should match the data type as
359 // returned by function <src>getColumnDataType</src>.
360 // <group>
365 virtual Array<Int> getColumnInt (const Vector<rownr_t>& rownrs);
373 // </group>
374
375 // Convert the tree to a number of range vectors which at least
376 // select the same things.
377 // This function is very useful to convert the expression to
378 // some intervals covering the select expression. This can
379 // be used to do a rough fast selection via an index and do the
380 // the slower final selection on that much smaller subset.
381 // The function can only convert direct comparisons of columns
382 // with constants (via ==, !=, >, >=, < or <=) and their combinations
383 // using && or ||.
385
386 // Get the data type of the derived TableExprNode object.
387 // This is the data type of the resulting value. E.g. a compare
388 // of 2 numeric values results in a Bool, thus the data type
389 // of, say, TableExprNodeEQ<T> is always Bool.
390 // Function getInternalDT gives the internal data type, thus in
391 // the example above the data type of T.
392 NodeDataType dataType() const;
393
394 // Is the data type real (i.e., integer or double)?
395 Bool isReal() const;
396
397 // Get the value type.
398 ValueType valueType() const;
399
400 // Set the value type.
401 void setValueType (ValueType vtype);
402
403 // Get the operator type.
404 OperType operType() const;
405
406 // Get the expression type.
407 ExprType exprType() const;
408
409 // Is the expression a constant?
410 Bool isConstant() const;
411
412 // Get the unit.
413 const Unit& unit() const;
414
415 // Set the unit.
416 // It also sets the datatype to NTDouble if it is NTInt.
417 void setUnit (const Unit& unit);
418
419 // Get the attributes.
420 const Record& attributes() const;
421
422 // Set the attributes.
423 void setAttributes (const Record&);
424
425 // Get the fixed dimensionality (same for all rows).
426 Int ndim() const;
427
428 // Get the fixed shape (same for all rows).
429 const IPosition& shape() const;
430
431 // Get the shape for the given row.
432 // It returns the fixed shape if defined, otherwise getShape(id).
433 const IPosition& shape (const TableExprId& id);
434
435 // Is the value in the given row defined?
436 // The default implementation returns True.
437 virtual Bool isDefined (const TableExprId& id);
438
439 // Show the expression tree.
440 virtual void show (ostream&, uInt indent) const;
441
442 // Get table. This gets the Table object to which a
443 // TableExprNode belongs. A TableExprNode belongs to the Table to
444 // which the first column used in an expression belongs.
445 // <group>
446 Table& table();
447 const Table& table() const;
448 // </group>
449
450 // Replace a node with a constant expression by node with its value.
451 static TENShPtr replaceConstNode (const TENShPtr& node);
452
453 // Let a set node convert itself to the given unit.
454 // The default implementation does nothing.
455 virtual void adaptSetUnits (const Unit&);
456
457 // Create a range object from a column and an interval.
459 TableExprNodeColumn*, Double start, Double end);
460
461 // Create a empty range object.
463
464 // Convert a NodeDataType to a string.
466
467 // Convert a ValueType to a string.
469
470protected:
471 Table table_p; //# Table from which node is "derived"
472 NodeDataType dtype_p; //# data type of the operation
473 ValueType vtype_p; //# value type of the result
474 OperType optype_p; //# operator type
475 ArgType argtype_p; //# argument types
476 ExprType exprtype_p; //# Constant or Variable
477 Int ndim_p; //# Fixed dimensionality of node values
478 //# -1 = variable dimensionality
479 IPosition shape_p; //# Fixed shape of node values
480 Unit unit_p; //# Unit of the values
481 Record attributes_p; //# Possible attributes (for UDFs)
482
483 // Get the shape for the given row.
484 virtual const IPosition& getShape (const TableExprId& id);
485
486 // If one of the children is a constant, convert its data type
487 // to that of the other operand (if appropriate).
488 // This avoids that conversions are done for each get.
489 // The default implementation does nothing.
490 virtual void convertConstChild();
491
492 // Check if this node uses the same table pointer.
493 // Fill the Table object if it is still null.
494 // <group>
495 void checkTablePtr (const TENShPtr& node);
496 static void checkTablePtr (Table& table, const TENShPtr& node);
497 // </group>
498
499 // Set expression type to Variable if node is Variable.
500 // <group>
501 void fillExprType (const TENShPtr& node);
502 static void fillExprType (ExprType&, const TENShPtr& node);
503 // </group>
504
505 // If the node is constant, it is evaluated and replaced by
506 // the appropriate TableExprNodeConst object.
507 // If not constant, it calls the virtual ConvertConstChild function
508 // which can convert a constant child if appropriate.
509 static TENShPtr convertNode (const TENShPtr& thisNode,
510 Bool convertConstType);
511
512private:
513 // A copy of a TableExprNodeRep cannot be made.
515};
516
517
518
519
520
521// <summary>
522// Abstract base class for a node having 0, 1, or 2 child nodes.
523// </summary>
524
525// <use visibility=local>
526
527// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
528// </reviewed>
529
530// <prerequisite>
531//# Classes you should understand before using this one.
532// <li> <linkto class=TableExprNodeRep>TableExprNodeRep</linkto>
533// </prerequisite>
534
535// <etymology>
536// TableExprNodeBinary is a node in the table expression tree
537// representing a binary node (i.e. having up to 2 operands).
538// </etymology>
539
540// <synopsis>
541// TableExprNodeBinary is the abstract base class for all nodes in a table
542// expression tree using up to 2 operands.
543// It is used as the base class for the node classes representing
544// operator +, -, etc..
545// </synopsis>
546
547// <motivation>
548// This class contains the common functionality for the classes
549// representing a binary (or unary) operator.
550// </motivation>
551
552//# <todo asof="$DATE:$">
553//# A List of bugs, limitations, extensions or planned refinements.
554//# <li> to be filled in
555//# </todo>
556
557
559{
560public:
561 // Constructor
564
565 // Destructor
567
568 // Show the expression tree.
569 virtual void show (ostream&, uInt indent) const;
570
571 // Get the nodes representing an aggregate function.
572 virtual void getAggrNodes (std::vector<TableExprNodeRep*>& aggr);
573
574 // Get the nodes representing a table column.
575 virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
576
577 // Check the data types and get the common one.
578 static NodeDataType getDT (NodeDataType leftDtype,
579 NodeDataType rightDype,
581
582 // Check the data and value types and get the common one.
584 const TENShPtr& right,
586
587 // Set the children.
588 // If needed, their properties like data type and unit are adapted.
589 void setChildren (const TENShPtr& left, const TENShPtr& right,
590 Bool adapt=True);
591
592 // Handle the units of the children and possibly set the parent's unit.
593 // The default implementation make the units of the children equal and
594 // set the parent unit to that unit if the parent is not a Bool value.
595 virtual void handleUnits();
596
597 // If one of the children is a constant, convert its data type
598 // to that of the other operand. This avoids that conversions are
599 // done for each get.
601
602 // Get the child nodes.
603 // <group>
604 const TENShPtr& getLeftChild() const
605 { return lnode_p; }
606 const TENShPtr& getRightChild() const
607 { return rnode_p; }
608 // </group>
609
610protected:
611 // Make the units equal.
612 // Replace the right node if needed.
613 static const Unit& makeEqualUnits (const TENShPtr& left,
614 TENShPtr& right);
615
616 TENShPtr lnode_p; //# left operand
617 TENShPtr rnode_p; //# right operand
618};
619
620
621
622
623// <summary>
624// Abstract base class for a node having multiple child nodes.
625// </summary>
626
627// <use visibility=local>
628
629// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
630// </reviewed>
631
632// <prerequisite>
633//# Classes you should understand before using this one.
634// <li> <linkto class=TableExprNodeRep>TableExprNodeRep</linkto>
635// </prerequisite>
636
637// <etymology>
638// TableExprNodeMulti is a node in the table expression tree
639// which can have MULTIple child nodes.
640// </etymology>
641
642// <synopsis>
643// TableExprNodeMulti is the abstract base class for all nodes in a table
644// expression tree using multiple operands.
645// It is used as the base class for the node classes representing
646// functions, sets, indices, etc..
647// </synopsis>
648
649// <motivation>
650// This class contains the common functionality for the classes
651// representing a node with multiple operands.
652// </motivation>
653
654//# <todo asof="$DATE:$">
655//# A List of bugs, limitations, extensions or planned refinements.
656//# <li> to be filled in
657//# </todo>
658
659
661{
662public:
663 // Constructor
665 const TableExprNodeRep& source);
666
667 // Destructor
669
670 // Show the expression tree.
671 virtual void show (ostream&, uInt indent) const;
672
673 // Get the nodes representing an aggregate function.
674 virtual void getAggrNodes (std::vector<TableExprNodeRep*>& aggr);
675
676 // Get the nodes representing a table column.
677 virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
678
679 // Check number of arguments
680 // low <= number_of_args <= high
681 // It throws an exception if wrong number of arguments.
682 static uInt checkNumOfArg (uInt low, uInt high,
683 const std::vector<TENShPtr>& nodes);
684
685 // Get the child nodes.
686 const std::vector<TENShPtr>& getChildren() const
687 { return operands_p; }
688
689 // Check datatype of nodes and return output type.
690 // It also sets the expected data type of the operands (from dtIn).
691 // Conversion of Int,Double.String to Date is by default possible.
692 static NodeDataType checkDT (Block<Int>& dtypeOper,
693 NodeDataType dtIn, NodeDataType dtOut,
694 const std::vector<TENShPtr>& nodes,
695 Bool dateConv=True);
696
697protected:
698 std::vector<TENShPtr> operands_p;
699};
700
701
702
703//# Get the data type of the node.
706
708 { return dtype_p==NTInt || dtype_p==NTDouble; }
709
710//# Get the value type of the node.
713
714//# Set the value type of the node.
717
718//# Get the operator type of the node.
721
722//# Get the expression type of the node.
725
726//# Is the expression a constant?
728 { return (exprtype_p == Constant); }
729
730//# Get the unit of the node.
731inline const Unit& TableExprNodeRep::unit() const
732 { return unit_p; }
733
735 { return attributes_p; }
736
737inline void TableExprNodeRep::setAttributes (const Record& attributes)
739
740//# Get the fixed dimensionality of the node.
742 { return ndim_p; }
743
744//# Get the fixed shape of the node.
746 { return shape_p; }
747
748//# Get the table from which the node is derived.
750 { return table_p; }
751inline const Table& TableExprNodeRep::table() const
752 { return table_p; }
753
755 { checkTablePtr (table_p, node); }
757 { fillExprType (exprtype_p, node); }
758
759
760} //# NAMESPACE CASACORE - END
761
762#endif
simple 1-D array
Definition Block.h:200
Referenced counted pointer for constant data.
Definition CountedPtr.h:81
const String & regexp() const
Get the regular expression string.
Definition Regex.h:251
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.
Definition String.h:225
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.
Definition String.h:377
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)
virtual ~TableExprNodeBinary()
Destructor.
static TableExprNodeRep getCommonTypes(const TENShPtr &left, const TENShPtr &right, OperType operType)
Check the data and value types and get the common one.
virtual void show(ostream &, uInt indent) const
Show the expression tree.
void adaptDataTypes()
If one of the children is a constant, convert its data type to that of the other operand.
const TENShPtr & getRightChild() const
virtual void handleUnits()
Handle the units of the children and possibly set the parent's unit.
virtual void getAggrNodes(std::vector< TableExprNodeRep * > &aggr)
Get the nodes representing an aggregate function.
virtual void getColumnNodes(std::vector< TableExprNodeRep * > &cols)
Get the nodes representing a table column.
TableExprNodeBinary(NodeDataType, ValueType, OperType, const Table &)
Constructor.
static const Unit & makeEqualUnits(const TENShPtr &left, TENShPtr &right)
Make the units equal.
const TENShPtr & getLeftChild() const
Get the child nodes.
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.
virtual void show(ostream &, uInt indent) const
Show the expression tree.
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.
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.
virtual void getColumnNodes(std::vector< TableExprNodeRep * > &cols)
Get the nodes representing a table column.
virtual void getAggrNodes(std::vector< TableExprNodeRep * > &aggr)
Get the nodes representing an aggregate function.
std::vector< TENShPtr > operands_p
virtual ~TableExprNodeMulti()
Destructor.
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.
rownr_t nrow() const
Get the number of rows in the table associated with this expression.
const Unit & unit() const
Get the unit.
virtual Array< DComplex > getColumnDComplex(const Vector< rownr_t > &rownrs)
void get(const TableExprId &id, MArray< Double > &value)
void get(const TableExprId &id, DComplex &value)
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 MArray< Bool > hasArrayDComplex(const TableExprId &id, const MArray< DComplex > &value)
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.
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)
MArray< Double > getDoubleAS(const TableExprId &id)
void setUnit(const Unit &unit)
Set the unit.
TableExprNodeRep(NodeDataType, ValueType, OperType, ArgType, ExprType, Int ndim, const IPosition &shape, const Table &table)
Construct a node.
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 MArray< Double > getArrayDouble(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.
TableExprNodeRep(const TableExprNodeRep &)
Copy constructor.
virtual Bool hasInt(const TableExprId &id, Int64 value)
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.
void fillExprType(const TENShPtr &node)
Set expression type to Variable if node is Variable.
virtual void getColumnNodes(std::vector< TableExprNodeRep * > &cols)
Get the nodes representing a table column.
virtual Bool getBool(const TableExprId &id)
Get a scalar value for this node in the given row.
virtual DComplex getDComplex(const TableExprId &id)
virtual void convertConstChild()
If one of the children is a constant, convert its data type to that of the other operand (if appropri...
virtual MArray< Bool > hasArrayDate(const TableExprId &id, const MArray< MVTime > &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 MArray< DComplex > getArrayDComplex(const TableExprId &id)
void get(const TableExprId &id, Bool &value)
General get functions for template purposes.
virtual Bool hasString(const TableExprId &id, const String &value)
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.
void checkAggrFuncs()
Throw an exception if an aggregate function is used in the expression node or its children.
virtual ~TableExprNodeRep()
The destructor deletes all the underlying TableExprNode objects.
TableExprNodeRep(NodeDataType, ValueType, OperType, const Table &)
This constructor is called from the derived TableExprNodeRep.
MArray< MVTime > getDateAS(const TableExprId &id)
virtual void getAggrNodes(std::vector< TableExprNodeRep * > &aggr)
Get the nodes representing an aggregate function.
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 TaqlRegex getRegex(const TableExprId &id)
virtual MArray< Bool > getArrayBool(const TableExprId &id)
Get an array value for this node in the given row.
MArray< Bool > getBoolAS(const TableExprId &id)
Get a value as an array, even it it is a scalar.
TableExprNodeRep & operator=(const TableExprNodeRep &)
A copy of a TableExprNodeRep cannot be made.
static void checkTablePtr(Table &table, const TENShPtr &node)
virtual Array< Complex > getColumnComplex(const Vector< rownr_t > &rownrs)
virtual MArray< Bool > hasArrayString(const TableExprId &id, const MArray< String > &value)
virtual Double getDouble(const TableExprId &id)
virtual Int64 getInt(const TableExprId &id)
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 Bool hasDate(const TableExprId &id, const MVTime &value)
virtual void show(ostream &, uInt indent) const
Show the expression tree.
virtual MVTime getDate(const TableExprId &id)
void checkTablePtr(const TENShPtr &node)
Check if this node uses the same table pointer.
virtual Bool hasDComplex(const TableExprId &id, const DComplex &value)
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.
virtual MArray< Bool > hasArrayDouble(const TableExprId &id, const MArray< Double > &value)
void get(const TableExprId &id, Int64 &value)
virtual Bool hasDouble(const TableExprId &id, Double value)
Table & table()
Get table.
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.
OperType operType() const
Get the operator type.
void get(const TableExprId &id, Double &value)
void get(const TableExprId &id, MArray< DComplex > &value)
virtual MArray< Bool > hasArrayBool(const TableExprId &id, const MArray< Bool > &value)
virtual MArray< Bool > hasArrayInt(const TableExprId &id, const MArray< Int64 > &value)
ValueType
Define the value types.
virtual CountedPtr< TableExprGroupFuncBase > makeGroupAggrFunc()
Create the correct immediate aggregate function object.
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)
static void fillExprType(ExprType &, const TENShPtr &node)
TaqlRegex(const Regex &regex)
Construct from a regex.
Definition ExprNodeRep.h:85
StringDistance itsDist
Bool match(const String &str) const
Does the regex or maximum string distance match?
Definition ExprNodeRep.h:95
TaqlRegex(const StringDistance &dist)
Construct from a StringDistance.
Definition ExprNodeRep.h:90
const Regex & regex() const
Return the regular expression.
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:51
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition aipsxtype.h:38
CountedPtr< TableExprNodeRep > TENShPtr
Definition ExprNodeRep.h:57
int Int
Definition aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:42
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
const Bool True
Definition aipstype.h:43
double Double
Definition aipstype.h:55
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:46