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: casa-feedback@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#ifndef TABLES_EXPRNODEREP_H
27#define TABLES_EXPRNODEREP_H
28
29//# Includes
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>
43#include <vector>
44
45namespace casacore { //# NAMESPACE CASACORE - BEGIN
46
47//# Forward Declarations
48class TableExprNode;
49class TableExprNodeColumn;
50class TableExprGroupFuncBase;
51template<class T> class Block;
52
53//# Define a shared pointer to the Rep class.
54class TableExprNodeRep;
55typedef std::shared_ptr<TableExprNodeRep> TENShPtr;
56
57
58// <summary>
59// Class to handle a Regex or StringDistance.
60// </summary>
61
62// <use visibility=local>
63
64// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
65// </reviewed>
66
67// <prerequisite>
68//# Classes you should understand before using this one.
69// <li> <linkto class=Regex>Regex</linkto>
70// <li> <linkto class=StringDistance>StringDistance</linkto>
71// </prerequisite>
72
73// <synopsis>
74// A StringDistance (Levensthein distance) in TaQL is given in the same way
75// as a Regex. This class is needed to have a single object in the parse tree
76// objects containing them (in class TableExprNodeConstRegex).
77// </synopsis>
78
80{
81public:
82 // Construct from a regex.
83 explicit TaqlRegex (const Regex& regex)
85 {}
86
87 // Construct from a StringDistance.
88 explicit TaqlRegex (const StringDistance& dist)
89 : itsDist(dist)
90 {}
91
92 // Does the regex or maximum string distance match?
93 Bool match (const String& str) const
94 { return itsRegex.regexp().empty() ?
95 itsDist.match(str) : str.matches(itsRegex);
96 }
97
98 // Return the regular expression.
99 const Regex& regex() const
100 { return itsRegex; }
101
102private:
105};
106
107
108
109 // <summary>
110// Class to connect a Table and its alias name
111// </summary>
112
113// <use visibility=local>
114
115// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
116// </reviewed>
117
118// <synopsis>
119// This class connects a Table object to its alias name used in a TaQL command.
120// If no alias is given, the table name is used as such.
121// It also tells if the Table is used as a join table.
122// </synopsis>
123
125{
126public:
127 // Construct from a table and its alias.
128 explicit TableExprInfo (const Table& table = Table(),
129 const String& alias = String(),
131
132 // Get the Table object.
133 const Table& table() const
134 { return itsTable; }
135
136 // Get the alias.
137 const String& alias() const
138 { return itsAlias; }
139
140 // Is the table a join table?
142 { return itsIsJoinTable; }
143
144 // Apply a selection of row numbers to the Table.
145 void apply (const Vector<rownr_t>& rownrs);
146
147private:
151};
152
153
154
155// <summary>
156// Abstract base class for a node in a table column expression tree
157// </summary>
158
159// <use visibility=local>
160
161// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
162// </reviewed>
163
164// <prerequisite>
165//# Classes you should understand before using this one.
166// <li> <linkto class=TableExprNode>TableExprNode</linkto>
167// </prerequisite>
168
169// <etymology>
170// TableExprNodeRep is the (abstract) REPresentation of a node in a table
171// expression tree.
172// </etymology>
173
174// <synopsis>
175// TableExprNodeRep is the base class for all nodes in a table
176// expression tree. It is used by the handle class TableExprNode.
177// <p>
178// The objects of this class are reference-counted to make it possible
179// that the same object is reused.
180// </synopsis>
181
182// <motivation>
183// TableExprNodeRep and its derivations store a table select expression
184// before actually evaluating it. It is also possible that the classes
185// are used by the table expression parser defined in TableParse and
186// TableGram.
187// <br>
188// For each operator a special derived class is implemented.
189// Another approach could have been to store the operator as
190// a flag and switch on that. However, that causes extra overhead
191// and the C++ virtual function mechanism is designed for
192// these purposes.
193// </motivation>
194
195// <todo asof="$DATE:$">
196//# A List of bugs, limitations, extensions or planned refinements.
197// <li> add selection by comparing with a set of values
198// </todo>
199
200
202{
203public:
204 // Define the data types of a node.
213 NTReal, //# NTInt or NTDouble
214 NTDouCom, //# NTDouble or NTComplex
215 NTNumeric, //# NTInt, NTDouble, or NTComplex
216 NTAny //# Any data type
217 };
218
219 // Define the value types.
228
229 // Define the operator types.
230 // LE and LT are handled as GE and GT with swapped operands.
238
239 // Define the value types of the 2 arguments when arrays are involved.
243
244 // Define (sub-)expression type
245 enum ExprType {
246 // A constant subexpression which can be evaluated immediately.
248 // A variable (i.e. row dependent) subexpression which
249 // has to be evaluated for each table row.
251 // An expensive constant subexpression which should only be
252 // evaluated when needed (e.g. a subquery).
253// Lazy
254 };
255
256 // Construct a node.
258 Int ndim, const IPosition& shape);
259
260 // This constructor is called from the derived TableExprNodeRep.
262
263 // Copy constructor.
265
266 // Assign to a TableExprNodeRep cannot be done.
268
269 // The destructor deletes all the underlying TableExprNode objects.
270 virtual ~TableExprNodeRep() = default;
271
272 // Is the node an aggegation node.
273 // The default implementation returns False.
274 virtual Bool isAggregate() const;
275
276 // Get the table info.
277 // The default implementation returns an info object with a null table.
279
280 // Try to optimize the node (meant for the right hand of the IN operator).
281 // The default implementation does nothing.
282 virtual void optimize();
283
284 // Do not apply the selection.
285 virtual void disableApplySelection();
286
287 // Re-create the column object for a selection of rows.
288 // The default implementation does nothing.
289 virtual void applySelection (const Vector<rownr_t>& rownrs);
290
291 // Get the unit conversion factor.
292 // Default 1 is returned.
293 virtual Double getUnitFactor() const;
294
295 // Flatten the node tree by adding the node and its children to the vector.
296 virtual void flattenTree (std::vector<TableExprNodeRep*>&);
297
298 // Create the correct immediate aggregate function object.
299 // The default implementation throws an exception, because it should
300 // only be called for TableExprAggrNode(Array).
301 virtual std::shared_ptr<TableExprGroupFuncBase> makeGroupAggrFunc();
302
303 // Is the aggregate function a lazy or an immediate one?
304 // The default implementation returns True
305 // (because all UDF aggregate functions have to be lazy).
306 virtual Bool isLazyAggregate() const;
307
308 // Get a scalar value for this node in the given row.
309 // The appropriate functions are implemented in the derived classes and
310 // will usually invoke the get in their children and apply the
311 // operator on the resulting values.
312 // <group>
313 virtual Bool getBool (const TableExprId& id);
314 virtual Int64 getInt (const TableExprId& id);
315 virtual Double getDouble (const TableExprId& id);
316 virtual DComplex getDComplex (const TableExprId& id);
317 virtual String getString (const TableExprId& id);
318 virtual TaqlRegex getRegex (const TableExprId& id);
319 virtual MVTime getDate (const TableExprId& id);
320 // </group>
321
322 // Get an array value for this node in the given row.
323 // The appropriate functions are implemented in the derived classes and
324 // will usually invoke the get in their children and apply the
325 // operator on the resulting values.
326 // <group>
333 // </group>
334
335 // General get functions for template purposes.
336 // <group>
337 void get (const TableExprId& id, Bool& value)
338 { value = getBool (id); }
339 void get (const TableExprId& id, Int64& value)
340 { value = getInt (id); }
341 void get (const TableExprId& id, Double& value)
342 { value = getDouble (id); }
343 void get (const TableExprId& id, DComplex& value)
344 { value = getDComplex (id); }
345 void get (const TableExprId& id, MVTime& value)
346 { value = getDate (id); }
347 void get (const TableExprId& id, String& value)
348 { value = getString (id); }
350 { value = getArrayBool (id); }
352 { value = getArrayInt (id); }
354 { value = getArrayDouble (id); }
356 { value = getArrayDComplex (id); }
358 { value = getArrayDate (id); }
360 { value = getArrayString (id); }
361 // </group>
362
363 // Get a value as an array, even it it is a scalar.
364 // This is useful if one could give an argument as scalar or array.
365 // <group>
372 // </group>
373
374 // Does a set or array contain the value?
375 // The default implementation assumes the set is a single scalar,
376 // thus tests if it is equal to the given value.
377 // <group>
378 virtual Bool contains (const TableExprId& id, Bool value);
379 virtual Bool contains (const TableExprId& id, Int64 value);
380 virtual Bool contains (const TableExprId& id, Double value);
381 virtual Bool contains (const TableExprId& id, DComplex value);
382 virtual Bool contains (const TableExprId& id, String value);
383 virtual Bool contains (const TableExprId& id, MVTime value);
385 const MArray<Bool>& value);
387 const MArray<Int64>& value);
389 const MArray<Double>& value);
391 const MArray<DComplex>& value);
393 const MArray<String>& value);
395 const MArray<MVTime>& value);
396 // </group>
397
398 // Get the number of rows in the table associated with this expression.
399 // One is returned if the expression is a constant or no table is
400 // associated with it.
402
403 // Get the data type of the column.
404 // It returns True when it could set the data type (which it can
405 // if the expression is a scalar column or a constant array column pixel).
406 // Otherwise it returns False.
407 virtual Bool getColumnDataType (DataType&) const;
408
409 // Get the value of the expression evaluated for the entire column.
410 // The data of function called should match the data type as
411 // returned by function <src>getColumnDataType</src>.
412 // <group>
417 virtual Array<Int> getColumnInt (const Vector<rownr_t>& rownrs);
425 // </group>
426
427 // Convert the tree to a number of range vectors which at least
428 // select the same things.
429 // This function is very useful to convert the expression to
430 // some intervals covering the select expression. This can
431 // be used to do a rough fast selection via an index and do the
432 // the slower final selection on that much smaller subset.
433 // The function can only convert direct comparisons of columns
434 // with constants (via ==, !=, >, >=, < or <=) and their combinations
435 // using && or ||.
437
438 // Get the data type of the derived TableExprNode object.
439 // This is the data type of the resulting value. E.g. a compare
440 // of 2 numeric values results in a Bool, thus the data type
441 // of, say, TableExprNodeEQ<T> is always Bool.
442 // Function getInternalDT gives the internal data type, thus in
443 // the example above the data type of T.
444 NodeDataType dataType() const;
445
446 // Is the data type real (i.e., integer or double)?
447 Bool isReal() const;
448
449 // Get the value type.
450 ValueType valueType() const;
451
452 // Set the value type.
453 void setValueType (ValueType vtype);
454
455 // Get the operator type.
456 OperType operType() const;
457
458 // Get the expression type.
459 ExprType exprType() const;
460
461 // Is the expression a constant?
462 Bool isConstant() const;
463
464 // Get the unit.
465 const Unit& unit() const;
466
467 // Set the unit.
468 // It also sets the datatype to NTDouble if it is NTInt.
469 void setUnit (const Unit& unit);
470
471 // Get the attributes.
472 const Record& attributes() const;
473
474 // Set the attributes.
475 void setAttributes (const Record&);
476
477 // Get the fixed dimensionality (same for all rows).
478 Int ndim() const;
479
480 // Get the fixed shape (same for all rows).
481 const IPosition& shape() const;
482
483 // Get the shape for the given row.
484 // It returns the fixed shape if defined, otherwise getShape(id).
485 const IPosition& shape (const TableExprId& id);
486
487 // Is the value in the given row defined?
488 // The default implementation returns True.
489 virtual Bool isDefined (const TableExprId& id);
490
491 // Show the expression tree.
492 virtual void show (ostream&, uInt indent) const;
493
494 // Replace a node with a constant expression by node with its value.
495 static TENShPtr replaceConstNode (const TENShPtr& node);
496
497 // Let a set node convert itself to the given unit.
498 // The default implementation does nothing.
499 virtual void adaptSetUnits (const Unit&);
500
501 // Create a range object from a column and an interval.
503 TableExprNodeColumn*, Double start, Double end);
504
505 // Create a empty range object.
507
508 // Convert a NodeDataType to a string.
510
511 // Convert a ValueType to a string.
513
514protected:
515 NodeDataType dtype_p; //# data type of the operation
516 ValueType vtype_p; //# value type of the result
517 OperType optype_p; //# operator type
518 ArgType argtype_p; //# argument types
519 ExprType exprtype_p; //# Constant or Variable
520 Int ndim_p; //# Fixed dimensionality of node values
521 //# -1 = variable dimensionality
522 IPosition shape_p; //# Fixed shape of node values
523 Unit unit_p; //# Unit of the values
524 Record attributes_p; //# Possible attributes (for UDFs)
525
526 // Get the shape for the given row.
527 virtual const IPosition& getShape (const TableExprId& id);
528
529 // Set expression type to Variable if node is Variable.
530 void fillExprType (const TableExprNodeRep* node);
531
532 // If the node is constant, it is evaluated and replaced by
533 // the appropriate TableExprNodeConst object.
534 // If not constant, it calls the virtual ConvertConstChild function
535 // which can convert a constant child if appropriate.
536 static TENShPtr convertNode (const TENShPtr& thisNode,
537 Bool convertConstType);
538};
539
540
541
542
543
544// <summary>
545// Abstract base class for a node having 0, 1, or 2 child nodes.
546// </summary>
547
548// <use visibility=local>
549
550// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
551// </reviewed>
552
553// <prerequisite>
554//# Classes you should understand before using this one.
555// <li> <linkto class=TableExprNodeRep>TableExprNodeRep</linkto>
556// </prerequisite>
557
558// <etymology>
559// TableExprNodeBinary is a node in the table expression tree
560// representing a binary node (i.e. having up to 2 operands).
561// </etymology>
562
563// <synopsis>
564// TableExprNodeBinary is the abstract base class for all nodes in a table
565// expression tree using up to 2 operands.
566// It is used as the base class for the node classes representing
567// operator +, -, etc..
568// </synopsis>
569
570// <motivation>
571// This class contains the common functionality for the classes
572// representing a binary (or unary) operator.
573// </motivation>
574
575//# <todo asof="$DATE:$">
576//# A List of bugs, limitations, extensions or planned refinements.
577//# <li> to be filled in
578//# </todo>
579
580
582{
583public:
584 // Constructor
587
588 // Destructor
589 ~TableExprNodeBinary() override = default;
590
591 // Show the expression tree.
592 void show (ostream&, uInt indent) const override;
593
594 // Flatten the node tree by adding the node and its children to the vector.
595 void flattenTree (std::vector<TableExprNodeRep*>&) override;
596
597 // Check the data types and get the common one.
598 static NodeDataType getDT (NodeDataType leftDtype,
599 NodeDataType rightDype,
601
602 // Check the data and value types and get the common one.
604 const TENShPtr& right,
606
607 // Set the children.
608 // If needed, their properties like data type and unit are adapted.
609 void setChildren (const TENShPtr& left, const TENShPtr& right,
610 Bool adapt=True);
611
612 // Handle the units of the children and possibly set the parent's unit.
613 // The default implementation make the units of the children equal and
614 // set the parent unit to that unit if the parent is not a Bool value.
615 virtual void handleUnits();
616
617 // If one of the children is a constant, convert its data type
618 // to that of the other operand. This avoids that conversions are
619 // done for each get.
621
622 // Get the child nodes.
623 // <group>
624 const TENShPtr& getLeftChild() const
625 { return lnode_p; }
626 const TENShPtr& getRightChild() const
627 { return rnode_p; }
628 // </group>
629
630protected:
631 // Make the units equal.
632 // Replace the right node if needed.
633 static const Unit& makeEqualUnits (const TENShPtr& left,
634 TENShPtr& right);
635
636 TENShPtr lnode_p; //# left operand
637 TENShPtr rnode_p; //# right operand
638};
639
640
641
642
643// <summary>
644// Abstract base class for a node having multiple child nodes.
645// </summary>
646
647// <use visibility=local>
648
649// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
650// </reviewed>
651
652// <prerequisite>
653//# Classes you should understand before using this one.
654// <li> <linkto class=TableExprNodeRep>TableExprNodeRep</linkto>
655// </prerequisite>
656
657// <etymology>
658// TableExprNodeMulti is a node in the table expression tree
659// which can have MULTIple child nodes.
660// </etymology>
661
662// <synopsis>
663// TableExprNodeMulti is the abstract base class for all nodes in a table
664// expression tree using multiple operands.
665// It is used as the base class for the node classes representing
666// functions, sets, indices, etc..
667// </synopsis>
668
669// <motivation>
670// This class contains the common functionality for the classes
671// representing a node with multiple operands.
672// </motivation>
673
674//# <todo asof="$DATE:$">
675//# A List of bugs, limitations, extensions or planned refinements.
676//# <li> to be filled in
677//# </todo>
678
679
681{
682public:
683 // Constructor
685 const TableExprNodeRep& source);
686
687 // Destructor
688 ~TableExprNodeMulti() override = default;
689
690 // Show the expression tree.
691 void show (ostream&, uInt indent) const override;
692
693 // Flatten the node tree by adding the node and its children to the vector.
694 void flattenTree (std::vector<TableExprNodeRep*>&) override;
695
696 // Check number of arguments
697 // low <= number_of_args <= high
698 // It throws an exception if wrong number of arguments.
699 static uInt checkNumOfArg (uInt low, uInt high,
700 const std::vector<TENShPtr>& nodes);
701
702 // Get the child nodes.
703 const std::vector<TENShPtr>& getChildren() const
704 { return operands_p; }
705
706 // Check datatype of nodes and return output type.
707 // It also sets the expected data type of the operands (from dtIn).
708 // Conversion of Int,Double.String to Date is by default possible.
709 static NodeDataType checkDT (Block<Int>& dtypeOper,
710 NodeDataType dtIn, NodeDataType dtOut,
711 const std::vector<TENShPtr>& nodes,
712 Bool dateConv=True);
713
714protected:
715 std::vector<TENShPtr> operands_p;
716};
717
718
719
720//# Get the data type of the node.
723
725 { return dtype_p==NTInt || dtype_p==NTDouble; }
726
727//# Get the value type of the node.
730
731//# Set the value type of the node.
734
735//# Get the operator type of the node.
738
739//# Get the expression type of the node.
742
743//# Is the expression a constant?
745 { return (exprtype_p == Constant); }
746
747//# Get the unit of the node.
748inline const Unit& TableExprNodeRep::unit() const
749 { return unit_p; }
750
752 { return attributes_p; }
753
754inline void TableExprNodeRep::setAttributes (const Record& attributes)
756
757//# Get the fixed dimensionality of the node.
759 { return ndim_p; }
760
761//# Get the fixed shape of the node.
763 { return shape_p; }
764
765
766} //# NAMESPACE CASACORE - END
767
768#endif
simple 1-D array
Definition Block.h:198
const String & regexp() const
Get the regular expression string.
Definition Regex.h:245
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:223
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:375
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 &regex)
Construct from a regex.
Definition ExprNodeRep.h:83
StringDistance itsDist
Bool match(const String &str) const
Does the regex or maximum string distance match?
Definition ExprNodeRep.h:93
TaqlRegex(const StringDistance &dist)
Construct from a StringDistance.
Definition ExprNodeRep.h:88
const Regex & regex() const
Return the regular expression.
Definition ExprNodeRep.h:99
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition aipsxtype.h:36
std::shared_ptr< TableExprNodeRep > TENShPtr
Definition ExprNodeRep.h:55
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44