ExprNodeSet.h

Classes

TableExprNodeSetElem -- Class to hold the table expression nodes for an element in a set. (full description)
TableExprNodeSet -- Class to hold multiple table expression nodes. (full description)

class TableExprNodeSetElem : public TableExprNodeRep

Interface

Public Members
explicit TableExprNodeSetElem (const TableExprNode& node)
TableExprNodeSetElem (const TableExprNode* start, const TableExprNode* end, const TableExprNode* incr)
TableExprNodeSetElem (Bool isLeftClosed, const TableExprNode& start, const TableExprNode& end, Bool isRightClosed)
TableExprNodeSetElem (Bool isLeftClosed, const TableExprNode& start)
TableExprNodeSetElem (const TableExprNode& end, Bool isRightClosed)
TableExprNodeSetElem (const TableExprNodeSetElem&)
~TableExprNodeSetElem()
void show (ostream& os, uInt indent) const
Bool isDiscrete() const
Bool isSingle() const
Bool isLeftClosed() const
Bool isRightClosed() const
TableExprNodeRep* start() const
TableExprNodeRep* end() const
TableExprNodeRep* increment() const
void fillVector (Vector<Bool>& vec, uInt& cnt, const TableExprId& id) const
void fillVector (Vector<Double>& vec, uInt& cnt, const TableExprId& id) const
void fillVector (Vector<DComplex>& vec, uInt& cnt, const TableExprId& id) const
void fillVector (Vector<String>& vec, uInt& cnt, const TableExprId& id) const
void fillVector (Vector<MVTime>& vec, uInt& cnt, const TableExprId& id) const
void matchBool (Bool* match, const Bool* value, uInt nval, const TableExprId& id) const
void matchDouble (Bool* match, const Double* value, uInt nval, const TableExprId& id) const
void matchDComplex (Bool* match, const DComplex* value, uInt nval, const TableExprId& id) const
void matchString (Bool* match, const String* value, uInt nval, const TableExprId& id) const
void matchDate (Bool* match, const MVTime* value, uInt nval, const TableExprId& id) const
TableExprNodeSetElem* evaluate (const TableExprId& id) const
void checkTable()
virtual void replaceTablePtr (const Table&)
Private Members
TableExprNodeSetElem& operator= (const TableExprNodeSetElem&)
TableExprNodeSetElem (const TableExprNodeSetElem& that, TableExprNodeRep* start, TableExprNodeRep* end, TableExprNodeRep* incr)
void setup (Bool isLeftClosed, const TableExprNode* start, const TableExprNode* end, Bool isRightClosed)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Synopsis

This class is used to assemble the table expression nodes representing an element in a set. A set element can be of 3 types:
  1. A single discrete value, which can be of any type. It can be used for 3 purposes:
    - A function argument.
    - A single index in an array indexing operation.
    - A single value in a set (used with the IN operator). This is in fact a bounded discrete interval (see below).
  2. A discrete interval consisting of start, end and increment. Each of those has to be a double scalar. Increment defaults to 1. It can be used for 2 purposes:
    - A slice in an array indexing operation. In that case start defaults to the beginning of the dimension and end defaults to the end.
    - A discrete interval in a set. Start has to be given. When end is not given, the result is an unbounded discrete interval. For a discrete interval, the type of start and end can also be a datetime scalar.
  3. A continuous interval, which can only be used in a set. It consists of a start and/or an end scalar value of type double, datetime, or string. The interval can be open or closed on one or both sides.
Note the difference between a discrete and a continuous interval. E.g. the discrete interval 2,6 consists of the five values 2,3,4,5,6. The continuous interval 2,6 consists of all values between them.
Further note that a bounded discrete interval is automatically converted to a vector, which makes it possible to apply array functions to it.

Member Description

explicit TableExprNodeSetElem (const TableExprNode& node)

Create the object for a single expression node.

TableExprNodeSetElem (const TableExprNode* start, const TableExprNode* end, const TableExprNode* incr)

Create the object for a discrete interval. Each of the start, end, and incr pointers can be zero meaning that they are not given (see the synopsis for an explanation).

TableExprNodeSetElem (Bool isLeftClosed, const TableExprNode& start, const TableExprNode& end, Bool isRightClosed)

Create the object for a continuous bounded interval. It can be open or closed on either side.

TableExprNodeSetElem (Bool isLeftClosed, const TableExprNode& start)

Create the object for a continuous left-bounded interval.

TableExprNodeSetElem (const TableExprNode& end, Bool isRightClosed)

Create the object for a continuous right-bounded interval.

TableExprNodeSetElem (const TableExprNodeSetElem&)

Copy constructor (copy semantics).

~TableExprNodeSetElem()

void show (ostream& os, uInt indent) const

Show the node.

Bool isDiscrete() const

Is it a discrete set element.

Bool isSingle() const

Is a single value given?

