net.sf.farrago.namespace.impl
Class MedAbstractFennelProjectionRule

java.lang.Object
  extended by org.eigenbase.relopt.RelOptRule
      extended by net.sf.farrago.namespace.impl.MedAbstractFennelProjectionRule
Direct Known Subclasses:
FtrsTableProjectionRule, LcsTableProjectionRule

public abstract class MedAbstractFennelProjectionRule
extends RelOptRule

MedAbstractFennelProjectionRule is a base class for implementing projection rules on different storage mechanisms

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/namespace/impl/MedAbstractFennelProjectionRule.java#14 $
Author:
Zelaine Fong

Field Summary
 
Fields inherited from class org.eigenbase.relopt.RelOptRule
ANY, description, operands
 
Constructor Summary
MedAbstractFennelProjectionRule(RelOptRuleOperand operand)
          Creates a new MedAbstractFennelProjectionRule object.
 
Method Summary
 RelNode createNewRelNode(RelNode projectedScan, ProjectRel origProject, boolean needRename, ProjectRel newProject)
          Creates new RelNodes replacing/removing the original project/row scan
 boolean createProjectionList(FennelRel origScan, ProjectRel projRel, List<Integer> projectedColumns, PushProjector.ExprCondition preserveExprCondition, RexNode defaultExpr, List<ProjectRel> newProjList)
          Creates projection list for scan.
 CallingConvention getOutConvention()
          Returns the calling convention of the result of firing this rule, null if not known.
protected  Integer mapFieldRef(RexNode exp, List<String> origFieldName, RelDataType rowType)
           
protected  Integer mapProjCol(RexNode exp, List<String> origFieldName, RelDataType rowType)
          Maps a projection expression to its underlying field reference
abstract  void onMatch(RelOptRuleCall call)
          Receives notification about a rule match.
 
Methods inherited from class org.eigenbase.relopt.RelOptRule
convert, equals, equals, getOperand, getOperands, getOutTrait, hashCode, matches, mergeTraitsAndConvert, mergeTraitsAndConvert, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MedAbstractFennelProjectionRule

public MedAbstractFennelProjectionRule(RelOptRuleOperand operand)
Creates a new MedAbstractFennelProjectionRule object.

Parameters:
operand - root operand to pass to RelOptRule constructor
Method Detail

getOutConvention

public CallingConvention getOutConvention()
Description copied from class: RelOptRule
Returns the calling convention of the result of firing this rule, null if not known.

Overrides:
getOutConvention in class RelOptRule

onMatch

public abstract 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)

createProjectionList

public boolean createProjectionList(FennelRel origScan,
                                    ProjectRel projRel,
                                    List<Integer> projectedColumns,
                                    PushProjector.ExprCondition preserveExprCondition,
                                    RexNode defaultExpr,
                                    List<ProjectRel> newProjList)
Creates projection list for scan. If the projection contains expressions, then the input references from those expressions are extracted and that list of references becomes the projection list.

Parameters:
origScan - row scan underneath the project
projRel - ProjectRel that we will be creating the projection for
projectedColumns - returns a list of the projected column ordinals, if it is possible to project
preserveExprCondition - condition that identifies special expressions that should be preserved in the projection
defaultExpr - expression to be used in the projection if no fields or special columns are selected
newProjList - returns a new projection RelNode corresponding to a projection that now references a rowscan that is projecting the input references that were extracted from the original projection expressions; if the original expression didn't contain expressions, then this list is returned empty
Returns:
true if columns in projection list from the scan need to be renamed

mapProjCol

protected Integer mapProjCol(RexNode exp,
                             List<String> origFieldName,
                             RelDataType rowType)
Maps a projection expression to its underlying field reference

Parameters:
exp - expression to be mapped
origFieldName - returns field name corresponding to the field reference
rowType - row from which the field reference originated
Returns:
ordinal representing the projection element

mapFieldRef

protected Integer mapFieldRef(RexNode exp,
                              List<String> origFieldName,
                              RelDataType rowType)

createNewRelNode

public RelNode createNewRelNode(RelNode projectedScan,
                                ProjectRel origProject,
                                boolean needRename,
                                ProjectRel newProject)
Creates new RelNodes replacing/removing the original project/row scan

Parameters:
projectedScan - new scan that is now projected
origProject - original projection
needRename - true if fields from the row scan need to be renamed
newProject - projection that contains the new projection expressions, in the case where the original projection cannot be removed because it projects expressions
Returns:
new RelNode