org.eigenbase.rel.rules
Class ReduceDecimalsRule

java.lang.Object
  extended by org.eigenbase.relopt.RelOptRule
      extended by org.eigenbase.rel.rules.ReduceDecimalsRule

public class ReduceDecimalsRule
extends RelOptRule

ReduceDecimalsRule is a rule which reduces decimal operations (such as casts or arithmetic) into operations involving more primitive types (such as longs and doubles). The rule allows eigenbase implementations to deal with decimals in a consistent manner, while saving the effort of implementing them.

The rule can be applied to a CalcRel with a program for which RexUtil.requiresDecimalExpansion(org.eigenbase.rex.RexNode, boolean) returns true. The rule relies on a RexShuttle to walk over relational expressions and replace them.

While decimals are generally not implemented by the eigenbase runtime, the rule is optionally applied, in order to support the situation in which we would like to push down decimal operations to an external database.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/rel/rules/ReduceDecimalsRule.java#3 $
Author:
jpham

Nested Class Summary
private  class ReduceDecimalsRule.BinaryArithmeticExpander
          Expands a decimal arithmetic expression
private  class ReduceDecimalsRule.CaseExpander
          Expander that rewrites case expressions, in place.
private  class ReduceDecimalsRule.CastArgAsDoubleExpander
          An expander which casts decimal arguments as doubles
private  class ReduceDecimalsRule.CastArgAsReturnExpander
          An expander which casts decimal arguments as call return type
private  class ReduceDecimalsRule.CastArgAsTypeExpander
          An expander which casts decimal arguments as another type
private  class ReduceDecimalsRule.CastExpander
          Expands a decimal cast expression
private  class ReduceDecimalsRule.CeilExpander
          Expander that rewrites ceiling(decimal) expressions:
 class ReduceDecimalsRule.DecimalShuttle
          A shuttle which converts decimal expressions to expressions based on longs.
private  class ReduceDecimalsRule.ExpanderMap
          Maps a RexCall to a RexExpander
private  class ReduceDecimalsRule.FloorExpander
          Expander that rewrites floor(decimal) expressions:
private  class ReduceDecimalsRule.PassThroughExpander
          An expander that substitutes decimals with their integer representations.
private  class ReduceDecimalsRule.ReinterpretExpander
          This expander simplifies reinterpret calls.
 class ReduceDecimalsRule.RexExpander
          Rewrites a decimal expression for a specific set of SqlOperator's.
 
Field Summary
static ReduceDecimalsRule instance
           
 
Fields inherited from class org.eigenbase.relopt.RelOptRule
ANY, description, operands
 
Constructor Summary
private ReduceDecimalsRule()
          Creates a ReduceDecimalsRule.
 
Method Summary
 CallingConvention getOutConvention()
          Returns the calling convention of the result of firing this rule, null if not known.
 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
 

Field Detail

instance

public static final ReduceDecimalsRule instance
Constructor Detail

ReduceDecimalsRule

private ReduceDecimalsRule()
Creates a ReduceDecimalsRule.

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