com.lucidera.lcs
Class LcsIndexSearchRel

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.FennelOptionalRel
                  extended by com.lucidera.lcs.LcsIndexSearchRel
All Implemented Interfaces:
Cloneable, FennelRel, RelNode

public class LcsIndexSearchRel
extends FennelOptionalRel

LcsIndexSearchRel is a relation for reading from an unclustered index. It has two major modes. In the "full scan" mode, it has no input and it scans the entire index. In the "key search" mode, it has one input and only searches for keys produced by its child.

Key search relations, have two formats for input. A single key set may be specified, in which case, exact matches for keys are returned. The double key format is a more versatile format in which both points and ranges can be represented. The input produces two sets of keys, one for a lower bound and one for an upper bound. The upper and lower bounds are described by directives as OPEN, or CLOSED, etc.

The output of an index scan may be expanded with fields from its input, making it more useful for implementing an index-based join.

Version:
$Id: //open/dev/farrago/src/com/lucidera/lcs/LcsIndexSearchRel.java#24 $
Author:
Rushan Chen

Field Summary
(package private)  boolean fullScan
          Whether to perform a full scan
(package private)  FemLocalIndex index
          Index to use for access.
 Double indexSelectivity
           
(package private)  Integer[] inputDirectiveProj
           
(package private)  Integer[] inputJoinProj
           
(package private)  Integer[] inputKeyProj
           
(package private)  boolean isOuter
           
(package private)  boolean isUniqueKey
           
(package private)  boolean isVisibleInExplain
           
(package private)  LcsTable lcsTable
          The table containing the index to be scanned
(package private)  Integer[] projectedColumns
          Array of 0-based flattened column ordinals to project; if null, project bitmap columns.
(package private)  FennelRelParamId rowLimitParamId
           
(package private)  FennelRelParamId startRidParamId
           
 
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
LcsIndexSearchRel(RelOptCluster cluster, RelNode child, LcsTable lcsTable, FemLocalIndex index, boolean fullScan, Integer[] projectedColumns, boolean isUniqueKey, boolean isOuter, boolean isVisibleInExplain, Integer[] inputKeyProj, Integer[] inputJoinProj, Integer[] inputDirectiveProj, FennelRelParamId startRidParamId, FennelRelParamId rowLimitParamId, Double indexSelectivity)
          Creates a new LcsIndexSearchRel object.
 
Method Summary
 LcsIndexSearchRel clone()
          Clones this RelNode.
 LcsIndexSearchRel cloneWithNewParams(FennelRelParamId startRidParamId, FennelRelParamId rowLimitParamId)
          Create a new index search rel based on the existing one but with new dynamic parameters.
(package private)  RelOptCost computeCost(RelOptPlanner planner, double dRows)
           
 RelOptCost computeSelfCost(RelOptPlanner planner)
          Returns the cost of this plan (not including children).
protected  RelDataType deriveRowType()
           
 void explain(RelOptPlanWriter pw)
           
 Double getIndexSelectivity()
           
 Integer[] getInputDirectiveProj()
           
 Integer[] getInputJoinProj()
           
 int getInputKeyCount()
           
 Integer[] getInputKeyProj()
           
 LcsTable getLcsTable()
           
 double getRows()
          Returns an estimate of the number of rows this relational expression will return.
 RelOptTable getTable()
          If this relational expression represents an access to a table, returns that table, otherwise returns null.
 boolean isInputSingleKeyset()
           
 boolean isOuter()
           
 boolean isUniqueKey()
           
 boolean isVisibleInExplain()
           
 FemExecutionStreamDef toStreamDef(FennelRelImplementor implementor)
          Converts this relational expression to FemExecutionStreamDef form.
 
Methods inherited from class net.sf.farrago.fennel.rel.FennelOptionalRel
childrenAccept, getInputs, implementFennelChild
 
Methods inherited from class net.sf.farrago.fennel.rel.FennelSingleRel
getCollations, getFarragoTypeFactory
 
Methods inherited from class org.eigenbase.rel.SingleRel
getChild, 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, 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
collectVariablesSet, collectVariablesUsed, getChildExps, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getOrCreateCorrelVariable, getQuery, getRelTypeName, getRowType, getTraits, getVariablesStopped, isAccessTo, isDistinct, isValid, onRegister, recomputeDigest, registerCorrelVariable, replaceInput, setCorrelVariable
 