Bool isLeftClosed() const
Bool isRightClosed() const

Is the interval left or right closed?

TableExprNodeRep* start() const
TableExprNodeRep* end() const
TableExprNodeRep* increment() const

Get the start, end or increment expression. Note that the pointer returned can be zero indicating that that value was not given.

void fillVector (Vector<Bool>& vec, uInt& cnt, const TableExprId& id) const
void fillVector (Vector<Double>& vec, uInt& cnt, const TableExprId& id) const
void fillVector (Vector<DComplex>& vec, uInt& cnt, const TableExprId& id) const
void fillVector (Vector<String>& vec, uInt& cnt, const TableExprId& id) const
void fillVector (Vector<MVTime>& vec, uInt& cnt, const TableExprId& id) const

Fill a vector with the value(s) from this element. This is used by the system to convert a set to a vector.

void matchBool (Bool* match, const Bool* value, uInt nval, const TableExprId& id) const
void matchDouble (Bool* match, const Double* value, uInt nval, const TableExprId& id) const
void matchDComplex (Bool* match, const DComplex* value, uInt nval, const TableExprId& id) const
void matchString (Bool* match, const String* value, uInt nval, const TableExprId& id) const
void matchDate (Bool* match, const MVTime* value, uInt nval, const TableExprId& id) const

Set a flag in the match output array if the corresponding element in the value array is included in this set element. This is used by the system to implement the IN operator.

TableExprNodeSetElem* evaluate (const TableExprId& id) const

Evaluate the element for the given row and construct a new (constant) element from it. This is used by the system to implement a set in a GIVING clause.

void checkTable()

Get the table of a node and check if the children use the same table.

virtual void replaceTablePtr (const Table&)

Replace the BaseTable pointer in this node and all its children.

TableExprNodeSetElem& operator= (const TableExprNodeSetElem&)

A copy of a TableExprNodeSetElem cannot be made.

TableExprNodeSetElem (const TableExprNodeSetElem& that, TableExprNodeRep* start, TableExprNodeRep* end, TableExprNodeRep* incr)

Construct an element from the given parts and take over their pointers. It is used by evaluate to construct an element in a rather cheap way.

void setup (Bool isLeftClosed, const TableExprNode* start, const TableExprNode* end, Bool isRightClosed)

Setup the object for a continuous interval.


class TableExprNodeSet : public TableExprNodeRep

Interface

Public Members
TableExprNodeSet()
TableExprNodeSet (const IPosition&)
TableExprNodeSet (const Slicer&)
TableExprNodeSet (uInt n, const TableExprNodeSet&)
TableExprNodeSet(const TableExprNodeSet&)
~TableExprNodeSet()
void add (const TableExprNodeSetElem&)
void show (ostream& os, uInt indent) const
void checkEqualDataTypes() const
Bool isSingle() const
Bool isDiscrete() const
Bool isBounded() const
uInt nelements() const
const TableExprNodeSetElem& operator[] (uInt index) const
Bool hasArrays() const
TableExprNodeRep* setOrArray() const
TableExprNodeRep* toArray() const
virtual Array<Bool> getArrayBool (const TableExprId& id)
virtual Array<Double> getArrayDouble (const TableExprId& id)
virtual Array<DComplex> getArrayDComplex (const TableExprId& id)
virtual Array<String> getArrayString (const TableExprId& id)
virtual Array<MVTime> getArrayDate (const TableExprId& id)
virtual Bool hasBool (const TableExprId& id, Bool value)
virtual Bool hasDouble (const TableExprId& id, Double value)
virtual Bool hasDComplex (const TableExprId& id, const DComplex& value)
virtual Bool hasString (const TableExprId& id, const String& value)
virtual Bool hasDate (const TableExprId& id, const MVTime& value)
virtual Array<Bool> hasArrayBool (const TableExprId& id, const Array<Bool>& value)
virtual Array<Bool> hasArrayDouble (const TableExprId& id, const Array<Double>& value)
virtual Array<Bool> hasArrayDComplex (const TableExprId& id, const Array<DComplex>& value)
virtual Array<Bool> hasArrayString (const TableExprId& id, const Array<String>& value)
virtual Array<Bool> hasArrayDate (const TableExprId& id, const Array<MVTime>& value)
virtual void replaceTablePtr (const Table&)
Private Members
TableExprNodeSet& operator= (const TableExprNodeSet&)
void deleteElems()
Array<Bool> toArrayBool (const TableExprId& id) const
Array<Double> toArrayDouble (const TableExprId& id) const
Array<DComplex> toArrayDComplex (const TableExprId& id) const
Array<String> toArrayString (const TableExprId& id) const
Array<MVTime> toArrayDate (const TableExprId& id) const
void combineDoubleIntervals()
void combineDateIntervals()
typedef Bool (TableExprNodeSet::* FindFuncPtr) (Double value)
Bool findOpenOpen (Double value)
Bool findOpenClosed (Double value)
Bool findClosedOpen (Double value)
Bool findClosedClosed (Double value)
void setFindFunc (Bool isLeftClosed, Bool isRightClosed)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Synopsis

