#include <aggregatefunctexpression.h>
Public Member Functions | |
AggregateFunctExpression (EXP_TYPE _type, VarExpression *_var) | |
Constructor. | |
AggregateFunctExpression (EXP_TYPE _type, VarStepExpression *_varstep) | |
Constructor. | |
virtual | ~AggregateFunctExpression () |
virtual void | scopeCheck (vector< unsigned > &def_vars, vector< unsigned > &introduced_vars, vector< unsigned > &violating_vars) |
virtual void | replaceVarId (unsigned old_id, unsigned new_id) |
virtual void | extractFSAMap (FSAMap *fsamap, unsigned parent_var) |
virtual void | extractParVarMap (ParVarMap *parvarmap) |
virtual void | extractDependencies (vector< DependencySet * > *depset) |
virtual Expression * | placeSignOffs (vector< SignOffExpression * > &signoffs) |
void | rewriteAggregateFuncts () |
virtual void | print (OutputStream &dos) const |
virtual void | init (BufferNode *root) |
virtual void | eval (OutputStream &eos, Environment *env, unsigned modus)=0 |
bool | isSingleValued () |
virtual void | prepareOperand (OutputStream &eos, Environment *env, unsigned modus) |
void | unprepareOperand () |
virtual Value * | getNextValue () |
Protected Attributes | |
VarExpression * | var |
The entered VarExpression. | |
VarStepExpression * | varstep |
The entered VarStepExpression. | |
ForExpression * | forexp |
The rewritten ForExpression of the entered VarExpression or VarStepExpression. | |
BufferIterator * | bit |
The initialized BufferIterator for the entered VarExpression or VarStepExpression. | |
Private Member Functions | |
virtual long double | calculateValue (OutputStream &eos, Environment *env, unsigned modus, bool &empty_sequence)=0 |
Result calculation of the corresponding aggregate function. |
Represents base class of all aggregate function expressions.
Definition at line 52 of file aggregatefunctexpression.h.
AggregateFunctExpression::AggregateFunctExpression | ( | EXP_TYPE | _type, | |
VarExpression * | _var | |||
) |
Constructor.
Constructor - creating object for an EXP_TYPE and a VarExpression.
[in] | _type | EXP_TYPE. |
[in] | _var | Pointer to a VarExpression object. |
Definition at line 37 of file aggregatefunctexpression.cpp.
AggregateFunctExpression::AggregateFunctExpression | ( | EXP_TYPE | _type, | |
VarStepExpression * | _varstep | |||
) |
Constructor.
Constructor - creating object for an EXP_TYPE and a VarStepExpression.
[in] | _type | EXP_TYPE. |
[in] | _varstep | Pointer to a VarStepExpression object. |
Definition at line 47 of file aggregatefunctexpression.cpp.
AggregateFunctExpression::~AggregateFunctExpression | ( | ) | [virtual] |
long double AggregateFunctExpression::calculateValue | ( | OutputStream & | eos, | |
Environment * | env, | |||
unsigned | modus, | |||
bool & | empty_sequence | |||
) | [private, pure virtual] |
Result calculation of the corresponding aggregate function.
Result calculation of the corresponding aggregate function.
[in] | eos | Pointer to a OutputStream object. |
[in] | env | Pointer to a Environment object. |
[in] | modus | Evaluation modus. |
[in] | empty_sequence | Indicator if aggreagte function is called on an empty sequence. |
long | double Result of the corresponding aggregate function. |
Implemented in AggregateFunctAvgExpression, AggregateFunctCountExpression, AggregateFunctMaxExpression, AggregateFunctMedianExpression, AggregateFunctMinExpression, AggregateFunctStdDevPopExpression, AggregateFunctStdDevSampExpression, AggregateFunctSumExpression, AggregateFunctVarPopExpression, and AggregateFunctVarSampExpression.
void AggregateFunctExpression::eval | ( | OutputStream & | eos, | |
Environment * | env, | |||
unsigned | modus | |||
) | [pure 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 from Expression.
Implemented in AggregateFunctAvgExpression, AggregateFunctCountExpression, AggregateFunctMaxExpression, AggregateFunctMedianExpression, AggregateFunctMinExpression, AggregateFunctStdDevPopExpression, AggregateFunctStdDevSampExpression, AggregateFunctSumExpression, AggregateFunctVarPopExpression, and AggregateFunctVarSampExpression.
Referenced by prepareOperand().
void AggregateFunctExpression::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 from Expression.
Definition at line 91 of file aggregatefunctexpression.cpp.
References ForExpression::extractDependencies(), forexp, and Expression::type.
Referenced by RoundingExpression::extractDependencies().
void AggregateFunctExpression::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 from Expression.
Definition at line 82 of file aggregatefunctexpression.cpp.
References ForExpression::extractFSAMap(), and forexp.
Referenced by RoundingExpression::extractFSAMap().
void AggregateFunctExpression::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 from Expression.
Definition at line 87 of file aggregatefunctexpression.cpp.
References ForExpression::extractParVarMap(), and forexp.
Referenced by RoundingExpression::extractParVarMap().
Value * AggregateFunctExpression::getNextValue | ( | ) | [virtual] |
Returns the next value of the operand.
Returns the next value of the operand for iteration.
Value* | Pointer to a Value object. |
Implements OperandExpression.
Definition at line 239 of file aggregatefunctexpression.cpp.
References OperandExpression::cur_val, and OperandExpression::initial.
Referenced by FunctTruncateExpression::calculateValue(), FunctRoundHalfToEvenExpression::calculateValue(), FunctRoundExpression::calculateValue(), FunctFloorExpression::calculateValue(), FunctCoverExpression::calculateValue(), FunctCeilingExpression::calculateValue(), and FunctAbsExpression::calculateValue().
void AggregateFunctExpression::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 from Expression.
Definition at line 223 of file aggregatefunctexpression.cpp.
References bit, forexp, ForExpression::init(), var, and varstep.
Referenced by RoundingExpression::init().
bool AggregateFunctExpression::isSingleValued | ( | ) | [inline, virtual] |
Returns if the result/iteration of the operand is a single value.
Returns if the result/iteration of the operand is a single value, e.g a AggregateFunctExpression returns a single value whereas a VarStepExpression may return more than one value.
bool | if the result/iteration is a single value, false otherwise. |
Implements OperandExpression.
Definition at line 130 of file aggregatefunctexpression.h.
Expression * AggregateFunctExpression::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 from Expression.
Definition at line 100 of file aggregatefunctexpression.cpp.
References forexp, and ForExpression::placeSignOffs().
Referenced by RoundingExpression::placeSignOffs().
void AggregateFunctExpression::prepareOperand | ( | OutputStream & | eos, | |
Environment * | env, | |||
unsigned | modus | |||
) | [virtual] |
Initializes the operand if necessary.
Initializes the operand if necessary.
[in] | eos | Pointer to a OutputStream object. |
[in] | env | Pointer to a Environment object. |
[in] | modus | Evaluation modus. |
void |
Implements OperandExpression.
Definition at line 233 of file aggregatefunctexpression.cpp.
References eval(), and EVAL_QUERY_SILENT.
Referenced by FunctTruncateExpression::calculateValue(), FunctRoundHalfToEvenExpression::calculateValue(), FunctRoundExpression::calculateValue(), FunctFloorExpression::calculateValue(), FunctCoverExpression::calculateValue(), FunctCeilingExpression::calculateValue(), and FunctAbsExpression::calculateValue().
void AggregateFunctExpression::print | ( | OutputStream & | dos | ) | const [virtual] |
Prints the expression.
Prints the expression.
[in] | dos | Pointer to a OutputStream object. |
void |
Implements Expression.
Definition at line 126 of file aggregatefunctexpression.cpp.
References forexp, Expression::type, and varstep.
void AggregateFunctExpression::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 from Expression.
Definition at line 74 of file aggregatefunctexpression.cpp.
References VarExpression::replaceVarId(), var, and varstep.
Referenced by RoundingExpression::replaceVarId().
void AggregateFunctExpression::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 from Expression.
Definition at line 108 of file aggregatefunctexpression.cpp.
References VarStepExpression::clone(), VarExpression::clone(), forexp, VarName::getInstance(), var, and varstep.
Referenced by RoundingExpression::rewriteAggregateFuncts().
void AggregateFunctExpression::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 from Expression.
Definition at line 64 of file aggregatefunctexpression.cpp.
References VarExpression::scopeCheck(), var, and varstep.
Referenced by RoundingExpression::scopeCheck().
void AggregateFunctExpression::unprepareOperand | ( | ) | [inline, virtual] |
Resets the operand if necessary.
Resets the operand if necessary.
void |
Implements OperandExpression.
Definition at line 141 of file aggregatefunctexpression.h.
References OperandExpression::initial.
Referenced by FunctTruncateExpression::calculateValue(), FunctRoundHalfToEvenExpression::calculateValue(), FunctRoundExpression::calculateValue(), FunctFloorExpression::calculateValue(), FunctCoverExpression::calculateValue(), FunctCeilingExpression::calculateValue(), and FunctAbsExpression::calculateValue().
BufferIterator * AggregateFunctExpression::bit [protected] |
The initialized BufferIterator for the entered VarExpression or VarStepExpression.
The initialized BufferIterator for the entered VarExpression or VarStepExpression after calling method init(). This member variable is NULL
on creation of object but should not be NULL
anymore after method init() has been executed.
Definition at line 194 of file aggregatefunctexpression.h.
Referenced by AggregateFunctVarSampExpression::calculateValue(), AggregateFunctVarPopExpression::calculateValue(), AggregateFunctSumExpression::calculateValue(), AggregateFunctStdDevSampExpression::calculateValue(), AggregateFunctStdDevPopExpression::calculateValue(), AggregateFunctMinExpression::calculateValue(), AggregateFunctMedianExpression::calculateValue(), AggregateFunctMaxExpression::calculateValue(), AggregateFunctCountExpression::calculateValue(), AggregateFunctAvgExpression::calculateValue(), init(), and ~AggregateFunctExpression().
ForExpression * AggregateFunctExpression::forexp [protected] |
The rewritten ForExpression of the entered VarExpression or VarStepExpression.
The rewritten ForExpression of the entered VarExpression or VarStepExpression after calling method rewriteAggregateFuncts(). This member variable is NULL
on creation of object but should not be NULL
anymore after method rewriteAggregateFuncts() has been executed.
Definition at line 186 of file aggregatefunctexpression.h.
Referenced by AggregateFunctVarSampExpression::calculateValue(), AggregateFunctVarPopExpression::calculateValue(), AggregateFunctSumExpression::calculateValue(), AggregateFunctStdDevSampExpression::calculateValue(), AggregateFunctStdDevPopExpression::calculateValue(), AggregateFunctMinExpression::calculateValue(), AggregateFunctMedianExpression::calculateValue(), AggregateFunctMaxExpression::calculateValue(), AggregateFunctCountExpression::calculateValue(), AggregateFunctAvgExpression::calculateValue(), AggregateFunctVarSampExpression::eval(), AggregateFunctVarPopExpression::eval(), AggregateFunctSumExpression::eval(), AggregateFunctStdDevSampExpression::eval(), AggregateFunctStdDevPopExpression::eval(), AggregateFunctMinExpression::eval(), AggregateFunctMedianExpression::eval(), AggregateFunctMaxExpression::eval(), AggregateFunctCountExpression::eval(), AggregateFunctAvgExpression::eval(), extractDependencies(), extractFSAMap(), extractParVarMap(), init(), placeSignOffs(), print(), rewriteAggregateFuncts(), and ~AggregateFunctExpression().
VarExpression * AggregateFunctExpression::var [protected] |
The entered VarExpression.
The entered VarExpression, which is the second argument of the constructor. This member variable is NULL
if the constructor was called with a VarStepExpression.
Definition at line 170 of file aggregatefunctexpression.h.
Referenced by AggregateFunctVarSampExpression::calculateValue(), AggregateFunctVarPopExpression::calculateValue(), AggregateFunctSumExpression::calculateValue(), AggregateFunctStdDevSampExpression::calculateValue(), AggregateFunctStdDevPopExpression::calculateValue(), AggregateFunctMinExpression::calculateValue(), AggregateFunctMedianExpression::calculateValue(), AggregateFunctMaxExpression::calculateValue(), AggregateFunctCountExpression::calculateValue(), AggregateFunctAvgExpression::calculateValue(), init(), replaceVarId(), rewriteAggregateFuncts(), scopeCheck(), and ~AggregateFunctExpression().
VarStepExpression * AggregateFunctExpression::varstep [protected] |
The entered VarStepExpression.
The entered VarStepExpression, which is the second argument of the constructor. This member variable is NULL
if the constructor was called with a VarExpression.
Definition at line 177 of file aggregatefunctexpression.h.
Referenced by AggregateFunctVarSampExpression::calculateValue(), AggregateFunctVarPopExpression::calculateValue(), AggregateFunctSumExpression::calculateValue(), AggregateFunctStdDevSampExpression::calculateValue(), AggregateFunctStdDevPopExpression::calculateValue(), AggregateFunctMinExpression::calculateValue(), AggregateFunctMedianExpression::calculateValue(), AggregateFunctMaxExpression::calculateValue(), AggregateFunctCountExpression::calculateValue(), AggregateFunctAvgExpression::calculateValue(), init(), print(), replaceVarId(), rewriteAggregateFuncts(), scopeCheck(), and ~AggregateFunctExpression().