net.sf.farrago.query
Class FarragoJavaUdxRel

java.lang.Object
  extended by org.eigenbase.rel.AbstractRelNode
      extended by org.eigenbase.rel.TableFunctionRelBase
          extended by net.sf.farrago.query.FarragoJavaUdxRel
All Implemented Interfaces:
Cloneable, JavaRel, RelNode

public class FarragoJavaUdxRel
extends TableFunctionRelBase
implements JavaRel

FarragoJavaUdxRel is the implementation for a TableFunctionRel which invokes a Java UDX (user-defined transformation).

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/query/FarragoJavaUdxRel.java#26 $
Author:
John V. Sichi

Field Summary
private  String serverMofId
           
 
Fields inherited from class org.eigenbase.rel.TableFunctionRelBase
inputs
 
Fields inherited from class org.eigenbase.rel.AbstractRelNode
digest, id, traits
 
Fields inherited from interface org.eigenbase.rel.RelNode
emptyArray
 
Constructor Summary
FarragoJavaUdxRel(RelOptCluster cluster, RexNode rexCall, RelDataType rowType, String serverMofId)
          Creates a FarragoJavaUdxRel with no relational inputs.
FarragoJavaUdxRel(RelOptCluster cluster, RexNode rexCall, RelDataType rowType, String serverMofId, RelNode[] inputs)
          Creates a FarragoJavaUdxRel.
 
Method Summary
 FarragoJavaUdxRel clone()
          Clones this RelNode.
 RelOptCost computeSelfCost(RelOptPlanner planner)
          Returns the cost of this plan (not including children).
 void explain(RelOptPlanWriter pw)
           
private  Expression generateTypeLookupCall(JavaRelImplementor implementor, RelNode relNode)
          Stores the row type for a relational expression in the PreparingStmt, and generates a call which will retrieve it from the executable context at runtime.
 ParseTree implement(JavaRelImplementor implementor)
          Creates a plan for this expression according to a calling convention.
static RelNode newUdxRel(FarragoPreparingStmt preparingStmt, RelDataType rowType, String udxSpecificName, String serverMofId, RexNode[] args, RelNode[] relInputs)
          Constructs a new instance of FarragoJavaUdxRel via a lookup from the catalog.
 
Methods inherited from class org.eigenbase.rel.TableFunctionRelBase
deriveRowType, getCall, getChildExps, getColumnMappings, getInputs, getRows, replaceInput, setColumnMappings
 
Methods inherited from class org.eigenbase.rel.AbstractRelNode
childrenAccept, cloneTraits, collectVariablesSet, collectVariablesUsed, computeDigest, 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, getRows, getRowType, getTable, getTraits, getVariablesStopped, isAccessTo, isDistinct, isValid, onRegister, recomputeDigest, registerCorrelVariable, replaceInput, setCorrelVariable
 

Field Detail

serverMofId

private final String serverMofId
Constructor Detail

FarragoJavaUdxRel

public FarragoJavaUdxRel(RelOptCluster cluster,
                         RexNode rexCall,
                         RelDataType rowType,
                         String serverMofId,
                         RelNode[] inputs)
Creates a FarragoJavaUdxRel.

Parameters:
cluster - RelOptCluster this relational expression belongs to
rexCall - function invocation expression
rowType - row type produced by function
serverMofId - MOFID of data server to associate with this UDX invocation, or null for none
inputs - 0 or more relational inputs

FarragoJavaUdxRel

public FarragoJavaUdxRel(RelOptCluster cluster,
                         RexNode rexCall,
                         RelDataType rowType,
                         String serverMofId)
Creates a FarragoJavaUdxRel with no relational inputs.

Parameters:
cluster - RelOptCluster this relational expression belongs to
rexCall - function invocation expression
rowType - row type produced by function
serverMofId - MOFID of data server to associate with this UDX invocation, or null for none
Method Detail

newUdxRel

public static RelNode newUdxRel(FarragoPreparingStmt preparingStmt,
                                RelDataType rowType,
                                String udxSpecificName,
                                String serverMofId,
                                RexNode[] args,
                                RelNode[] relInputs)
Constructs a new instance of FarragoJavaUdxRel via a lookup from the catalog. This is intended for use by optimizer rules which need to insert system-defined UDX invocations into a plan.

Parameters:
preparingStmt - statement being prepared
rowType - type descriptor for UDX output row
udxSpecificName - specific name with which the UDX was created (either via the SPECIFIC keyword or the invocation name if SPECIFIC was not specified); this can be a qualified name, possibly with quoted identifiers, e.g. x.y.z or x."y".z
serverMofId - if not null, the invoked UDX can access a SQL/MED data server with the given MOFID at runtime via FarragoUdrRuntime.getDataServerRuntimeSupport(java.lang.Object)
args - arguments to UDX invocation
relInputs - relational inputs

clone

public FarragoJavaUdxRel 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

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

explain

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

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

generateTypeLookupCall

private Expression generateTypeLookupCall(JavaRelImplementor implementor,
                                          RelNode relNode)
Stores the row type for a relational expression in the PreparingStmt, and generates a call which will retrieve it from the executable context at runtime. The literal string key used is based on the relational expression id.