net.sf.farrago.fennel.rel
Class FennelMultiUseBufferRel

java.lang.Object
  extended by org.eigenbase.rel.AbstractRelNode
      extended by org.eigenbase.rel.SingleRel
          extended by net.sf.farrago.fennel.rel.FennelSingleRel
              extended by net.sf.farrago.fennel.rel.FennelBufferRel
                  extended by net.sf.farrago.fennel.rel.FennelMultiUseBufferRel
All Implemented Interfaces:
Cloneable, FennelRel, RelNode

public class FennelMultiUseBufferRel
extends FennelBufferRel

FennelMultiUseBufferRel represents the Fennel implementation of a buffering stream that's used in multiple places in a stream graph.

Within the query tree, a single instance of this object can be referenced multiple times. Each reference corresponds to a node that needs to read the same buffered data. When converting this object to a streamDef, each reference to the object will result in the creation of a buffer reader stream. In addition, a single buffer writer stream is created that will be "shared" by the buffer readers. Hence, there will be one buffer writer stream and one or more buffer reader streams per FennelMultiUseBufferRel object.

The writer stream will have an incoming input stream corresponding to the input into the FennelMultiUseBufferRel. Dataflows will be created from the writer stream to its corresponding reader streams. That dataflow will be used by the writer stream to communicate to the readers the first pageId of the buffered data.

The writer and reader streams will also share a dynamic parameter that will be used to keep track of the number of active readers.

Note that unlike FennelBufferRel, FennelMultiUseBufferRel only supports "multipass = true" semantics. The parameter cannot be set to false, even if the buffered contents are only going to be used once.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/fennel/rel/FennelMultiUseBufferRel.java#1 $
Author:
Zelaine Fong

Field Summary
private  FennelRelParamId readerRefCountParamId
          Id of the dynamic parameter that the writer will use to keep track of the number of active readers.
 
Fields inherited from class net.sf.farrago.fennel.rel.FennelBufferRel
inMemory, multiPass
 
Fields inherited from class org.eigenbase.rel.AbstractRelNode
digest, id, rowType, traits
 
Fields inherited from interface net.sf.farrago.query.FennelRel
FENNEL_EXEC_CONVENTION
 
Fields inherited from interface org.eigenbase.rel.RelNode
emptyArray
 
Constructor Summary
FennelMultiUseBufferRel(RelOptCluster cluster, RelNode child, boolean inMemory)
          Creates a new FennelMultiUseBufferRel object.
 
Method Summary
 FennelMultiUseBufferRel clone()
          Clones this RelNode.
 void explain(RelOptPlanWriter pw)
           
 Object implementFennelChild(FennelRelImplementor implementor)
          Visits this relational expression as part of the implementation process.
 FemExecutionStreamDef toStreamDef(FennelRelImplementor implementor)
          Converts this relational expression to FemExecutionStreamDef form.
 
Methods inherited from class net.sf.farrago.fennel.rel.FennelBufferRel
computeSelfCost, getRows, isInMemory
 
Methods inherited from class net.sf.farrago.fennel.rel.FennelSingleRel
getCollations, getFarragoTypeFactory
 
Methods inherited from class org.eigenbase.rel.SingleRel
childrenAccept, deriveRowType, getChild, getInputs, replaceInput
 
Methods inherited from class org.eigenbase.rel.AbstractRelNode
cloneTraits, collectVariablesSet, collectVariablesUsed, computeDigest, 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

readerRefCountParamId

private FennelRelParamId readerRefCountParamId
Id of the dynamic parameter that the writer will use to keep track of the number of active readers.

Constructor Detail

FennelMultiUseBufferRel

public FennelMultiUseBufferRel(RelOptCluster cluster,
                               RelNode child,
                               boolean inMemory)
Creates a new FennelMultiUseBufferRel object.

Parameters:
cluster - RelOptCluster for this rel
child - child input
inMemory - true if the buffering needs to be done only in memory by a single instance of a stream
Method Detail

clone

public FennelMultiUseBufferRel 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
Overrides:
clone in class FennelBufferRel
Returns:
a clone of this RelNode

explain

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

toStreamDef

public FemExecutionStreamDef toStreamDef(FennelRelImplementor implementor)
Description copied from interface: FennelRel
Converts this relational expression to FemExecutionStreamDef form. In the process, the relational expression will almost certainly call FennelRelImplementor.visitFennelChild(net.sf.farrago.query.FennelRel, int) on each of its children.

Specified by:
toStreamDef in interface FennelRel
Overrides:
toStreamDef in class FennelBufferRel
Parameters:
implementor - for generating Java code
Returns:
generated FemExecutionStreamDef

implementFennelChild

public Object implementFennelChild(FennelRelImplementor implementor)
Description copied from interface: FennelRel
Visits this relational expression as part of the implementation process. Fennel relational expressions are implemented in a two-phase process: first call this method, then call FennelRel.toStreamDef(net.sf.farrago.query.FennelRelImplementor).

Specified by:
implementFennelChild in interface FennelRel
Overrides:
implementFennelChild in class FennelSingleRel