org.eigenbase.oj.rel
Class IterCalcRel

java.lang.Object
  extended by org.eigenbase.rel.AbstractRelNode
      extended by org.eigenbase.rel.SingleRel
          extended by org.eigenbase.oj.rel.IterCalcRel
All Implemented Interfaces:
Cloneable, JavaRel, RelNode

public class IterCalcRel
extends SingleRel
implements JavaRel

IterCalcRel is an iterator implementation of a combination of ProjectRel above an optional FilterRel. It takes a iterator as input, and for each row applies the filter condition if defined. Rows passing the filter expression are transformed via projection and returned. Note that the same object is always returned (with different values), so parents must not buffer the result.

Rules:


Field Summary
private static boolean abortOnError
           
private static boolean errorBuffering
           
protected  int flags
          Values defined in ProjectRelBase.Flags.
private  RexProgram program
           
private  String tag
           
 
Fields inherited from class org.eigenbase.rel.AbstractRelNode
digest, id, rowType, traits
 
Fields inherited from interface org.eigenbase.rel.RelNode
emptyArray
 
Constructor Summary
IterCalcRel(RelOptCluster cluster, RelNode child, RexProgram program, int flags)
           
IterCalcRel(RelOptCluster cluster, RelNode child, RexProgram program, int flags, String tag)
           
 
Method Summary
private static Statement assignInputRow(OJClass inputRowClass, Variable varInputRow, Variable varInputObj)
           
 IterCalcRel clone()
          Clones this RelNode.
protected  String computeDigest()
          Computes the digest.
 RelOptCost computeSelfCost(RelOptPlanner planner)
          Returns the cost of this plan (not including children).
 void explain(RelOptPlanWriter pw)
           
 int getFlags()
           
 RexProgram getProgram()
           
 double getRows()
          Returns an estimate of the number of rows this relational expression will return.
 String getTag()
           
 ParseTree implement(JavaRelImplementor implementor)
          Creates a plan for this expression according to a calling convention.
static Expression implementAbstract(JavaRelImplementor implementor, JavaRel rel, Expression childExp, Variable varInputRow, RelDataType inputRowType, RelDataType outputRowType, RexProgram program, String tag)
           
static Expression implementAbstractTupleIter(JavaRelImplementor implementor, JavaRel rel, Expression childExp, Variable varInputRow, RelDataType inputRowType, RelDataType outputRowType, RexProgram program, String tag)
          Generates code for a Java expression satisfying the TupleIter interface.
 JavaRel implementFieldAccess(JavaRelImplementor implementor, String fieldName)
          Burrows into a synthetic record and returns the underlying relation which provides the field called fieldName.
 boolean isBoxed()
           
static void setAbortOnError(boolean abortOnError)
          Disables throwing of exceptions on error.
static void setErrorBuffering(boolean errorBuffering)
          Allows errors to be buffered, in the event that they overflow the error handler.
 
Methods inherited from class org.eigenbase.rel.SingleRel
childrenAccept, deriveRowType, getChild, getInputs, replaceInput
 
Methods inherited from class org.eigenbase.rel.AbstractRelNode
cloneTraits, collectVariablesSet, collectVariablesUsed, getChildExps, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getOrCreateCorrelVariable, getQuery, getRelTypeName, getRowType, getTable, getTraits, getVariablesStopped, inheritTraitsFrom, isAccessTo, isDistinct, isValid, onRegister, recomputeDigest, register, registerCorrelVariable, setCorrelVariable, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eigenbase.rel.RelNode
childrenAccept, collectVariablesSet, collectVariablesUsed, getChildExps, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getInputs, getOrCreateCorrelVariable, getQuery, getRelTypeName, getRowType, getTable, getTraits, getVariablesStopped, isAccessTo, isDistinct, isValid, onRegister, recomputeDigest, registerCorrelVariable, replaceInput, setCorrelVariable
 

Field Detail

abortOnError

private static boolean abortOnError

errorBuffering

private static boolean errorBuffering

program

private final RexProgram program

flags

protected int flags
Values defined in ProjectRelBase.Flags.


tag

private String tag
Constructor Detail

IterCalcRel

public IterCalcRel(RelOptCluster cluster,
                   RelNode child,
                   RexProgram program,
                   int flags)

IterCalcRel

public IterCalcRel(RelOptCluster cluster,
                   RelNode child,
                   RexProgram program,
                   int flags,
                   String tag)
