com.lucidera.lcs
Class LcsAppendStreamDef

java.lang.Object
  extended by com.lucidera.lcs.LcsAppendStreamDef
Direct Known Subclasses:
LcsReplaceStreamDef

public class LcsAppendStreamDef
extends Object

LcsAppendStreamDef creates an append execution stream def

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

Field Summary
private  boolean alterTable
           
protected  FennelRel appendRel
           
protected  List<FemLocalIndex> clusteredIndexes
           
protected  FemLocalIndex deletionIndex
           
private  Double estimatedNumInputRows
           
protected  boolean hasIndexes
           
protected  LcsIndexGuide indexGuide
           
private  FemExecutionStreamDef inputStream
           
protected  LcsTable lcsTable
           
protected  boolean replaceColumns
           
protected  FarragoRepos repos
           
protected  List<FemLocalIndex> unclusteredIndexes
           
 
Constructor Summary
LcsAppendStreamDef(FarragoRepos repos, LcsTable lcsTable, FemExecutionStreamDef inputStream, FennelRel appendRel, Double estimatedNumInputRows)
           
 
Method Summary
 FemBarrierStreamDef createBitmapAppendStreams(FennelRelImplementor implementor, FemBarrierStreamDef clusterAppendBarrier, int writeRowCountParamId)
          Creates the bottom half of an insert execution stream, i.e., the part the inserts into the unclustered indexes.
protected  void createClusterAppends(FennelRelImplementor implementor, List<FemLcsClusterAppendStreamDef> clusterAppendDefs)
           
 FemBarrierStreamDef createClusterAppendStreams(FennelRelImplementor implementor)
          Creates the top half of an insert execution stream, i.e., the part that appends the clustered indexes.
 FemLbmSplicerStreamDef createDeleteRidStream(FennelRelImplementor implementor, FemExecutionStreamDef inputStream, Double inputRowCount, int writeRowCountParamId, boolean removeDups)
          Creates a substream that takes an input stream of rids, sorts them, optionally removes duplicates, and then adds them into the deletion index associated with the table we're appending to
protected  FemSplitterStreamDef createSplitter()
           
private  FemLbmSplicerStreamDef createViolationStream(FennelRelImplementor implementor, ArrayList<LcsCompositeStreamDef> bitmapAppendDefs, int numUniqueIndexes)
          Creates the substream that inserts unique constraint violations into the table's deletion index.
private  LcsIndexGuide getIndexGuide(FemLocalIndex unclusteredIndex)
          Returns an index guide specific to an unclustered index
protected  void setupIndexes()
          Initializes the clustered and unclustered indexes relevant to the stream that will be created.
 boolean streamHasIndexes()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

repos

protected FarragoRepos repos

lcsTable

protected LcsTable lcsTable

inputStream

private FemExecutionStreamDef inputStream

appendRel

protected FennelRel appendRel

estimatedNumInputRows

private Double estimatedNumInputRows

indexGuide

protected LcsIndexGuide indexGuide

clusteredIndexes

protected List<FemLocalIndex> clusteredIndexes

unclusteredIndexes

protected List<FemLocalIndex> unclusteredIndexes

deletionIndex

protected FemLocalIndex deletionIndex

replaceColumns

protected boolean replaceColumns

hasIndexes

protected boolean hasIndexes

alterTable

private boolean alterTable
Constructor Detail

LcsAppendStreamDef

public LcsAppendStreamDef(FarragoRepos repos,
                          LcsTable lcsTable,
                          FemExecutionStreamDef inputStream,
                          FennelRel appendRel,
                          Double estimatedNumInputRows)
Method Detail

setupIndexes

protected void setupIndexes()
Initializes the clustered and unclustered indexes relevant to the stream that will be created.


createClusterAppendStreams

public FemBarrierStreamDef createClusterAppendStreams(FennelRelImplementor implementor)
Creates the top half of an insert execution stream, i.e., the part that appends the clustered indexes.

Parameters:
implementor - FennelRel implementor
Returns:
the barrier stream that anchors the top half of the insert execution stream

createSplitter

protected FemSplitterStreamDef createSplitter()

createClusterAppends

protected void createClusterAppends(FennelRelImplementor implementor,
                                    List<FemLcsClusterAppendStreamDef> clusterAppendDefs)

streamHasIndexes

public boolean streamHasIndexes()
Returns:
true if this append stream graph will have an index creation substream

createBitmapAppendStreams

public FemBarrierStreamDef createBitmapAppendStreams(FennelRelImplementor implementor,
                                                     FemBarrierStreamDef clusterAppendBarrier,
                                                     int writeRowCountParamId)
Creates the bottom half of an insert execution stream, i.e., the part the inserts into the unclustered indexes.

Parameters:
implementor - FennelRel implementor
clusterAppendBarrier - the barrier from the cluster appends that serves as the producer for the unclustered index append streams
writeRowCountParamId - parameter id the final barrier will use to retrieve the upstream deletion rowcount, in the case of a MERGE statement
Returns:
the final barrier that anchors the full insert stream or the clusterAppendBarrier if the table does not have any unclustered indexes

getIndexGuide

private LcsIndexGuide getIndexGuide(FemLocalIndex unclusteredIndex)
Returns an index guide specific to an unclustered index

Parameters:
unclusteredIndex - the unclustered index

createViolationStream

private FemLbmSplicerStreamDef createViolationStream(FennelRelImplementor implementor,
                                                     ArrayList<LcsCompositeStreamDef> bitmapAppendDefs,
                                                     int numUniqueIndexes)
Creates the substream that inserts unique constraint violations into the table's deletion index. Only bitmap appenders that are writing to a unique index will create violations. Those streams are then merged together into a single stream of violating rids.

Bitmap appenders that do not write to unique indexes don't need to be involved. In fact, the violation substream can even proceed before those appenders have finished because they don't access the deletion index and therefore there is no conflict.

Parameters:
implementor - FennelRel implementor
bitmapAppendDefs - bitmap append substreams that created the violations
numUniqueIndexes - number of unique indexes on the table; must be > 0
Returns:
the stream def corresponding to the splicer that inserts into the deletion index

createDeleteRidStream

public FemLbmSplicerStreamDef createDeleteRidStream(FennelRelImplementor implementor,
                                                    FemExecutionStreamDef inputStream,
                                                    Double inputRowCount,
                                                    int writeRowCountParamId,
                                                    boolean removeDups)
Creates a substream that takes an input stream of rids, sorts them, optionally removes duplicates, and then adds them into the deletion index associated with the table we're appending to

Parameters:
implementor - FennelRel implementor
inputStream - input stream containing rids
inputRowCount - estimated number of rids to be added to the deletion index
writeRowCountParamId - > 0 if the splicer that writes to the deletion index needs to return a count of the number of rids written
removeDups - if true, remove duplicate rids from the stream
Returns:
the stream def corresponding to the splicer that inserts into the deletion index