#include <expression.h>
Public Member Functions | |
Expression (EXP_TYPE _type) | |
Constructor. | |
virtual | ~Expression () |
virtual void | scopeCheck (vector< unsigned > &def_vars, vector< unsigned > &introduced_vars, vector< unsigned > &violating_vars) |
Returns if all used variables were previously (through a for-clause) defined or if a variable leaves their defined scope. | |
virtual void | replaceVarId (unsigned old_id, unsigned new_id) |
Replaces all matching variable IDs by a new one. | |
virtual void | mergeSequences () |
Merges belonging together XQuery sequences into a single sequence. | |
virtual void | extractFSAMap (FSAMap *fsamap, unsigned parent_var) |
Extracts the needed first straight ancestor (FSA) variables map. | |
virtual void | extractParVarMap (ParVarMap *parvarmap) |
Extracts the needed parent variable (ParVar) map. | |
virtual void | extractDependencies (vector< DependencySet * > *depset) |
Extracts the needed dependencies of a query. | |
virtual Expression * | placeSignOffs (vector< SignOffExpression * > &signoffs) |
Places all signOff-statements in the corresponding query. | |
virtual void | rewriteWhereExps () |
Rewrites all where-clauses in the query into equivalent if-expressions. | |
virtual void | rewriteEmptyFuncts () |
Rewrites all fn:empty XQuery functions into equivalent fn:not(fn:exists) XQuery functions. | |
virtual void | rewriteVarstepCondExps () |
Rewrites all if($x) if-conditions into equivalent if(fn:not(fn:empty($x))) XQuery expressions. | |
virtual void | rewriteAggregateFuncts () |
Rewrites all arguments of all aggregate functions into an equivalent for-clause (with return-clause). | |
virtual void | rewriteVarsteps () |
Rewrites all varstep expressions, which produces output into an equivalent for-clause (with return-clause). | |
virtual void | print (OutputStream &dos) const =0 |
Prints the expression. | |
virtual void | init (BufferNode *root) |
Initializes the query for evaluation. | |
virtual void | eval (OutputStream &eos, Environment *env, unsigned modus) |
Evaluates the expression in the given environment. | |
const EXP_TYPE | getType () |
Returns the EXP_TYPE of the corresponding expression. | |
void | setType (EXP_TYPE _type) |
Sets the EXP_TYPE of the corresponding expression. | |
virtual bool | containsDirectOutput () |
Returns if the corresponding expression produces direct output. | |
Protected Attributes | |
TagMap * | tagmap |
EXP_TYPE | type |
The entered EXP_TYPE. |
Represents base class of all expressions.
Definition at line 92 of file expression.h.
Expression::Expression | ( | EXP_TYPE | _type | ) |
Constructor.
Constructor - creating object for an EXP_TYPE.
[in] | _type | EXP_TYPE. |
Definition at line 37 of file expression.cpp.
Expression::~Expression | ( | ) | [virtual] |
Destructor.
Definition at line 41 of file expression.cpp.
bool Expression::containsDirectOutput | ( | ) | [virtual] |
Returns if the corresponding expression produces direct output.
Returns if the corresponding expression produces direct output. Direct output is meant that this subexpression produces output such as node constructs or strings.
bool | true if the corresponding expression produces direct output, false otherwise. |
Reimplemented in ForExpression, IfExpression, SequenceExpression, and WhereExpression.
Definition at line 89 of file expression.cpp.
Referenced by IfExpression::containsDirectOutput(), and ForExpression::containsDirectOutput().
void Expression::eval | ( | OutputStream & | eos, | |
Environment * | env, | |||
unsigned | modus | |||
) | [virtual] |
Evaluates the expression in the given environment.
Evaluates the expression in the given environment. The evaluation takes place in the environment that is passed to this method. In addition, the parameter modus is one of the following: EVAL_QUERY, EVAL_QUERY_SILENT or EVAL_SIGNOFF (see also the corresponding defines for more information). This method implements the XQuery semantics for the standard expression types, but also the GCX specific extensions like signOff-statements.
[in] | eos | Pointer to a OutputStream object. |
[in] | env | Pointer to an Environment object. |
[in] | modus | The query evaluation mode. |
RuntimeException | If illegal evaluation mode. |
Reimplemented in AggregateFunctAvgExpression, AggregateFunctCountExpression, AggregateFunctExpression, AggregateFunctMaxExpression, AggregateFunctMedianExpression, AggregateFunctMinExpression, AggregateFunctStdDevPopExpression, AggregateFunctStdDevSampExpression, AggregateFunctSumExpression, AggregateFunctVarPopExpression, AggregateFunctVarSampExpression, AndCondExpression, ConstExpression, EmptyCondExpression, ForExpression, FunctAbsExpression, FunctCeilingExpression, FunctCoverExpression, FunctFloorExpression, FunctRoundExpression, FunctRoundHalfToEvenExpression, FunctTruncateExpression, IfExpression, NodeConstructExpression, NotCondExpression, NumericConstExpression, OrCondExpression, RoundingExpression, SequenceExpression, SignOffExpression, StringConstExpression, VarExpression, VarStepExpression, and WhereExpression.
Definition at line 86 of file expression.cpp.
Referenced by OrCondExpression::eval(), NotCondExpression::eval(), NodeConstructExpression::eval(), IfExpression::eval(), ForExpression::eval(), AndCondExpression::eval(), Executor::evalQuery(), and ForExpression::evalSignOffForBinding().
void Expression::extractDependencies | ( | vector< DependencySet * > * | depset | ) | [virtual] |
Extracts the needed dependencies of a query.
Extracts the needed dependencies of a query, which are needed for constructing the ProjectionTree.
[in,out] | depset | Pointer to a vector containing Pointer to DependencySet objects. |
void |
Reimplemented in AggregateFunctExpression, AndCondExpression, CondOperandExpression, EmptyCondExpression, ExistsCondExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, OrCondExpression, RoundingExpression, SequenceExpression, VarExpression, VarstepCondExpression, VarStepExpression, and WhereExpression.
Definition at line 61 of file expression.cpp.
Referenced by Executor::buildDependencies(), OrCondExpression::extractDependencies(), NotCondExpression::extractDependencies(), NodeConstructExpression::extractDependencies(), IfExpression::extractDependencies(), ForExpression::extractDependencies(), CondOperandExpression::extractDependencies(), and AndCondExpression::extractDependencies().
void Expression::extractFSAMap | ( | FSAMap * | fsamap, | |
unsigned | parent_var | |||
) | [virtual] |
Extracts the needed first straight ancestor (FSA) variables map.
Extracts the needed first straight ancestor (FSA) variables map, which is needed for correct insertion of SignOffExpression.
[in,out] | fsamap | Pointer to a FSAMap object. |
[in] | parent_var | Parent variable. |
void |
Reimplemented in AggregateFunctExpression, AndCondExpression, CondOperandExpression, EmptyCondExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, OrCondExpression, RoundingExpression, SequenceExpression, and WhereExpression.
Definition at line 55 of file expression.cpp.
Referenced by Executor::collectQueryInformation(), OrCondExpression::extractFSAMap(), NotCondExpression::extractFSAMap(), NodeConstructExpression::extractFSAMap(), IfExpression::extractFSAMap(), ForExpression::extractFSAMap(), CondOperandExpression::extractFSAMap(), and AndCondExpression::extractFSAMap().
void Expression::extractParVarMap | ( | ParVarMap * | parvarmap | ) | [virtual] |
Extracts the needed parent variable (ParVar) map.
Extracts the needed parent variable (ParVar) map, which is needed for constructing the VariableTree.
[in,out] | parvarmap | Pointer to a ParVarMap object. |
void |
Reimplemented in AggregateFunctExpression, AndCondExpression, CondOperandExpression, EmptyCondExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, OrCondExpression, RoundingExpression, SequenceExpression, and WhereExpression.
Definition at line 58 of file expression.cpp.
Referenced by Executor::collectQueryInformation(), OrCondExpression::extractParVarMap(), NotCondExpression::extractParVarMap(), NodeConstructExpression::extractParVarMap(), IfExpression::extractParVarMap(), ForExpression::extractParVarMap(), CondOperandExpression::extractParVarMap(), and AndCondExpression::extractParVarMap().
const EXP_TYPE Expression::getType | ( | ) | [inline] |
Returns the EXP_TYPE of the corresponding expression.
Returns the EXP_TYPE of the corresponding expression.
EXP_TYPE. |
Definition at line 249 of file expression.h.
References type.
Referenced by SequenceExpression::containsDirectOutput(), IfExpression::containsDirectOutput(), ForExpression::containsDirectOutput(), NodeConstructExpression::eval(), SequenceExpression::mergeSequences(), SequenceExpression::print(), OrCondExpression::print(), NodeConstructExpression::print(), ForExpression::print(), AndCondExpression::print(), SequenceExpression::rewriteVarsteps(), NodeConstructExpression::rewriteVarsteps(), IfExpression::rewriteVarsteps(), and ForExpression::rewriteVarsteps().
void Expression::init | ( | BufferNode * | root | ) | [virtual] |
Initializes the query for evaluation.
Initializes the query for evaluation. Up to now only all required BufferIterator objects are created to speed up query evaluation.
[in] | root | Pointer to a BufferNode object. |
void |
Reimplemented in AggregateFunctExpression, AndCondExpression, CondOperandExpression, EmptyCondExpression, ExistsCondExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, OrCondExpression, RoundingExpression, SequenceExpression, SignOffExpression, VarExpression, VarstepCondExpression, VarStepExpression, and WhereExpression.
Definition at line 83 of file expression.cpp.
Referenced by Executor::evalQuery(), OrCondExpression::init(), NotCondExpression::init(), NodeConstructExpression::init(), IfExpression::init(), ForExpression::init(), CondOperandExpression::init(), and AndCondExpression::init().
void Expression::mergeSequences | ( | ) | [virtual] |
Merges belonging together XQuery sequences into a single sequence.
Merges belonging together XQuery sequences into a single sequence, which is done because of better/nicer output look.
void |
Reimplemented in ForExpression, IfExpression, NodeConstructExpression, SequenceExpression, and WhereExpression.
Definition at line 52 of file expression.cpp.
Referenced by Executor::buildSignOffQuery(), NodeConstructExpression::mergeSequences(), IfExpression::mergeSequences(), ForExpression::mergeSequences(), and Executor::optimizeQuery().
Expression * Expression::placeSignOffs | ( | vector< SignOffExpression * > & | signoffs | ) | [virtual] |
Places all signOff-statements in the corresponding query.
Places all signOff-statements in the corresponding query, which are needed for active garbage collection by removing Role from the BufferNode.
[in] | signoffs | Pointer to a vector containing Pointer to SignOffExpression objects. |
Expression* | Pointer to a Expression object (following expression in the corresponding query). |
Reimplemented in AggregateFunctExpression, AndCondExpression, CondOperandExpression, EmptyCondExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, OrCondExpression, RoundingExpression, SequenceExpression, and WhereExpression.
Definition at line 64 of file expression.cpp.
Referenced by Executor::insertSignOffs(), OrCondExpression::placeSignOffs(), NotCondExpression::placeSignOffs(), NodeConstructExpression::placeSignOffs(), IfExpression::placeSignOffs(), ForExpression::placeSignOffs(), CondOperandExpression::placeSignOffs(), and AndCondExpression::placeSignOffs().
void Expression::print | ( | OutputStream & | dos | ) | const [pure virtual] |
Prints the expression.
Prints the expression.
[in] | dos | Pointer to a OutputStream object. |
void |
Implemented in AggregateFunctExpression, AndCondExpression, CommentExpression, CondOperandExpression, DocExpression, EmptyCondExpression, EmptyExpression, ExistsCondExpression, FalseCondExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, NumericConstExpression, OrCondExpression, PathExpression, PathStepExpression, PathStepNodeExpression, PathStepStarExpression, PathStepTagExpression, PathStepTextExpression, RoundingExpression, SequenceExpression, SignOffExpression, StringConstExpression, TrueCondExpression, VarExpression, VarstepCondExpression, VarStepExpression, and WhereExpression.
Referenced by operator<<().
void Expression::replaceVarId | ( | unsigned | old_id, | |
unsigned | new_id | |||
) | [virtual] |
Replaces all matching variable IDs by a new one.
Replaces all matching variable IDs by a new one, which is needed in case of calling method rewriteVarsteps().
[in] | old_id | Old variable ID. |
[in] | new_id | New variable ID, which should be introduced instead. |
void |
Reimplemented in AggregateFunctExpression, AndCondExpression, CondOperandExpression, EmptyCondExpression, ExistsCondExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, OrCondExpression, RoundingExpression, SequenceExpression, SignOffExpression, VarExpression, VarstepCondExpression, and WhereExpression.
Definition at line 49 of file expression.cpp.
Referenced by WhereExpression::replaceVarId(), OrCondExpression::replaceVarId(), NotCondExpression::replaceVarId(), NodeConstructExpression::replaceVarId(), IfExpression::replaceVarId(), ForExpression::replaceVarId(), CondOperandExpression::replaceVarId(), AndCondExpression::replaceVarId(), and ForExpression::scopeCheck().
void Expression::rewriteAggregateFuncts | ( | ) | [virtual] |
Rewrites all arguments of all aggregate functions into an equivalent for-clause (with return-clause).
Rewrites all arguments of all aggregate functions into an equivalent for-clause (with return-clause).
void |
Reimplemented in AggregateFunctExpression, AndCondExpression, CondOperandExpression, EmptyCondExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, OrCondExpression, RoundingExpression, SequenceExpression, and WhereExpression.
Definition at line 77 of file expression.cpp.
Referenced by Executor::optimizeQuery(), OrCondExpression::rewriteAggregateFuncts(), NotCondExpression::rewriteAggregateFuncts(), NodeConstructExpression::rewriteAggregateFuncts(), IfExpression::rewriteAggregateFuncts(), ForExpression::rewriteAggregateFuncts(), CondOperandExpression::rewriteAggregateFuncts(), and AndCondExpression::rewriteAggregateFuncts().
void Expression::rewriteEmptyFuncts | ( | ) | [virtual] |
Rewrites all fn:empty
XQuery functions into equivalent fn:not(fn:exists)
XQuery functions.
Rewrites all fn:empty
XQuery functions into equivalent fn:not(fn:exists)
XQuery functions.
void |
Reimplemented in AndCondExpression, CondOperandExpression, EmptyCondExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, OrCondExpression, SequenceExpression, and WhereExpression.
Definition at line 71 of file expression.cpp.
Referenced by Executor::optimizeQuery(), OrCondExpression::rewriteEmptyFuncts(), NotCondExpression::rewriteEmptyFuncts(), NodeConstructExpression::rewriteEmptyFuncts(), IfExpression::rewriteEmptyFuncts(), ForExpression::rewriteEmptyFuncts(), CondOperandExpression::rewriteEmptyFuncts(), and AndCondExpression::rewriteEmptyFuncts().
void Expression::rewriteVarstepCondExps | ( | ) | [virtual] |
Rewrites all if($x)
if-conditions into equivalent if(fn:not(fn:empty($x)))
XQuery expressions.
Rewrites all if($x)
if-conditions into equivalent if(fn:not(fn:empty($x)))
XQuery expressions.
void |
Reimplemented in AndCondExpression, CondOperandExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, OrCondExpression, SequenceExpression, VarstepCondExpression, and WhereExpression.
Definition at line 74 of file expression.cpp.
Referenced by Executor::optimizeQuery(), OrCondExpression::rewriteVarstepCondExps(), NotCondExpression::rewriteVarstepCondExps(), NodeConstructExpression::rewriteVarstepCondExps(), IfExpression::rewriteVarstepCondExps(), ForExpression::rewriteVarstepCondExps(), CondOperandExpression::rewriteVarstepCondExps(), and AndCondExpression::rewriteVarstepCondExps().
void Expression::rewriteVarsteps | ( | ) | [virtual] |
Rewrites all varstep expressions, which produces output into an equivalent for-clause (with return-clause).
Rewrites all varstep expressions, which produces output into an equivalent for-clause (with return-clause). This method belongs to the 'earlier execution of signoff-statements' optimization.
void |
Reimplemented in ForExpression, IfExpression, NodeConstructExpression, SequenceExpression, and WhereExpression.
Definition at line 80 of file expression.cpp.
Referenced by Executor::optimizeQuery(), NodeConstructExpression::rewriteVarsteps(), IfExpression::rewriteVarsteps(), and ForExpression::rewriteVarsteps().
void Expression::rewriteWhereExps | ( | ) | [virtual] |
Rewrites all where-clauses in the query into equivalent if-expressions.
Rewrites all where-clauses in the query into equivalent if-expressions, i.e. rewrites all WhereExpression into equivalent IfExpression.
void |
Reimplemented in ForExpression, IfExpression, NodeConstructExpression, SequenceExpression, and WhereExpression.
Definition at line 68 of file expression.cpp.
Referenced by Executor::optimizeQuery(), NodeConstructExpression::rewriteWhereExps(), IfExpression::rewriteWhereExps(), and ForExpression::rewriteWhereExps().
void Expression::scopeCheck | ( | vector< unsigned > & | def_vars, | |
vector< unsigned > & | introduced_vars, | |||
vector< unsigned > & | violating_vars | |||
) | [virtual] |
Returns if all used variables were previously (through a for-clause) defined or if a variable leaves their defined scope.
Returns if all used variables were previously (through a for-clause) defined or if a variable leaves their defined scope.
[in] | def_vars | Vector containing all previously defined variables. |
[in] | introduced_vars | Vector containing all up to this expression defined variables. |
[in] | violating_vars | Vector containing all variables which violates the scope condition. |
void |
Reimplemented in AggregateFunctExpression, AndCondExpression, CondOperandExpression, EmptyCondExpression, ExistsCondExpression, ForExpression, IfExpression, NodeConstructExpression, NotCondExpression, OrCondExpression, RoundingExpression, SequenceExpression, SignOffExpression, VarExpression, VarstepCondExpression, and WhereExpression.
Definition at line 44 of file expression.cpp.
Referenced by WhereExpression::scopeCheck(), OrCondExpression::scopeCheck(), NotCondExpression::scopeCheck(), NodeConstructExpression::scopeCheck(), IfExpression::scopeCheck(), ForExpression::scopeCheck(), CondOperandExpression::scopeCheck(), and AndCondExpression::scopeCheck().
void Expression::setType | ( | EXP_TYPE | _type | ) | [inline] |
Sets the EXP_TYPE of the corresponding expression.
Sets the EXP_TYPE of the corresponding expression.
[in] | _type | EXP_TYPE. |
void |
Definition at line 257 of file expression.h.
Referenced by EmptyCondExpression::rewriteEmptyFuncts(), VarstepCondExpression::rewriteVarstepCondExps(), and WhereExpression::rewriteWhereExps().
TagMap * Expression::tagmap [protected] |
The map which contains mapping of numeric values of tagnames to their string value.
Definition at line 276 of file expression.h.
Referenced by NodeConstructExpression::eval(), PathStepTagExpression::print(), and NodeConstructExpression::print().
EXP_TYPE Expression::type [protected] |
The entered EXP_TYPE.
The entered EXP_TYPE, which is the argument of the constructor.
Definition at line 282 of file expression.h.
Referenced by AggregateFunctExpression::extractDependencies(), PathStepExpression::getNodeTestType(), PathStepExpression::getStepWeight(), getType(), PathStepExpression::isDosNodeStep(), PathStepExpression::isNodeNodeTest(), PathStepExpression::isStarNodeTest(), PathStepExpression::isTagNodeTest(), PathStepExpression::isTextNodeTest(), RoundingExpression::print(), and AggregateFunctExpression::print().