Method Detail

explain

public void explain(RelOptPlanWriter pw)
Specified by:
explain in interface RelNode
Overrides:
explain in class SingleRel

computeDigest

protected String computeDigest()
Description copied from class: AbstractRelNode
Computes the digest. Does not modify this object.

Overrides:
computeDigest in class AbstractRelNode

getRows

public double getRows()
Description copied from interface: RelNode
Returns an estimate of the number of rows this relational expression will return.

NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getRowCount(org.eigenbase.rel.RelNode), which gives plugins a chance to override the rel's default ideas about row count.

Specified by:
getRows in interface RelNode
Overrides:
getRows in class SingleRel

computeSelfCost

public RelOptCost computeSelfCost(RelOptPlanner planner)
Description copied from interface: RelNode
Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.

NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getNonCumulativeCost(org.eigenbase.rel.RelNode), which gives plugins a chance to override the rel's default ideas about cost.

Specified by:
computeSelfCost in interface RelNode
Overrides:
computeSelfCost in class AbstractRelNode

clone

public IterCalcRel clone()
Description copied from interface: RelNode
Clones this RelNode.

Traits of the RelNode must be explicitly cloned, using AbstractRelNode.inheritTraitsFrom(AbstractRelNode), as the RelNode may have traits of which it has no knowledge. Example implementation:

     public MyRelNode clone()
     {
         MyRelNode clone = new MyRelNode(...);
         clone.inheritTraitsFrom(this);
         return clone;
     }
 
N.B.: This method must be overridden whenever an existing, concrete RelNode is extended. Otherwise, calling clone() will produce a differently typed RelNode, resulting in invalid or incorrect query plans.

Specified by:
clone in interface RelNode
Specified by:
clone in class AbstractRelNode
Returns:
a clone of this RelNode

getFlags

public int getFlags()

isBoxed

public boolean isBoxed()

implementFieldAccess

public JavaRel implementFieldAccess(JavaRelImplementor implementor,
                                    String fieldName)
Burrows into a synthetic record and returns the underlying relation which provides the field called fieldName.


setAbortOnError

public static void setAbortOnError(boolean abortOnError)
Disables throwing of exceptions on error. Do not set this false without a very good reason! Doing so will prevent type cast, overflow/underflow, etc. errors in Farrago.


setErrorBuffering

public static void setErrorBuffering(boolean errorBuffering)
Allows errors to be buffered, in the event that they overflow the error handler.

Parameters:
errorBuffering - whether to buffer errors

implementAbstract

public static Expression implementAbstract(JavaRelImplementor implementor,
                                           JavaRel rel,
                                           Expression childExp,
                                           Variable varInputRow,
                                           RelDataType inputRowType,
                                           RelDataType outputRowType,
                                           RexProgram program,
                                           String tag)

implementAbstractTupleIter

public static Expression implementAbstractTupleIter(JavaRelImplementor implementor,
                                                    JavaRel rel,
                                                    Expression childExp,
                                                    Variable varInputRow,
                                                    RelDataType inputRowType,
                                                    RelDataType outputRowType,
                                                    RexProgram program,
                                                    String tag)
Generates code for a Java expression satisfying the TupleIter interface. The generated code allocates a CalcTupleIter with a dynamic TupleIter.fetchNext() method. If the "abort on error" flag is false, or an error handling tag is specified, then fetchNext is written to handle row errors.

Row errors are handled by wrapping expressions that can fail with a try/catch block. A caught RuntimeException is then published to an "connection variable." In the event that errors can overflow, an "error buffering" flag allows them to be posted again on the next iteration of fetchNext.

Parameters:
implementor - an object that implements relations as Java code
rel - the relation to be implemented
childExp - the implemented child of the relation
varInputRow - the Java variable to use for the input row
inputRowType - the rel data type of the input row
outputRowType - the rel data type of the output row
program - the rex program to implemented by the relation
tag - an error handling tag
Returns:
a Java expression satisfying the TupleIter interface

implement

public ParseTree implement(JavaRelImplementor implementor)
Description copied from interface: JavaRel
Creates a plan for this expression according to a calling convention.

Specified by:
implement in interface JavaRel
Parameters:
implementor - implementor

getProgram

public RexProgram getProgram()

getTag

public String getTag()

assignInputRow

private static Statement assignInputRow(OJClass inputRowClass,
                                        Variable varInputRow,
                                        Variable varInputObj)