org.eigenbase.sarg
Class SargIntervalExpr

java.lang.Object
  extended by org.eigenbase.sarg.SargIntervalBase
      extended by org.eigenbase.sarg.SargIntervalExpr
All Implemented Interfaces:
SargExpr

public class SargIntervalExpr
extends SargIntervalBase
implements SargExpr

SargIntervalExpr represents an expression which can be resolved to a fixed SargInterval.

Null values require special treatment in expressions. Normally, for intervals of any kind, nulls are not considered to be within the domain of search values. This behavior can be modified by setting the SqlNullSemantics to a value other than the default. This happens implicitly when a point interval is created matching the null value. When null values are considered to be part of the domain, the ordering is defined as for SargInterval.

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

Field Summary
private  SqlNullSemantics nullSemantics
           
 
Fields inherited from class org.eigenbase.sarg.SargIntervalBase
factory, lowerBound, upperBound
 
Constructor Summary
SargIntervalExpr(SargFactory factory, RelDataType dataType, SqlNullSemantics nullSemantics)
           
 
Method Summary
 void collectDynamicParams(Set<RexDynamicParam> dynamicParams)
          Collects all dynamic parameters referenced by this expression.
 SargIntervalSequence evaluate()
          Resolves this expression into a fixed SargIntervalSequence.
 SargIntervalSequence evaluateComplemented()
          Resolves the complement of this expression into a fixed SargIntervalSequence.
 SqlNullSemantics getNullSemantics()
           
 void setEmpty()
          Sets this interval to empty (matching nothing at all).
 void setLower(RexNode coordinate, SargStrictness strictness)
          Sets the lower bound for this interval.
 void setNull()
          Sets this interval to represent a single point matching the null value.
 void setPoint(RexNode coordinate)
          Sets this interval to represent a single point (possibly the null value).
 void setUnconstrained()
          Sets this interval to unconstrained (matching everything, including null).
 void setUpper(RexNode coordinate, SargStrictness strictness)
          Sets the upper bound for this interval.
 String toString()
          Overrides the default Object.toString.
 void unsetLower()
          Removes the lower bound for this interval, setting it to -infinity.
 void unsetUpper()
          Removes the upper bound for this interval, setting it to +infinity.
 
Methods inherited from class org.eigenbase.sarg.SargIntervalBase
getDataType, getFactory, getLowerBound, getUpperBound, isEmpty, isPoint, isRange, isUnconstrained
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eigenbase.sarg.SargExpr
getDataType, getFactory
 

Field Detail

nullSemantics

private SqlNullSemantics nullSemantics
Constructor Detail

SargIntervalExpr

SargIntervalExpr(SargFactory factory,
                 RelDataType dataType,
                 SqlNullSemantics nullSemantics)
See Also:
SargFactory.newIntervalExpr(org.eigenbase.reltype.RelDataType)
Method Detail

getNullSemantics

public SqlNullSemantics getNullSemantics()
Returns:
null semantics which apply for searches on this interval

setPoint

public void setPoint(RexNode coordinate)
Description copied from class: SargIntervalBase
Sets this interval to represent a single point (possibly the null value).

Overrides:
setPoint in class SargIntervalBase
Parameters:
coordinate - coordinate of point to set, or null for the null value

setNull

public void setNull()
Description copied from class: SargIntervalBase
Sets this interval to represent a single point matching the null value.

Overrides:
setNull in class SargIntervalBase

setLower

public void setLower(RexNode coordinate,
                     SargStrictness strictness)
Description copied from class: SargIntervalBase
Sets the lower bound for this interval.

Overrides:
setLower in class SargIntervalBase
Parameters:
coordinate - coordinate of point to set, must not be null
strictness - strictness

setUpper

public void setUpper(RexNode coordinate,
                     SargStrictness strictness)
Description copied from class: SargIntervalBase
Sets the upper bound for this interval.

Overrides:
setUpper in class SargIntervalBase
Parameters:
coordinate - coordinate of point to set
strictness - boundary strictness

unsetLower

public void unsetLower()
Description copied from class: SargIntervalBase
Removes the lower bound for this interval, setting it to -infinity.

Overrides:
unsetLower in class SargIntervalBase

unsetUpper

public void unsetUpper()
Description copied from class: SargIntervalBase
Removes the upper bound for this interval, setting it to +infinity.

Overrides:
unsetUpper in class SargIntervalBase

setUnconstrained

public void setUnconstrained()
Description copied from class: SargIntervalBase
Sets this interval to unconstrained (matching everything, including null).

Overrides:
setUnconstrained in class SargIntervalBase

setEmpty

public void setEmpty()
Description copied from class: SargIntervalBase
Sets this interval to empty (matching nothing at all).

Overrides:
setEmpty in class SargIntervalBase

toString

public String toString()
Description copied from interface: SargExpr
Overrides the default Object.toString. The result must be safe for use in a RelNode digest.

Specified by:
toString in interface SargExpr
Overrides:
toString in class SargIntervalBase

evaluate

public SargIntervalSequence evaluate()
Description copied from interface: SargExpr
Resolves this expression into a fixed SargIntervalSequence.

TODO jvs 17-Jan-2006: add binding for dynamic params so they can be evaluated as well

Specified by:
evaluate in interface SargExpr
Returns:
immutable ordered sequence of disjoint intervals

collectDynamicParams

public void collectDynamicParams(Set<RexDynamicParam> dynamicParams)
Description copied from interface: SargExpr
Collects all dynamic parameters referenced by this expression.

Specified by:
collectDynamicParams in interface SargExpr
Parameters:
dynamicParams - receives dynamic parameter references

evaluateComplemented

public SargIntervalSequence evaluateComplemented()
Description copied from interface: SargExpr
Resolves the complement of this expression into a fixed SargIntervalSequence.

Specified by:
evaluateComplemented in interface SargExpr
Returns:
immutable ordered sequence of disjoint intervals