org.eigenbase.sarg
Class SargSetExpr

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

public class SargSetExpr
extends Object
implements SargExpr

SargSetExpr represents the application of a set operator to zero or more child sarg expressions.

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

Nested Class Summary
private static class SargSetExpr.IntervalComparator
          Comparator used in evaluateUnionOp.
 
Field Summary
private  List<SargExpr> children
           
private  RelDataType dataType
           
private  SargFactory factory
           
private  SargSetOperator setOp
           
 
Constructor Summary
SargSetExpr(SargFactory factory, RelDataType dataType, SargSetOperator setOp)
           
 
Method Summary
 void addChild(SargExpr child)
          Adds a child to this expression.
 void collectDynamicParams(Set<RexDynamicParam> dynamicParams)
          Collects all dynamic parameters referenced by this expression.
 SargIntervalSequence evaluate()
          Resolves this expression into a fixed SargIntervalSequence.
private  List<SargIntervalSequence> evaluateChildren(SargSetExpr setExpr)
           
 SargIntervalSequence evaluateComplemented()
          Resolves the complement of this expression into a fixed SargIntervalSequence.
private  SargIntervalSequence evaluateIntersection(List<SargIntervalSequence> list)
           
private  SargIntervalSequence evaluateUnion(List<SargIntervalSequence> list)
           
 List<SargExpr> getChildren()
           
 RelDataType getDataType()
           
 SargFactory getFactory()
           
private  void intersectSequences(SargIntervalSequence targetSeq, SargIntervalSequence sourceSeq)
           
 String toString()
          Overrides the default Object.toString.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

factory

private final SargFactory factory

dataType

private final RelDataType dataType

setOp

private final SargSetOperator setOp

children

private final List<SargExpr> children
Constructor Detail

SargSetExpr

SargSetExpr(SargFactory factory,
            RelDataType dataType,
            SargSetOperator setOp)
See Also:
SargFactory.newSetExpr(org.eigenbase.reltype.RelDataType, org.eigenbase.sarg.SargSetOperator)
Method Detail

getChildren

public List<SargExpr> getChildren()
Returns:
a read-only list of this expression's children (the returned children themselves are modifiable)

addChild

public void addChild(SargExpr child)
Adds a child to this expression.

Parameters:
child - child to add

getFactory

public SargFactory getFactory()
Specified by:
getFactory in interface SargExpr
Returns:
the factory which produced this expression

getDataType

public RelDataType getDataType()
Specified by:
getDataType in interface SargExpr
Returns:
datatype for coordinates of search domain

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 Object

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

evaluateChildren

private List<SargIntervalSequence> evaluateChildren(SargSetExpr setExpr)

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

evaluateUnion

private SargIntervalSequence evaluateUnion(List<SargIntervalSequence> list)

evaluateIntersection

private SargIntervalSequence evaluateIntersection(List<SargIntervalSequence> list)

intersectSequences

private void intersectSequences(SargIntervalSequence targetSeq,
                                SargIntervalSequence sourceSeq)

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