org.eigenbase.sarg
Class SargFactory

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

public class SargFactory
extends Object

SargFactory creates new instances of various sarg-related objects.

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

Field Summary
private  RexBuilder rexBuilder
           
private  RexNode rexNull
           
 
Constructor Summary
SargFactory(RexBuilder rexBuilder)
          Creates a new SargFactory.
 
Method Summary
 RexBuilder getRexBuilder()
           
 SargMutableEndpoint newEndpoint(RelDataType dataType)
          Creates a new endpoint.
 SargIntervalExpr newIntervalExpr(RelDataType dataType)
          Creates a new interval expression.
 SargIntervalExpr newIntervalExpr(RelDataType dataType, SqlNullSemantics nullSemantics)
          Creates a new unbounded interval expression with non-default null semantics.
 RexNode newNullLiteral()
           
 SargRexAnalyzer newRexAnalyzer()
           
 SargRexAnalyzer newRexAnalyzer(boolean simpleMode)
           
 SargRexAnalyzer newRexAnalyzer(int lowerRexInputIdx, int upperRexInputIdx)
           
 SargSetExpr newSetExpr(RelDataType dataType, SargSetOperator setOp)
          Creates a new set expression, initially with no children.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rexBuilder

private final RexBuilder rexBuilder

rexNull

private final RexNode rexNull
Constructor Detail

SargFactory

public SargFactory(RexBuilder rexBuilder)
Creates a new SargFactory.

Parameters:
rexBuilder - factory for instances of RexNode, needed internally in the sarg representation, and also for recomposing sargs into equivalent rex trees
Method Detail

newEndpoint

public SargMutableEndpoint newEndpoint(RelDataType dataType)
Creates a new endpoint. Initially, the endpoint represents a lower bound of negative infinity.

Parameters:
dataType - datatype for domain
Returns:
new endpoint

newIntervalExpr

public SargIntervalExpr newIntervalExpr(RelDataType dataType)
Creates a new interval expression. The interval starts out as unbounded (meaning it includes every non-null value of the datatype), with SqlNullSemantics.NULL_MATCHES_NOTHING.

Parameters:
dataType - datatype for domain

newIntervalExpr

public SargIntervalExpr newIntervalExpr(RelDataType dataType,
                                        SqlNullSemantics nullSemantics)
Creates a new unbounded interval expression with non-default null semantics.

Parameters:
dataType - datatype for domain
nullSemantics - null semantics governing searches on this interval

newSetExpr

public SargSetExpr newSetExpr(RelDataType dataType,
                              SargSetOperator setOp)
Creates a new set expression, initially with no children.

Parameters:
dataType - datatype for domain
setOp - set operator

newRexAnalyzer

public SargRexAnalyzer newRexAnalyzer()
Returns:
new analyzer for rex expressions

newRexAnalyzer

public SargRexAnalyzer newRexAnalyzer(boolean simpleMode)
Parameters:
simpleMode - if true, the analyzer restricts the types of predicates it allows; the following are disallowed - conjuntions on the same RexInputRef, more than one range predicate, and all disjunctions
Returns:
new analyzer for rex expressions

newRexAnalyzer

public SargRexAnalyzer newRexAnalyzer(int lowerRexInputIdx,
                                      int upperRexInputIdx)
Parameters:
lowerRexInputIdx - if >= 0, treat RexInputRefs whose index is within the range [lowerRexInputIdx, upperRexInputIdx) as coordinates in expressions
upperRexInputIdx - if >= 0, treat RexInputRefs whose index is within the range [lowerRexInputIdx, upperRexInputIdx) as coordinates in expressions
Returns:
new analyzer for rex expressions

newNullLiteral

public RexNode newNullLiteral()
Returns:
the null literal, which can be used to represent a range matching the null value

getRexBuilder

public RexBuilder getRexBuilder()
Returns:
RexBuilder used by this factory