com.lucidera.lcs
Class LcsIndexAccessRule

java.lang.Object
  extended by org.eigenbase.relopt.RelOptRule
      extended by com.lucidera.lcs.LcsIndexAccessRule

public class LcsIndexAccessRule
extends RelOptRule

LcsIndexAccessRule is a rule for converting FilterRel+LcsRowScanRel into LcsIndexAccessRel (when the filter has the appropriate form).

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

Field Summary
 
Fields inherited from class org.eigenbase.relopt.RelOptRule
ANY, description, operands
 
Constructor Summary
LcsIndexAccessRule(RelOptRuleOperand operand, String id)
          Creates an LcsIndexAccessRule.
 
Method Summary
private  RelNode addNewIndexAccessRel(RelNode oldIndexAccessRel, RelOptRuleCall call, int rowScanRelPosInCall, LcsIndexOptimizer.CandidateIndex candidate, Double rowScanInputSelectivity)
           
private  void buildColumnFilters(Integer[] residualColumns, RelTraitSet callTraits, RelNode[] valueRels, int residualColumnCount, List<SargBinding> residualSargBindingList, LcsRowScanRel origRowScan)
           
private  void considerIndex(RelOptRuleCall call, int rowScanRelPosInCall, SargRexAnalyzer rexAnalyzer, List<SargBinding> sargBindingList)
           
private static RelDataType getIndexInputType(FennelRel rel, FemLocalIndex index, int matchedPos)
          Create a type descriptor for the rows representing index search keys along with their directives, given an index and the number of matching keys from the index.
private static List<SargIntervalSequence> getIndexSargSeq(FemLocalIndex index, int matchedPos, Map<CwmColumn,SargIntervalSequence> col2SeqMap)
           
 CallingConvention getOutConvention()
          Returns the calling convention of the result of firing this rule, null if not known.
private static List<SargBinding> getResidualSargBinding(LcsRowScanRel origRowScan, List<SargBinding> sargBindingList, Map<FemLocalIndex,Integer> index2PosMap, List<SargBinding> nonResidualList)
           
private static List<List<LcsIndexOptimizer.SargColumnFilter>> getSargColFilterLists(LcsRowScanRel origRowScan, List<SargBinding> sargBindingList, Map<CwmColumn,SargIntervalSequence> col2SeqMap)
           
private static RelDataType getSearchKeyRowType(FennelRel rel, FemAbstractAttribute[] searchColumns)
          Create a type descriptor for the rows representing search keys along with their directives, given an array of the attributes representing the search columns.
 void onMatch(RelOptRuleCall call)
          Receives notification about a rule match.
private  void transformCall(RelOptRuleCall call, RelNode rel, RexNode extraFilter)
           
 
Methods inherited from class org.eigenbase.relopt.RelOptRule
convert, equals, equals, getOperand, getOperands, getOutTrait, hashCode, matches, mergeTraitsAndConvert, mergeTraitsAndConvert, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LcsIndexAccessRule

public LcsIndexAccessRule(RelOptRuleOperand operand,
                          String id)
Creates an LcsIndexAccessRule.

Parameters:
operand - Root operand, must not be null
id - Description of rule
Method Detail

getOutConvention

public CallingConvention getOutConvention()
Description copied from class: RelOptRule
Returns the calling convention of the result of firing this rule, null if not known.

Overrides:
getOutConvention in class RelOptRule

onMatch

public void onMatch(RelOptRuleCall call)
Description copied from class: RelOptRule
Receives notification about a rule match. At the time that this method is called, call.rels holds the set of relational expressions which match the operands to the rule; call.rels[0] is the root expression.

Typically a rule would check that the nodes are valid matches, creates a new expression, then calls back RelOptRuleCall.transformTo(org.eigenbase.rel.RelNode) to register the expression.

Specified by:
onMatch in class RelOptRule
Parameters:
call - Rule call
See Also:
RelOptRule.matches(RelOptRuleCall)

considerIndex

private void considerIndex(RelOptRuleCall call,
                           int rowScanRelPosInCall,
                           SargRexAnalyzer rexAnalyzer,
                           List<SargBinding> sargBindingList)

buildColumnFilters

private void buildColumnFilters(Integer[] residualColumns,
                                RelTraitSet callTraits,
                                RelNode[] valueRels,
                                int residualColumnCount,
                                List<SargBinding> residualSargBindingList,
                                LcsRowScanRel origRowScan)

transformCall

private void transformCall(RelOptRuleCall call,
                           RelNode rel,
                           RexNode extraFilter)

getIndexSargSeq

private static List<SargIntervalSequence> getIndexSargSeq(FemLocalIndex index,
                                                          int matchedPos,
                                                          Map<CwmColumn,SargIntervalSequence> col2SeqMap)

getSargColFilterLists

private static List<List<LcsIndexOptimizer.SargColumnFilter>> getSargColFilterLists(LcsRowScanRel origRowScan,
                                                                                    List<SargBinding> sargBindingList,
                                                                                    Map<CwmColumn,SargIntervalSequence> col2SeqMap)

getResidualSargBinding

private static List<SargBinding> getResidualSargBinding(LcsRowScanRel origRowScan,
                                                        List<SargBinding> sargBindingList,
                                                        Map<FemLocalIndex,Integer> index2PosMap,
                                                        List<SargBinding> nonResidualList)

addNewIndexAccessRel

private RelNode addNewIndexAccessRel(RelNode oldIndexAccessRel,
                                     RelOptRuleCall call,
                                     int rowScanRelPosInCall,
                                     LcsIndexOptimizer.CandidateIndex candidate,
                                     Double rowScanInputSelectivity)

getSearchKeyRowType

private static RelDataType getSearchKeyRowType(FennelRel rel,
                                               FemAbstractAttribute[] searchColumns)
Create a type descriptor for the rows representing search keys along with their directives, given an array of the attributes representing the search columns. Note that we force the key type to nullable because we use null for the representation of infinity (rather than domain-specific values).

Parameters:
rel - the table scan node that is being optimized
searchColumns - array of column attributes representing the search keys

getIndexInputType

private static RelDataType getIndexInputType(FennelRel rel,
                                             FemLocalIndex index,
                                             int matchedPos)
Create a type descriptor for the rows representing index search keys along with their directives, given an index and the number of matching keys from the index. Note that we force the key type to nullable because we use null for the representation of infinity (rather than domain-specific values).

Parameters:
rel - the table scan node that is being optimized
index - the index descriptor
matchedPos - the length of matched prefix in the index key
Returns:
type descriptor for the index search key