com.lucidera.lcs
Class LcsTableMergeRel

java.lang.Object
  extended by org.eigenbase.rel.AbstractRelNode
      extended by org.eigenbase.rel.SingleRel
          extended by org.eigenbase.rel.TableModificationRelBase
              extended by net.sf.farrago.namespace.impl.MedAbstractFennelTableModRel
                  extended by com.lucidera.lcs.LcsTableMergeRel
All Implemented Interfaces:
Cloneable, FennelRel, RelNode

public class LcsTableMergeRel
extends MedAbstractFennelTableModRel

LcsTableMergeRel is the relational expression corresponding to merges on a column-store table.

Version:
$Id: //open/dev/farrago/src/com/lucidera/lcs/LcsTableMergeRel.java#22 $
Author:
Zelaine Fong

Nested Class Summary
(package private) static class LcsTableMergeRel.ReshapeProjectionType
           
 
Nested classes/interfaces inherited from class org.eigenbase.rel.TableModificationRelBase
TableModificationRelBase.Operation
 
Field Summary
private  Double estimatedNumRows
           
private  boolean insertOnly
           
(package private)  LcsTable lcsTable
           
private  List<FemLocalIndex> updateClusters
           
private  boolean updateOnly
           
 
Fields inherited from class org.eigenbase.rel.TableModificationRelBase
connection, table
 
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
LcsTableMergeRel(RelOptCluster cluster, LcsTable lcsTable, RelOptConnection connection, RelNode child, TableModificationRelBase.Operation operation, List<String> updateColumnList, boolean updateOnly, List<FemLocalIndex> updateClusters)
          Constructor.
 
Method Summary
 LcsTableMergeRel clone()
          Clones this RelNode.
 RelOptCost computeSelfCost(RelOptPlanner planner)
          Returns the cost of this plan (not including children).
private  FemLbmSplicerStreamDef createDeleteStream(FarragoRepos repos, FennelRelImplementor implementor, LcsIndexGuide indexGuide, LcsAppendStreamDef appendStreamDef, FennelRel childFennelRel, FemSplitterStreamDef splitter, int writeRowCountParamId)
          Creates the substream for deleting rows for the MERGE statement
private  FemReshapeStreamDef createMergeReshape(boolean compareRid, CompOperator compOp, LcsTableMergeRel.ReshapeProjectionType projType, FennelRel input)
          Creates a Reshape execution stream used within the MERGE execution stream that optionally compares the rid column in its input to either null or non-null.
private  RelDataType createRidRowType(boolean nullableRid)
          Creates a rowtype corresponding to a single rid column
private  FemSortingStreamDef createRidSort(FennelRel sourceInput)
          Creates a sort stream that sorts on the first column in the input, which corresponds to a rid column.
private  FemMergeStreamDef createRidSplitterStream(FennelRelImplementor implementor, LcsIndexGuide indexGuide, FennelRel childFennelRel, FemExecutionStreamDef sourceStream)
          Creates a substream that takes a input containing rid values.
 void explain(RelOptPlanWriter pw)
           
 RelDataType getExpectedInputRowType(int ordinalInParent)
          Returns the type of the rows expected for an input.
 LcsTable getLcsTable()
           
 List<FemLocalIndex> getUpdateClusters()
           
 boolean getUpdateOnly()
           
 FemExecutionStreamDef toStreamDef(FennelRelImplementor implementor)
          Converts this relational expression to FemExecutionStreamDef form.
 
Methods inherited from class net.sf.farrago.namespace.impl.MedAbstractFennelTableModRel
getCollations, getConnection, getFarragoTypeFactory, implementFennelChild, inputNeedBuffer, inputNeedBuffer, newInputBuffer
 
Methods inherited from class org.eigenbase.rel.TableModificationRelBase
deriveRowType, getOperation, getTable, getUpdateColumnList, isDelete, isFlattened, isInsert, isMerge, isUpdate
 
Methods inherited from class org.eigenbase.rel.SingleRel
childrenAccept, getChild, getInputs, getRows, replaceInput
 
Methods inherited from class org.eigenbase.rel.AbstractRelNode
cloneTraits, collectVariablesSet, collectVariablesUsed, computeDigest, getChildExps, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getId, getInput, getOrCreateCorrelVariable, getQuery, getRelTypeName, getRowType, 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, getId, getInput, getInputs, getOrCreateCorrelVariable, getQuery, getRelTypeName, getRows, getRowType, getTable, getTraits, getVariablesStopped, isAccessTo, isDistinct, isValid, onRegister, recomputeDigest, registerCorrelVariable, replaceInput, setCorrelVariable
 

