net.sf.farrago.query
Class FarragoReduceExpressionsRule

java.lang.Object
  extended by org.eigenbase.relopt.RelOptRule
      extended by net.sf.farrago.query.FarragoReduceExpressionsRule

public abstract class FarragoReduceExpressionsRule
extends RelOptRule

Collection of planner rules that apply various simplifying transformations on RexNode trees. Currently, there are two transformations:

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/query/FarragoReduceExpressionsRule.java#27 $
Author:
John V. Sichi

Nested Class Summary
private static class FarragoReduceExpressionsRule.ReducibleExprLocator
          Helper class used to locate expressions that either can be reduced to literals or contain redundant casts.
(package private) static class FarragoReduceExpressionsRule.ReentrantValuesStmt
          Evaluates constant expressions via a reentrant query of the form "VALUES (exp1, exp2, exp3, ...)".
private static class FarragoReduceExpressionsRule.RexReplacer
          Replaces expressions with their reductions.
 
Field Summary
static FarragoReduceExpressionsRule calcInstance
           
static Pattern EXCLUSION_PATTERN
          Regular expression which matches the description of all instances of this rule and FarragoReduceValuesRule also.
static FarragoReduceExpressionsRule filterInstance
          Singleton rule which reduces constants inside a FilterRel.
static FarragoReduceExpressionsRule joinInstance
           
static FarragoReduceExpressionsRule projectInstance
           
 
Fields inherited from class org.eigenbase.relopt.RelOptRule
ANY, description, operands
 
Constructor Summary
private FarragoReduceExpressionsRule(Class<? extends RelNode> relClass)
          Creates a new FarragoReduceExpressionsRule object.
 
Method Summary
private static void findReducibleExps(FarragoSessionPreparingStmt preparingStmt, List<RexNode> exps, List<RexNode> constExps, List<Boolean> addCasts, List<RexNode> removableCasts)
          Locates expressions that can be reduced to literals or converted to expressions with redundant casts removed.
(package private) static FarragoSession getSession(RelNode rel)
           
(package private) static boolean reduceExpressions(RelNode rel, List<RexNode> expList)
          Reduces a list of expressions.
 
Methods inherited from class org.eigenbase.relopt.RelOptRule
convert, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, mergeTraitsAndConvert, mergeTraitsAndConvert, onMatch, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EXCLUSION_PATTERN

public static final Pattern EXCLUSION_PATTERN
Regular expression which matches the description of all instances of this rule and FarragoReduceValuesRule also. Use it to prevent the planner from invoking these rules.


filterInstance

public static final FarragoReduceExpressionsRule filterInstance
Singleton rule which reduces constants inside a FilterRel. If the condition is a constant, the filter is removed (if TRUE) or replaced with EmptyRel (if FALSE or NULL).


projectInstance

public static final FarragoReduceExpressionsRule projectInstance

joinInstance

public static final FarragoReduceExpressionsRule joinInstance

calcInstance

public static final FarragoReduceExpressionsRule calcInstance
Constructor Detail

FarragoReduceExpressionsRule

private FarragoReduceExpressionsRule(Class<? extends RelNode> relClass)
Creates a new FarragoReduceExpressionsRule object.

Parameters:
relClass - class of rels to which this rule should apply
Method Detail

reduceExpressions

static boolean reduceExpressions(RelNode rel,
                                 List<RexNode> expList)
Reduces a list of expressions.

Parameters:
rel - Relational expression
expList - List of expressions, modified in place
Returns:
whether reduction found something to change, and succeeded

getSession

static FarragoSession getSession(RelNode rel)

findReducibleExps

private static void findReducibleExps(FarragoSessionPreparingStmt preparingStmt,
                                      List<RexNode> exps,
                                      List<RexNode> constExps,
                                      List<Boolean> addCasts,
                                      List<RexNode> removableCasts)
Locates expressions that can be reduced to literals or converted to expressions with redundant casts removed.

Parameters:
preparingStmt - the statement containing the expressions
exps - list of candidate expressions to be examined for reduction
constExps - returns the list of expressions that can be constant reduced
addCasts - indicator for each expression that can be constant reduced, whether a cast of the resulting reduced expression is potentially necessary
removableCasts - returns the list of cast expressions where the cast can be removed