This class is used to assemble several table expression nodes. It is used for 3 purposes:
  1. To hold the arguments of a function. All set elements must be single.
  2. To hold the variables of an index for an array slice. All set elements must be of type double scalar and they must represent a discrete interval (which includes single).
  3. To hold the elements of a set used with the IN operator. All set elements must be scalars of any type.
The type of all set elements has to be the same. The set consists of TableExprNodeSetElem elements. The add function has to be used to add an element to the set.

It is possible to construct the object directly from an IPosition object. In that case all elements are single. Furthermore it is possible to construct it directly from a Slicer object. In that case all elements represent a discrete interval.

Member Description

TableExprNodeSet()

Construct an empty set.

TableExprNodeSet (const IPosition&)

Construct from an IPosition. The number of elements in the set is the number of elements in the IPosition. All set elements are single values.

TableExprNodeSet (const Slicer&)

Construct from a Slicer. The number of elements in the set is the dimensionality of the Slicer. All set elements are discrete intervals. Their start and/or end is undefined if it is was not defined (i.e. Slicer::MimicSource used) in the Slicer object.

TableExprNodeSet (uInt n, const TableExprNodeSet&)

Construct a set with n*set.nelements() elements. Element i is constructed by evaluating the input element for row i.

TableExprNodeSet(const TableExprNodeSet&)

~TableExprNodeSet()

void add (const TableExprNodeSetElem&)

Add an element to the set.

void show (ostream& os, uInt indent) const

Show the node.

void checkEqualDataTypes() const

Check if the data type of the set elements are the same. If not, an exception is thrown.

Bool isSingle() const

Contains the set only single elements? Single means that only single values are given (thus no end nor incr).

Bool isDiscrete() const

Contains the set only discrete elements? Discrete means that no continuous ranges are given, but discrete ranges (using :) are possible.

Bool isBounded() const

Is the set fully bounded (discrete and no undefined end values)?

uInt nelements() const

Get the number of elements.

const TableExprNodeSetElem& operator[] (uInt index) const

Get the i-th element.

Bool hasArrays() const

Contains the set array values?

TableExprNodeRep* setOrArray() const

Try to convert the set to an array. If not possible, a copy of the set is returned.

TableExprNodeRep* toArray() const

Convert the const set to an array.

virtual Array<Bool> getArrayBool (const TableExprId& id)
virtual Array<Double> getArrayDouble (const TableExprId& id)
virtual Array<DComplex> getArrayDComplex (const TableExprId& id)
virtual Array<String> getArrayString (const TableExprId& id)
virtual Array<MVTime> getArrayDate (const TableExprId& id)

Get an array value for this bounded set in the given row.

virtual Bool hasBool (const TableExprId& id, Bool value)
virtual Bool hasDouble (const TableExprId& id, Double value)
virtual Bool hasDComplex (const TableExprId& id, const DComplex& value)
virtual Bool hasString (const TableExprId& id, const String& value)
virtual Bool hasDate (const TableExprId& id, const MVTime& value)
virtual Array<Bool> hasArrayBool (const TableExprId& id, const Array<Bool>& value)
virtual Array<Bool> hasArrayDouble (const TableExprId& id, const Array<Double>& value)
virtual Array<Bool> hasArrayDComplex (const TableExprId& id, const Array<DComplex>& value)
virtual Array<Bool> hasArrayString (const TableExprId& id, const Array<String>& value)
virtual Array<Bool> hasArrayDate (const TableExprId& id, const Array<MVTime>& value)

Does a value occur in the set?

virtual void replaceTablePtr (const Table&)

Replace the BaseTable pointer in this node and all its children.

TableExprNodeSet& operator= (const TableExprNodeSet&)

A copy of a TableExprNodeSet cannot be made.

void deleteElems()

Delete all set elements in itsElems.

Array<Bool> toArrayBool (const TableExprId& id) const
Array<Double> toArrayDouble (const TableExprId& id) const
Array<DComplex> toArrayDComplex (const TableExprId& id) const
Array<String> toArrayString (const TableExprId& id) const
Array<MVTime> toArrayDate (const TableExprId& id) const

Convert a bounded set to an Array.

void combineDoubleIntervals()
void combineDateIntervals()

Sort and combine intervals.

typedef Bool (TableExprNodeSet::* FindFuncPtr) (Double value)
Bool findOpenOpen (Double value)
Bool findOpenClosed (Double value)
Bool findClosedOpen (Double value)
Bool findClosedClosed (Double value)
void setFindFunc (Bool isLeftClosed, Bool isRightClosed)

Define the functions to find a double, which depend on open/closed-ness. In this way a test on open/closed is done only once.