Field Detail

updateOnly

private boolean updateOnly

updateClusters

private List<FemLocalIndex> updateClusters

insertOnly

private boolean insertOnly

estimatedNumRows

private Double estimatedNumRows

lcsTable

final LcsTable lcsTable
Constructor Detail

LcsTableMergeRel

public LcsTableMergeRel(RelOptCluster cluster,
                        LcsTable lcsTable,
                        RelOptConnection connection,
                        RelNode child,
                        TableModificationRelBase.Operation operation,
                        List<String> updateColumnList,
                        boolean updateOnly,
                        List<FemLocalIndex> updateClusters)
Constructor.

Parameters:
cluster - RelOptCluster for this rel
lcsTable - target table of merge
connection - connection
child - input to the merge
operation - DML operation type
updateColumnList - update column list in the update substatement
updateOnly - merge only consists of an update substatement
updateClusters - if the merge executes by replacing the columns being updated as opposed to updating entire rows, then this is set to the list of clusters that will be replaced; otherwise, null
Method Detail

getLcsTable

public LcsTable getLcsTable()

getUpdateOnly

public boolean getUpdateOnly()

getUpdateClusters

public List<FemLocalIndex> getUpdateClusters()

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 TableModificationRelBase

clone

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

explain

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

getExpectedInputRowType

public RelDataType getExpectedInputRowType(int ordinalInParent)
Description copied from interface: RelNode
Returns the type of the rows expected for an input. Defaults to RelNode.getRowType().

Specified by:
getExpectedInputRowType in interface RelNode
Overrides:
getExpectedInputRowType in class TableModificationRelBase
Parameters:
ordinalInParent - input's 0-based ordinal with respect to this parent rel
Returns:
expected row type

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.

Parameters:
implementor - for generating Java code
Returns:
generated FemExecutionStreamDef

createRidSplitterStream

private FemMergeStreamDef createRidSplitterStream(FennelRelImplementor implementor,
                                                  LcsIndexGuide indexGuide,
                                                  FennelRel childFennelRel,
                                                  FemExecutionStreamDef sourceStream)
Creates a substream that takes a input containing rid values. Rearranges the input such that non-null rids are written to the output of the substream before the null rids.

Parameters:
implementor - FennelRel implementor
indexGuide - index guide
childFennelRel - FennelRel corresponding to the source input for the MERGE
sourceStream - the stream def corresponding to the input into the substream to be created
Returns:
a MergeStreamDef that outputs the rows with rows containing non-null rids appearing before rows with null rids

createRidSort

private FemSortingStreamDef createRidSort(FennelRel sourceInput)
Creates a sort stream that sorts on the first column in the input, which corresponds to a rid column.

Returns:
the created sort stream

createMergeReshape

private FemReshapeStreamDef createMergeReshape(boolean compareRid,
                                               CompOperator compOp,
                                               LcsTableMergeRel.ReshapeProjectionType projType,
                                               FennelRel input)
Creates a Reshape execution stream used within the MERGE execution stream that optionally compares the rid column in its input to either null or non-null. Also projects the input based on a specified parameter.

Parameters:
compareRid - true if the stream will be doing rid comparison
compOp - the operator to use in the rid comparison
projType - the type of projection to be done (either project only the rid column, the non-null rid columns, or all columns)
input - FennelRel corresponding to the input that will be reshaped
Returns:
created Reshape execution stream

createRidRowType

private RelDataType createRidRowType(boolean nullableRid)
Creates a rowtype corresponding to a single rid column

Parameters:
nullableRid - if true, create the rid type column as nullable
Returns:
created rowtype

createDeleteStream

private FemLbmSplicerStreamDef createDeleteStream(FarragoRepos repos,
                                                  FennelRelImplementor implementor,
                                                  LcsIndexGuide indexGuide,
                                                  LcsAppendStreamDef appendStreamDef,
                                                  FennelRel childFennelRel,
                                                  FemSplitterStreamDef splitter,
                                                  int writeRowCountParamId)
Creates the substream for deleting rows for the MERGE statement

Parameters:
repos - repository
implementor - FennelRel implementor
indexGuide - index guide
appendStreamDef - the append stream that this delete stream is associated with
childFennelRel - FennelRel corresponding to the source input for the MERGE
splitter - the splitter producer that passes rows to the delete substream
writeRowCountParamId - parameter id that the splicer stream will use to write out its rowcount to be read by a downstream barrier
Returns:
stream def for the deletion substream