org.eigenbase.sarg
Class SargRexAnalyzer

java.lang.Object
  extended by org.eigenbase.sarg.SargRexAnalyzer

public class SargRexAnalyzer
extends Object

SargRexAnalyzer attempts to translate a rex predicate into a SargBinding. It assumes that the predicate expression is already well-formed.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/sarg/SargRexAnalyzer.java#16 $
Author:
John V. Sichi

Nested Class Summary
private  class SargRexAnalyzer.BooleanConvertlet
           
private  class SargRexAnalyzer.CallConvertlet
           
private  class SargRexAnalyzer.ComparisonConvertlet
           
private  class SargRexAnalyzer.NodeVisitor
           
 
Field Summary
private  RexInputRef boundInputRef
           
private  Map<SqlOperator,SargRexAnalyzer.CallConvertlet> convertletMap
           
private  RexNode coordinate
           
private  List<SargExpr> exprStack
           
private  SargFactory factory
           
private  boolean failed
           
private  int lowerRexInputIdx
          If >= 0, treat RexInputRefs whose index is within the range [lowerRexInputIdx, upperRexInputIdx) as coordinates in expressions
private  List<RexNode> nonSargFilterList
           
private  boolean reverse
           
private  List<RexNode> rexCFList
           
private  Map<SargExpr,RexNode> sarg2RexMap
           
private  List<SargBinding> sargBindingList
           
private  boolean simpleMode
          If true, conjuntions on the same input reference are disallowed, as well as all disjunctions.
private  int upperRexInputIdx
          If >= 0, treat RexInputRefs whose index is within the range [lowerRexInputIdx, upperRexInputIdx) as coordinates in expressions
private  boolean variableSeen
           
 
Constructor Summary
SargRexAnalyzer(SargFactory factory, boolean simpleMode)
           
SargRexAnalyzer(SargFactory factory, boolean simpleMode, int lowerRexInputRef, int upperRexInputRef)
           
 
Method Summary
 SargBinding analyze(RexNode rexPredicate)
          Analyzes a rex predicate.
 List<SargBinding> analyzeAll(RexNode rexPredicate)
          Analyzes a rex predicate.
private  void clearLeaf()
           
 RexNode getNonSargFilterRexNode()
          Reconstructs a rex predicate from the non-sargable filter predicates which are AND'ed together.
 RexNode getPostFilterRexNode()
          Deprecated. use getNonSargFilterRexNode()
 RexNode getResidualSargRexNode(List<SargBinding> residualSargList)
          Deprecated. use getSargBindingListToRexNode(List)
 RexNode getSargBindingListToRexNode(List<SargBinding> sargBindingList)
          Reconstructs a rex predicate from a list of SargBindings which are AND'ed together.
private  void recomposeConjunction()
          Reconstructs a rex predicate from a list of SargExprs which will be AND'ed together.
private  void registerConvertlet(SqlOperator op, SargRexAnalyzer.CallConvertlet convertlet)
           
private  boolean testDynamicParamSupport(SargExpr sargExpr)
          Tests whether we can support the usage of dynamic parameters in a given SargExpr.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

private final SargFactory factory

simpleMode

private final boolean simpleMode
If true, conjuntions on the same input reference are disallowed, as well as all disjunctions. Also, only a single range predicate is allowed.


convertletMap

private final Map<SqlOperator,SargRexAnalyzer.CallConvertlet> convertletMap

failed

private boolean failed

boundInputRef

private RexInputRef boundInputRef

coordinate

private RexNode coordinate

variableSeen

private boolean variableSeen

reverse

private boolean reverse

exprStack

private List<SargExpr> exprStack

rexCFList

private List<RexNode> rexCFList

nonSargFilterList

private List<RexNode> nonSargFilterList

sargBindingList

private List<SargBinding> sargBindingList

sarg2RexMap

private Map<SargExpr,RexNode> sarg2RexMap

lowerRexInputIdx

private int lowerRexInputIdx
If >= 0, treat RexInputRefs whose index is within the range [lowerRexInputIdx, upperRexInputIdx) as coordinates in expressions


upperRexInputIdx

private int upperRexInputIdx
If >= 0, treat RexInputRefs whose index is within the range [lowerRexInputIdx, upperRexInputIdx) as coordinates in expressions

Constructor Detail

SargRexAnalyzer

SargRexAnalyzer(SargFactory factory,
                boolean simpleMode)

SargRexAnalyzer

SargRexAnalyzer(SargFactory factory,
                boolean simpleMode,
                int lowerRexInputRef,
                int upperRexInputRef)
Method Detail

registerConvertlet

private void registerConvertlet(SqlOperator op,
                                SargRexAnalyzer.CallConvertlet convertlet)

recomposeConjunction

private void recomposeConjunction()
Reconstructs a rex predicate from a list of SargExprs which will be AND'ed together.


analyzeAll

public List<SargBinding> analyzeAll(RexNode rexPredicate)
Analyzes a rex predicate.

Parameters:
rexPredicate - predicate to be analyzed
Returns:
a list of SargBindings contained in the input rex predicate

testDynamicParamSupport

private boolean testDynamicParamSupport(SargExpr sargExpr)
Tests whether we can support the usage of dynamic parameters in a given SargExpr.

Parameters:
sargExpr - expression to test
Returns:
true if supported

getNonSargFilterRexNode

public RexNode getNonSargFilterRexNode()
Reconstructs a rex predicate from the non-sargable filter predicates which are AND'ed together.

Returns:
the rex predicate reconstructed from the non-sargable predicates.

getPostFilterRexNode

public RexNode getPostFilterRexNode()
Deprecated. use getNonSargFilterRexNode()


getSargBindingListToRexNode

public RexNode getSargBindingListToRexNode(List<SargBinding> sargBindingList)
Reconstructs a rex predicate from a list of SargBindings which are AND'ed together.

Parameters:
sargBindingList - list of SargBindings to be converted.
Returns:
the rex predicate reconstructed from the list of SargBindings.

getResidualSargRexNode

public RexNode getResidualSargRexNode(List<SargBinding> residualSargList)
Deprecated. use getSargBindingListToRexNode(List)


analyze

public SargBinding analyze(RexNode rexPredicate)
Analyzes a rex predicate.

Parameters:
rexPredicate - predicate to be analyzed
Returns:
corresponding bound sarg expression, or null if analysis failed

clearLeaf

private void clearLeaf()