net.sf.farrago.query
Interface FennelRelImplementor

All Superinterfaces:
RelImplementor
All Known Implementing Classes:
FarragoRelImplementor

public interface FennelRelImplementor
extends RelImplementor

Callback used to hold state while converting a tree of FennelRel objects into a plan consisting of FemExecutionStreamDef objects.

Since:
May 24, 2004
Version:
$Id: //open/dev/farrago/src/net/sf/farrago/query/FennelRelImplementor.java#27 $
Author:
jhyde
See Also:
FarragoRelImplementor

Method Summary
 void addDataFlowFromProducerToConsumer(FemExecutionStreamDef producer, FemExecutionStreamDef consumer)
          Adds a new explicit dataflow edge between two existing stream definitions.
 void addDataFlowFromProducerToConsumer(FemExecutionStreamDef producer, FemExecutionStreamDef consumer, boolean implicit)
          Adds a new dataflow edge between two existing stream definitions.
 FennelRelParamId allocateRelParamId()
          Reserves a Fennel dynamic parameter.
 List<FemExecutionStreamDef> getRegisteredStreamDefs(RelNode rel)
          Returns the list of stream definitions that have been registered for a RelNode.
 FarragoRepos getRepos()
          Returns the repository.
 boolean isFirstTranslationInstance(RelNode rel)
          Determines if this is the instance of a RelNode such that the instance corresponds to the one at the time this method was first called.
 void registerRelStreamDef(FemExecutionStreamDef streamDef, RelNode rel, RelDataType rowType)
          Registers a new stream definition.
 void setErrorRecordType(FennelRel rel, FemExecutionStreamDef streamDef, RelDataType errorType)
          Sets the format of error records for an execution stream.
 FennelDynamicParamId translateParamId(FennelRelParamId relParamId)
          Translates a FennelRelParamId into a FennelDynamicParamId based on the current scope.
 FennelDynamicParamId translateParamId(FennelRelParamId relParamId, FemExecutionStreamDef streamDef, FennelDynamicParamId.StreamType streamType)
          Translates a FennelRelParamId into a FennelDynamicParamId based on the current scope.
 FemExecutionStreamDef visitFennelChild(FennelRel rel, int ordinal)
          Converts a relational expression into a plan by calling its FennelRel.toStreamDef(net.sf.farrago.query.FennelRelImplementor) method.
 
Methods inherited from interface org.eigenbase.relopt.RelImplementor
visitChild, visitChildInternal, visitChildInternal
 

Method Detail

visitFennelChild

FemExecutionStreamDef visitFennelChild(FennelRel rel,
                                       int ordinal)
Converts a relational expression into a plan by calling its FennelRel.toStreamDef(net.sf.farrago.query.FennelRelImplementor) method.

Parameters:
rel - the relational expression
ordinal - input position of the relational expression for its parent

registerRelStreamDef

void registerRelStreamDef(FemExecutionStreamDef streamDef,
                          RelNode rel,
                          RelDataType rowType)
Registers a new stream definition. Normally, it is not necessary to call this method explicitly; it happens automatically as part of visitFennelChild(net.sf.farrago.query.FennelRel, int). However, this is not true for non-tree stream graphs. For streams with multiple parents, this method must be called for streams not returned from visitFennelChild(net.sf.farrago.query.FennelRel, int).

Parameters:
streamDef - new stream definition
rel - RelNode which stream implements
rowType - row type for stream, or null to use rel's row type

addDataFlowFromProducerToConsumer

void addDataFlowFromProducerToConsumer(FemExecutionStreamDef producer,
                                       FemExecutionStreamDef consumer)
Adds a new explicit dataflow edge between two existing stream definitions. See the three-arg version for details.

NOTE jvs 14-Nov-2005: I gave this method a long name so that it wouldn't be necessary to guess the direction when reading code that uses it.

Parameters:
producer - the upstream node of the dataflow
consumer - the downstream node of the dataflow

addDataFlowFromProducerToConsumer

void addDataFlowFromProducerToConsumer(FemExecutionStreamDef producer,
                                       FemExecutionStreamDef consumer,
                                       boolean implicit)
Adds a new dataflow edge between two existing stream definitions. In cases where a stream has multiple inputs or outputs, order may be significant, in which case it is the caller's responsibility to add the flows in the desired order.

Parameters:
producer - the upstream node of the dataflow
consumer - the downstream node of the dataflow
implicit - false if this is an explicit dataflow edge between two ExecStreams; true if it represents implicit dataflow via a UDX reading from a cursor

getRepos

FarragoRepos getRepos()
Returns the repository.


allocateRelParamId

FennelRelParamId allocateRelParamId()
Reserves a Fennel dynamic parameter. The reserving rel can use translateParamId(FennelRelParamId) later as part of its toStreamDef implementation to convert this into a final FennelDynamicParamId, which can then be referenced from stream definitions.

Returns:
parameter reservation ID

translateParamId

FennelDynamicParamId translateParamId(FennelRelParamId relParamId)
Translates a FennelRelParamId into a FennelDynamicParamId based on the current scope.

Parameters:
relParamId - reserved ID to be translated
Returns:
physical ID to use in final plan

translateParamId

FennelDynamicParamId translateParamId(FennelRelParamId relParamId,
                                      FemExecutionStreamDef streamDef,
                                      FennelDynamicParamId.StreamType streamType)
Translates a FennelRelParamId into a FennelDynamicParamId based on the current scope.

Parameters:
relParamId - reserved ID to be translated
streamDef - the stream that either produces or consumes the dynamic parameter; or null if we don't need to keep track of that information
streamType - whether the streamDef produces or consumes the dynamic parameter
Returns:
physical ID to use in final plan

setErrorRecordType

void setErrorRecordType(FennelRel rel,
                        FemExecutionStreamDef streamDef,
                        RelDataType errorType)
Sets the format of error records for an execution stream.

Parameters:
rel - relation to which the execution stream belongs
streamDef - stream definition of stream that may produce errors
errorType - row type of error records produced by the stream

getRegisteredStreamDefs

List<FemExecutionStreamDef> getRegisteredStreamDefs(RelNode rel)
Returns the list of stream definitions that have been registered for a RelNode.

Parameters:
rel - the RelNode
Returns:
the list of registered stream definitions; null if no stream definitions have been registered yet to the RelNode

isFirstTranslationInstance

boolean isFirstTranslationInstance(RelNode rel)
Determines if this is the instance of a RelNode such that the instance corresponds to the one at the time this method was first called.

Parameters:
rel - the RelNode
Returns:
true if the RelNode instance is the one encountered the first time this method was called