Field Detail

index

final FemLocalIndex index
Index to use for access.


lcsTable

final LcsTable lcsTable
The table containing the index to be scanned


fullScan

final boolean fullScan
Whether to perform a full scan


projectedColumns

final Integer[] projectedColumns
Array of 0-based flattened column ordinals to project; if null, project bitmap columns. These ordinals are relative to the index.


isUniqueKey

final boolean isUniqueKey

isOuter

final boolean isOuter

isVisibleInExplain

final boolean isVisibleInExplain

indexSelectivity

public final Double indexSelectivity

inputKeyProj

final Integer[] inputKeyProj

inputJoinProj

final Integer[] inputJoinProj

inputDirectiveProj

final Integer[] inputDirectiveProj

startRidParamId

FennelRelParamId startRidParamId

rowLimitParamId

FennelRelParamId rowLimitParamId
Constructor Detail

LcsIndexSearchRel

public LcsIndexSearchRel(RelOptCluster cluster,
                         RelNode child,
                         LcsTable lcsTable,
                         FemLocalIndex index,
                         boolean fullScan,
                         Integer[] projectedColumns,
                         boolean isUniqueKey,
                         boolean isOuter,
                         boolean isVisibleInExplain,
                         Integer[] inputKeyProj,
                         Integer[] inputJoinProj,
                         Integer[] inputDirectiveProj,
                         FennelRelParamId startRidParamId,
                         FennelRelParamId rowLimitParamId,
                         Double indexSelectivity)
Creates a new LcsIndexSearchRel object. In general, parameters are nullable if they do not apply to the search being specified.

Parameters:
cluster - the environment for the scan
child - input which produces keys
lcsTable - the table containing the index
fullScan - whether to perform a full scan
projectedColumns - the columns to be projected from an index scan. If this parameter is null for a "key search", then the three bitmap fields are projected. This parameter cannot be null for a "full scan".
isUniqueKey - for a search, whether keys are known to be unique
isOuter - for a search with join, whether nulls should be made up for unmatched inputs
isVisibleInExplain - whether the relNode should appear in the explain output
inputKeyProj - for a double key search, the projection of input fields to be used as search keys
inputJoinProj - for an index join, a projection of input fields to be added to the output
inputDirectiveProj - for a double key search, the projection of input fields describing search endpoints, such as OPEN or CLOSED
startRidParamId - parameter ID for searching using start Rid as part of the key
rowLimitParamId - parameter ID to limit the number of rows fetched in one execute
indexSelectivity - the selectivity of the index search
Method Detail

getRows

public double getRows()
Description copied from interface: RelNode
Returns an estimate of the number of rows this relational expression will return.

NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getRowCount(org.eigenbase.rel.RelNode), which gives plugins a chance to override the rel's default ideas about row count.

Specified by:
getRows in interface RelNode
Overrides:
getRows in class FennelOptionalRel

clone

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

cloneWithNewParams

public LcsIndexSearchRel cloneWithNewParams(FennelRelParamId startRidParamId,
                                            FennelRelParamId rowLimitParamId)
Create a new index search rel based on the existing one but with new dynamic parameters.

Parameters:
startRidParamId - parameter ID for searching using start Rid as part of the key
rowLimitParamId - parameter ID to limit the number of rows fetched in one execute
Returns:
the newly created index search rel.

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

computeCost

RelOptCost computeCost(RelOptPlanner planner,
                       double dRows)

deriveRowType

protected RelDataType deriveRowType()
Overrides:
deriveRowType in class SingleRel

explain

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

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

getTable

public RelOptTable getTable()
Description copied from interface: RelNode
If this relational expression represents an access to a table, returns that table, otherwise returns null.

Specified by:
getTable in interface RelNode
Overrides:
getTable in class AbstractRelNode

isUniqueKey

public boolean isUniqueKey()

isOuter

public boolean isOuter()

isVisibleInExplain

public boolean isVisibleInExplain()

getInputKeyProj

public Integer[] getInputKeyProj()

getInputJoinProj

public Integer[] getInputJoinProj()

getInputDirectiveProj

public Integer[] getInputDirectiveProj()

isInputSingleKeyset

public boolean isInputSingleKeyset()

getInputKeyCount

public int getInputKeyCount()

getLcsTable

public LcsTable getLcsTable()

getIndexSelectivity

public Double getIndexSelectivity()