org.eigenbase.rel.rules
Class PullUpProjectsAboveJoinRule

java.lang.Object
  extended by org.eigenbase.relopt.RelOptRule
      extended by org.eigenbase.rel.rules.PullUpProjectsAboveJoinRule
Direct Known Subclasses:
PullUpProjectsOnTopOfMultiJoinRule

public class PullUpProjectsAboveJoinRule
extends RelOptRule

PullUpProjectsAboveJoinRule implements the rule for pulling ProjectRels beneath a JoinRel above the JoinRel. Projections are pulled up if the ProjectRel doesn't originate from a null generating input in an outer join.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/rel/rules/PullUpProjectsAboveJoinRule.java#9 $
Author:
Zelaine Fong

Field Summary
static PullUpProjectsAboveJoinRule instanceLeftProjectChild
           
static PullUpProjectsAboveJoinRule instanceRightProjectChild
           
static PullUpProjectsAboveJoinRule instanceTwoProjectChildren
           
 
Fields inherited from class org.eigenbase.relopt.RelOptRule
ANY, description, operands
 
Constructor Summary
PullUpProjectsAboveJoinRule(RelOptRuleOperand operand, String description)
           
 
Method Summary
private  void createProjectExprs(ProjectRel projRel, RelNode joinChild, int adjustmentAmount, RexBuilder rexBuilder, RelDataTypeField[] joinChildrenFields, RexNode[] projExprs, String[] fieldNames, int offset)
          Creates projection expressions corresponding to one of the inputs into the join
protected  RelNode getProjectChild(RelOptRuleCall call, ProjectRel project, boolean leftChild)
          Returns the child of the project that will be used as input into the new JoinRel once the projects are pulled above the JoinRel.
protected  ProjectRel getRightChild(RelOptRuleCall call)
           
protected  boolean hasLeftChild(RelOptRuleCall call)
           
protected  boolean hasRightChild(RelOptRuleCall call)
           
 void onMatch(RelOptRuleCall call)
          Receives notification about a rule match.
 
Methods inherited from class org.eigenbase.relopt.RelOptRule
convert, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, mergeTraitsAndConvert, mergeTraitsAndConvert, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

instanceTwoProjectChildren

public static final PullUpProjectsAboveJoinRule instanceTwoProjectChildren

instanceLeftProjectChild

public static final PullUpProjectsAboveJoinRule instanceLeftProjectChild

instanceRightProjectChild

public static final PullUpProjectsAboveJoinRule instanceRightProjectChild
Constructor Detail

PullUpProjectsAboveJoinRule

public PullUpProjectsAboveJoinRule(RelOptRuleOperand operand,
                                   String description)
Method Detail

onMatch

public void onMatch(RelOptRuleCall call)
Description copied from class: RelOptRule
Receives notification about a rule match. At the time that this method is called, call.rels holds the set of relational expressions which match the operands to the rule; call.rels[0] is the root expression.

Typically a rule would check that the nodes are valid matches, creates a new expression, then calls back RelOptRuleCall.transformTo(org.eigenbase.rel.RelNode) to register the expression.

Specified by:
onMatch in class RelOptRule
Parameters:
call - Rule call
See Also:
RelOptRule.matches(RelOptRuleCall)

hasLeftChild

protected boolean hasLeftChild(RelOptRuleCall call)
Parameters:
call - RelOptRuleCall
Returns:
true if the rule was invoked with a left project child

hasRightChild

protected boolean hasRightChild(RelOptRuleCall call)
Parameters:
call - RelOptRuleCall
Returns:
true if the rule was invoked with 2 children

getRightChild

protected ProjectRel getRightChild(RelOptRuleCall call)
Parameters:
call - RelOptRuleCall
Returns:
ProjectRel corresponding to the right child

getProjectChild

protected RelNode getProjectChild(RelOptRuleCall call,
                                  ProjectRel project,
                                  boolean leftChild)
Returns the child of the project that will be used as input into the new JoinRel once the projects are pulled above the JoinRel.

Parameters:
call - RelOptRuleCall
project - project RelNode
leftChild - true if the project corresponds to the left projection
Returns:
child of the project that will be used as input into the new JoinRel once the projects are pulled above the JoinRel

createProjectExprs

private void createProjectExprs(ProjectRel projRel,
                                RelNode joinChild,
                                int adjustmentAmount,
                                RexBuilder rexBuilder,
                                RelDataTypeField[] joinChildrenFields,
                                RexNode[] projExprs,
                                String[] fieldNames,
                                int offset)
Creates projection expressions corresponding to one of the inputs into the join

Parameters:
projRel - the projection input into the join (if it exists)
joinChild - the child of the projection input (if there is a projection); otherwise, this is the join input
adjustmentAmount - the amount the expressions need to be shifted by
rexBuilder - rex builder
joinChildrenFields - concatentation of the fields from the left and right join inputs (once the projections have been removed)
projExprs - array of projection expressions to be created
fieldNames - array of the names of the projection fields
offset - starting index in the arrays to be filled in