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;
51template <class T>
52class Block;
53
54// # Define a shared pointer to the Rep class.
56typedef std::shared_ptr<TableExprNodeRep> TENShPtr;
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
79class TaqlRegex {
80 public:
81 // Construct from a regex.
82 explicit TaqlRegex(const Regex& regex) : itsRegex(regex) {}
83
84 // Construct from a StringDistance.
85 explicit TaqlRegex(const StringDistance& dist) : itsDist(dist) {}
86
87 // Does the regex or maximum string distance match?
88 Bool match(const String& str) const {
89 return itsRegex.regexp().empty() ? itsDist.match(str) : RegexMatches(str, itsRegex);
90 }
91
92 // Return the regular expression.
93 const Regex& regex() const { return itsRegex; }
94
95 private:
98};
99
100// <summary>
101// Class to connect a Table and its alias name
102// </summary>
103
104// <use visibility=local>
105
106// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
107// </reviewed>
108
109// <synopsis>
110// This class connects a Table object to its alias name used in a TaQL command.
111// If no alias is given, the table name is used as such.
112// It also tells if the Table is used as a join table.
113// </synopsis>
114
116 public:
117 // Construct from a table and its alias.
118 explicit TableExprInfo(const Table& table = Table(), const String& alias = String(),
120
121 // Get the Table object.
122 const Table& table() const { return itsTable; }
123
124 // Get the alias.
125 const String& alias() const { return itsAlias; }
126
127 // Is the table a join table?
128 Bool isJoinTable() const { return itsIsJoinTable; }
129
130 // Apply a selection of row numbers to the Table.
131 void apply(const Vector<rownr_t>& rownrs);
132
133 private:
137};
138
139// <summary>
140// Abstract base class for a node in a table column expression tree
141// </summary>
142
143// <use visibility=local>
144
145// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
146// </reviewed>
147
148// <prerequisite>
149// # Classes you should understand before using this one.
150// <li> <linkto class=TableExprNode>TableExprNode</linkto>
151// </prerequisite>
152
153// <etymology>
154// TableExprNodeRep is the (abstract) REPresentation of a node in a table
155// expression tree.
156// </etymology>
157
158// <synopsis>
159// TableExprNodeRep is the base class for all nodes in a table
160// expression tree. It is used by the handle class TableExprNode.
161// <p>
162// The objects of this class are reference-counted to make it possible
163// that the same object is reused.
164// </synopsis>
165
166// <motivation>
167// TableExprNodeRep and its derivations store a table select expression
168// before actually evaluating it. It is also possible that the classes
169// are used by the table expression parser defined in TableParse and
170// TableGram.
171// <br>
172// For each operator a special derived class is implemented.
173// Another approach could have been to store the operator as
174// a flag and switch on that. However, that causes extra overhead
175// and the C++ virtual function mechanism is designed for
176// these purposes.
177// </motivation>
178
179// <todo asof="$DATE:$">
180// # A List of bugs, limitations, extensions or planned refinements.
181// <li> add selection by comparing with a set of values
182// </todo>
183
185 public:
186 // Define the data types of a node.
195 NTReal, // # NTInt or NTDouble
196 NTDouCom, // # NTDouble or NTComplex
197 NTNumeric, // # NTInt, NTDouble, or NTComplex
198 NTAny // # Any data type
199 };
200
201 // Define the value types.
203
204 // Define the operator types.
205 // LE and LT are handled as GE and GT with swapped operands.
234
235 // Define the value types of the 2 arguments when arrays are involved.
237
238 // Define (sub-)expression type
239 enum ExprType {
240 // A constant subexpression which can be evaluated immediately.
242 // A variable (i.e. row dependent) subexpression which
243 // has to be evaluated for each table row.
245 // An expensive constant subexpression which should only be
246 // evaluated when needed (e.g. a subquery).
247 // Lazy
248 };
249
250 // Construct a node.
252 const IPosition& shape);
253
254 // This constructor is called from the derived TableExprNodeRep.
256
257 // Copy constructor.
259
260 // Assign to a TableExprNodeRep cannot be done.
262
263 // The destructor deletes all the underlying TableExprNode objects.
264 virtual ~TableExprNodeRep() = default;
265
266 // Is the node an aggegation node.
267 // The default implementation returns False.
268 virtual Bool isAggregate() const;
269
270 // Get the table info.
271 // The default implementation returns an info object with a null table.
273
274 // Try to optimize the node (meant for the right hand of the IN operator).
275 // The default implementation does nothing.
276 virtual void optimize();
277
278 // Do not apply the selection.
279 virtual void disableApplySelection();
280
281 // Re-create the column object for a selection of rows.
282 // The default implementation does nothing.
283 virtual void applySelection(const Vector<rownr_t>& rownrs);
284
285 // Get the unit conversion factor.
286 // Default 1 is returned.
287 virtual Double getUnitFactor() const;
288
289 // Flatten the node tree by adding the node and its children to the vector.
290 virtual void flattenTree(std::vector<TableExprNodeRep*>&);
291
292 // Create the correct immediate aggregate function object.
293 // The default implementation throws an exception, because it should
294 // only be called for TableExprAggrNode(Array).
295 virtual std::shared_ptr<TableExprGroupFuncBase> makeGroupAggrFunc();
296
297 // Is the aggregate function a lazy or an immediate one?
298 // The default implementation returns True
299 // (because all UDF aggregate functions have to be lazy).
300 virtual Bool isLazyAggregate() const;
301
302 // Get a scalar value for this node in the given row.
303 // The appropriate functions are implemented in the derived classes and
304 // will usually invoke the get in their children and apply the
305 // operator on the resulting values.
306 // <group>
307 virtual Bool getBool(const TableExprId& id);
308 virtual Int64 getInt(const TableExprId& id);
309 virtual Double getDouble(const TableExprId& id);
310 virtual DComplex getDComplex(const TableExprId& id);
311 virtual String getString(const TableExprId& id);
312 virtual TaqlRegex getRegex(const TableExprId& id);
313 virtual MVTime getDate(const TableExprId& id);
314 // </group>
315
316 // Get an array value for this node in the given row.
317 // The appropriate functions are implemented in the derived classes and
318 // will usually invoke the get in their children and apply the
319 // operator on the resulting values.
320 // <group>
327 // </group>
328
329 // General get functions for template purposes.
330 // <group>
331 void get(const TableExprId& id, Bool& value) { value = getBool(id); }
332 void get(const TableExprId& id, Int64& value) { value = getInt(id); }
333 void get(const TableExprId& id, Double& value) { value = getDouble(id); }
334 void get(const TableExprId& id, DComplex& value) { value = getDComplex(id); }
335 void get(const TableExprId& id, MVTime& value) { value = getDate(id); }
336 void get(const TableExprId& id, String& value) { value = getString(id); }
337 void get(const TableExprId& id, MArray<Bool>& value) { value = getArrayBool(id); }
338 void get(const TableExprId& id, MArray<Int64>& value) { value = getArrayInt(id); }
343 // </group>
344
345 // Get a value as an array, even it it is a scalar.
346 // This is useful if one could give an argument as scalar or array.
347 // <group>
354 // </group>
355
356 // Does a set or array contain the value?
357 // The default implementation assumes the set is a single scalar,
358 // thus tests if it is equal to the given value.
359 // <group>
360 virtual Bool contains(const TableExprId& id, Bool value);
361 virtual Bool contains(const TableExprId& id, Int64 value);
362 virtual Bool contains(const TableExprId& id, Double value);
363 virtual Bool contains(const TableExprId& id, DComplex value);
364 virtual Bool contains(const TableExprId& id, String value);
365 virtual Bool contains(const TableExprId& id, MVTime value);
372 // </group>
373
374 // Get the number of rows in the table associated with this expression.
375 // One is returned if the expression is a constant or no table is
376 // associated with it.
378
379 // Get the data type of the column.
380 // It returns True when it could set the data type (which it can
381 // if the expression is a scalar column or a constant array column pixel).
382 // Otherwise it returns False.
383 virtual Bool getColumnDataType(DataType&) const;
384
385 // Get the value of the expression evaluated for the entire column.
386 // The data of function called should match the data type as
387 // returned by function <src>getColumnDataType</src>.
388 // <group>
401 // </group>
402
403 // Convert the tree to a number of range vectors which at least
404 // select the same things.
405 // This function is very useful to convert the expression to
406 // some intervals covering the select expression. This can
407 // be used to do a rough fast selection via an index and do the
408 // the slower final selection on that much smaller subset.
409 // The function can only convert direct comparisons of columns
410 // with constants (via ==, !=, >, >=, < or <=) and their combinations
411 // using && or ||.
413
414 // Get the data type of the derived TableExprNode object.
415 // This is the data type of the resulting value. E.g. a compare
416 // of 2 numeric values results in a Bool, thus the data type
417 // of, say, TableExprNodeEQ<T> is always Bool.
418 // Function getInternalDT gives the internal data type, thus in
419 // the example above the data type of T.
420 NodeDataType dataType() const;
421
422 // Is the data type real (i.e., integer or double)?
423 Bool isReal() const;
424
425 // Get the value type.
426 ValueType valueType() const;
427
428 // Set the value type.
429 void setValueType(ValueType vtype);
430
431 // Get the operator type.
432 OperType operType() const;
433
434 // Get the expression type.
435 ExprType exprType() const;
436
437 // Is the expression a constant?
438 Bool isConstant() const;
439
440 // Get the unit.
441 const Unit& unit() const;
442
443 // Set the unit.
444 // It also sets the datatype to NTDouble if it is NTInt.
445 void setUnit(const Unit& unit);
446
447 // Get the attributes.
448 const Record& attributes() const;
449
450 // Set the attributes.
451 void setAttributes(const Record&);
452
453 // Get the fixed dimensionality (same for all rows).
454 Int ndim() const;
455
456 // Get the fixed shape (same for all rows).
457 const IPosition& shape() const;
458
459 // Get the shape for the given row.
460 // It returns the fixed shape if defined, otherwise getShape(id).
461 const IPosition& shape(const TableExprId& id);
462
463 // Is the value in the given row defined?
464 // The default implementation returns True.
465 virtual Bool isDefined(const TableExprId& id);
466
467 // Show the expression tree.
468 virtual void show(ostream&, uInt indent) const;
469
470 // Replace a node with a constant expression by node with its value.
471 static TENShPtr replaceConstNode(const TENShPtr& node);
472
473 // Let a set node convert itself to the given unit.
474 // The default implementation does nothing.
475 virtual void adaptSetUnits(const Unit&);
476
477 // Create a range object from a column and an interval.
479
480 // Create a empty range object.
482
483 // Convert a NodeDataType to a string.
485
486 // Convert a ValueType to a string.
488
489 protected:
490 NodeDataType dtype_p; // # data type of the operation
491 ValueType vtype_p; // # value type of the result
492 OperType optype_p; // # operator type
493 ArgType argtype_p; // # argument types
494 ExprType exprtype_p; // # Constant or Variable
495 Int ndim_p; // # Fixed dimensionality of node values
496 // # -1 = variable dimensionality
497 IPosition shape_p; // # Fixed shape of node values
498 Unit unit_p; // # Unit of the values
499 Record attributes_p; // # Possible attributes (for UDFs)
500
501 // Get the shape for the given row.
502 virtual const IPosition& getShape(const TableExprId& id);
503
504 // Set expression type to Variable if node is Variable.
506
507 // If the node is constant, it is evaluated and replaced by
508 // the appropriate TableExprNodeConst object.
509 // If not constant, it calls the virtual ConvertConstChild function
510 // which can convert a constant child if appropriate.
511 static TENShPtr convertNode(const TENShPtr& thisNode, Bool convertConstType);
512};
513
514// <summary>
515// Abstract base class for a node having 0, 1, or 2 child nodes.
516// </summary>
517
518// <use visibility=local>
519
520// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
521// </reviewed>
522
523// <prerequisite>
524// # Classes you should understand before using this one.
525// <li> <linkto class=TableExprNodeRep>TableExprNodeRep</linkto>
526// </prerequisite>
527
528// <etymology>
529// TableExprNodeBinary is a node in the table expression tree
530// representing a binary node (i.e. having up to 2 operands).
531// </etymology>
532
533// <synopsis>
534// TableExprNodeBinary is the abstract base class for all nodes in a table
535// expression tree using up to 2 operands.
536// It is used as the base class for the node classes representing
537// operator +, -, etc..
538// </synopsis>
539
540// <motivation>
541// This class contains the common functionality for the classes
542// representing a binary (or unary) operator.
543// </motivation>
544
545// # <todo asof="$DATE:$">
546// # A List of bugs, limitations, extensions or planned refinements.
547// # <li> to be filled in
548// # </todo>
549
551 public:
552 // Constructor
555
556 // Destructor
557 ~TableExprNodeBinary() override = default;
558
559 // Show the expression tree.
560 void show(ostream&, uInt indent) const override;
561
562 // Flatten the node tree by adding the node and its children to the vector.
563 void flattenTree(std::vector<TableExprNodeRep*>&) override;
564
565 // Check the data types and get the common one.
567
568 // Check the data and value types and get the common one.
569 static TableExprNodeRep getCommonTypes(const TENShPtr& left, const TENShPtr& right,
571
572 // Set the children.
573 // If needed, their properties like data type and unit are adapted.
574 void setChildren(const TENShPtr& left, const TENShPtr& right, Bool adapt = True);
575
576 // Handle the units of the children and possibly set the parent's unit.
577 // The default implementation make the units of the children equal and
578 // set the parent unit to that unit if the parent is not a Bool value.
579 virtual void handleUnits();
580
581 // If one of the children is a constant, convert its data type
582 // to that of the other operand. This avoids that conversions are
583 // done for each get.
585
586 // Get the child nodes.
587 // <group>
588 const TENShPtr& getLeftChild() const { return lnode_p; }
589 const TENShPtr& getRightChild() const { return rnode_p; }
590 // </group>
591
592 protected:
593 // Make the units equal.
594 // Replace the right node if needed.
595 static const Unit& makeEqualUnits(const TENShPtr& left, TENShPtr& right);
596
597 TENShPtr lnode_p; // # left operand
598 TENShPtr rnode_p; // # right operand
599};
600
601// <summary>
602// Abstract base class for a node having multiple child nodes.
603// </summary>
604
605// <use visibility=local>
606
607// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
608// </reviewed>
609
610// <prerequisite>
611// # Classes you should understand before using this one.
612// <li> <linkto class=TableExprNodeRep>TableExprNodeRep</linkto>
613// </prerequisite>
614
615// <etymology>
616// TableExprNodeMulti is a node in the table expression tree
617// which can have MULTIple child nodes.
618// </etymology>
619
620// <synopsis>
621// TableExprNodeMulti is the abstract base class for all nodes in a table
622// expression tree using multiple operands.
623// It is used as the base class for the node classes representing
624// functions, sets, indices, etc..
625// </synopsis>
626
627// <motivation>
628// This class contains the common functionality for the classes
629// representing a node with multiple operands.
630// </motivation>
631
632// # <todo asof="$DATE:$">
633// # A List of bugs, limitations, extensions or planned refinements.
634// # <li> to be filled in
635// # </todo>
636
638 public:
639 // Constructor
641
642 // Destructor
643 ~TableExprNodeMulti() override = default;
644
645 // Show the expression tree.
646 void show(ostream&, uInt indent) const override;
647
648 // Flatten the node tree by adding the node and its children to the vector.
649 void flattenTree(std::vector<TableExprNodeRep*>&) override;
650
651 // Check number of arguments
652 // low <= number_of_args <= high
653 // It throws an exception if wrong number of arguments.
654 static uInt checkNumOfArg(uInt low, uInt high, const std::vector<TENShPtr>& nodes);
655
656 // Get the child nodes.
657 const std::vector<TENShPtr>& getChildren() const { return operands_p; }
658
659 // Check datatype of nodes and return output type.
660 // It also sets the expected data type of the operands (from dtIn).
661 // Conversion of Int,Double.String to Date is by default possible.
663 const std::vector<TENShPtr>& nodes, Bool dateConv = True);
664
665 protected:
666 std::vector<TENShPtr> operands_p;
667};
668
669// # Get the data type of the node.
671
672inline Bool TableExprNodeRep::isReal() const { return dtype_p == NTInt || dtype_p == NTDouble; }
673
674// # Get the value type of the node.
676
677// # Set the value type of the node.
679
680// # Get the operator type of the node.
682
683// # Get the expression type of the node.
685
686// # Is the expression a constant?
688
689// # Get the unit of the node.
690inline const Unit& TableExprNodeRep::unit() const { return unit_p; }
691
692inline const Record& TableExprNodeRep::attributes() const { return attributes_p; }
693
695
696// # Get the fixed dimensionality of the node.
697inline Int TableExprNodeRep::ndim() const { return ndim_p; }
698
699// # Get the fixed shape of the node.
700inline const IPosition& TableExprNodeRep::shape() const { return shape_p; }
701
702} // namespace casacore
703
704#endif
String: the storage and methods of handling collections of characters.
Definition String.h:355
Abstract base class for classes calculating an aggregated group result.
Definition ExprGroup.h:180
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.
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.
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?
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?
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?
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:82
StringDistance itsDist
Definition ExprNodeRep.h:97
Bool match(const String &str) const
Does the regex or maximum string distance match?
Definition ExprNodeRep.h:88
TaqlRegex(const StringDistance &dist)
Construct from a StringDistance.
Definition ExprNodeRep.h:85
const Regex & regex() const
Return the regular expression.
Definition ExprNodeRep.h:93
For temporary backward namespace compatibility, use casa as alias for casacore.
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
bool RegexMatches(const std::string &str, const Regex &r, int pos=0)
Checks if the regex @r matches with the string @str.
std::shared_ptr< TableExprNodeRep > TENShPtr
Definition ExprNodeRep.h:56
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:360
double Double
Definition aipstype.h:53
iterator end()
Definition Block.h:601
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44