org.objectweb.medor.optim.lib

Class PushSelectionRule

Implemented Interfaces:
RewriteRule

public class PushSelectionRule
extends BasicRule

This class represents the rule to push selections down a QueryTree.

Nested Class Summary

class
PushSelectionRule.SameQT

Nested classes/interfaces inherited from class org.objectweb.medor.optim.lib.BasicRule

BasicRule.ModifiedExpression

Field Summary

Fields inherited from class org.objectweb.medor.optim.lib.BasicRule

debug, log

Constructor Summary

PushSelectionRule()

Method Summary

BasicRule.ModifiedExpression
extractMapFromExpression(Expression e, Map qt2e, int op)
This methods does two things.
BasicRule.ModifiedExpression
goDownFieldOperand(Expression e)
PushSelectionRule.SameQT
isSameQT(Expression e)
It evaluates if inside an expression all QueryTreeField referenced in FieldOperands come from the same QueryTree.
BasicRule.ModifiedExpression
merge(Expression origin, Expression addExp, int op)
It merges an source expresion with an additional expression.
QueryTree
rewrite(QueryTree qt, QueryNode parent)
protected void
rewriteExp(QueryTree qt, Expression addedExp)

Methods inherited from class org.objectweb.medor.optim.lib.BasicRule

replaceUsage, rewrite

Constructor Details

PushSelectionRule

public PushSelectionRule()

Method Details

extractMapFromExpression

public BasicRule.ModifiedExpression extractMapFromExpression(Expression e,
                                                             Map qt2e,
                                                             int op)
            throws MedorException
This methods does two things. It extracts the expressions which can be moved to a QueryTree child. The extracted expression are grouped by QueryTree child in the Map parameter.

Parameters:
e - is the expression in which sub expression could be extracted
qt2e - is a map result parameter which must be fill with the the extractable sub expressions.

Returns:
a modifiedExpression instance. The 'isModified' field indicates if the source expression has been modified ou replaced. The 'e' field references the rest of the expression.


goDownFieldOperand

public BasicRule.ModifiedExpression goDownFieldOperand(Expression e)
            throws MedorException


isSameQT

public PushSelectionRule.SameQT isSameQT(Expression e)
            throws MedorException
It evaluates if inside an expression all QueryTreeField referenced in FieldOperands come from the same QueryTree.

Parameters:
e - is the expression in which the FieldOperand field will be searched

Returns:
a SameQt instance. The 'isSame' field indicates if in the given expression all Fields are linked to the same QueryTree. If 'isSame' is true, the 'qt' field is the QueryTree with which all fieldoperand of expression are linked.


merge

public BasicRule.ModifiedExpression merge(Expression origin,
                                          Expression addExp,
                                          int op)
It merges an source expresion with an additional expression.

Parameters:
origin - is the source expression
addExp - is the additionnal expression which will be merge with the source.

Returns:
a ModifiedExpression instance. The 'isModified' field indicates if the source expression has been modified ou replaced. The 'e' field references the result of the merge.


rewrite

public QueryTree rewrite(QueryTree qt,
                         QueryNode parent)
            throws MedorException
Specified by:
rewrite in interface RewriteRule


rewriteExp

protected void rewriteExp(QueryTree qt,
                          Expression addedExp)
            throws MedorException