com.lucidera.opt
Class LoptMetadataProvider

java.lang.Object
  extended by org.eigenbase.rel.metadata.ReflectiveRelMetadataProvider
      extended by com.lucidera.opt.LoptMetadataProvider
All Implemented Interfaces:
RelMetadataProvider, ReflectiveVisitor

public class LoptMetadataProvider
extends ReflectiveRelMetadataProvider

LoptMetadataProvider supplies relational expression metadata specific to LucidDB.

NOTE jvs 10-Apr-2006: For now, I just created one class; if it gets too big we can split it up like the ones in org.eigenbase.rel.metadata, e.g. add LoptRelMdCost.

Version:
$Id: //open/dev/farrago/src/com/lucidera/opt/LoptMetadataProvider.java#31 $
Author:
John V. Sichi

Nested Class Summary
private  class LoptMetadataProvider.SimpleColumnOrigins
          An extension of RelMdColumnOrigins that invokes LoptMetadataQuery.getSimpleColumnOrigins(org.eigenbase.rel.RelNode, int) instead of RelMetadataQuery.getColumnOrigins(org.eigenbase.rel.RelNode, int).
 
Field Summary
private  LcsColumnMetadata columnMd
           
private  LoptMetadataProvider.SimpleColumnOrigins columnOrigins
           
private  FarragoRepos repos
           
 
Constructor Summary
LoptMetadataProvider(FarragoRepos repos)
           
 
Method Summary
 Boolean areColumnsUnique(LcsRowScanRel rel, BitSet columns, boolean ignoreNulls)
           
 Boolean areColumnsUnique(ProjectRel rel, BitSet columns, boolean ignoreNulls)
           
private  Double computeDefaultCostWithFilters(RelNode rel, RexNode filter, boolean includeRel)
           
private  Double computeRowCountGivenConds(RelNode leftChild, RelNode rightChild, JoinRelType joinType, RexNode predicate)
          Computes the rowcount from a join, given a join condition and the join inputs
private  Boolean dimOnLeft(RelNode left, RelNode right, BitSet leftJoinCols, BitSet rightJoinCols)
          Returns true if the dimension table is on the LHS of a join
private  double estimateRowScanSelectivity(LcsRowScanRel rel, RexNode predicate, boolean excludeCalc)
           
 Double getCostWithFilters(AggregateRel rel, RexNode filter)
           
 Double getCostWithFilters(FilterRel rel, RexNode filter)
           
 Double getCostWithFilters(JoinRel rel, RexNode filter)
           
 Double getCostWithFilters(LcsRowScanRel rel, RexNode filter)
           
 Double getCostWithFilters(ProjectRel rel, RexNode filter)
           
 Double getCostWithFilters(RelNode rel, RexNode filter)
           
 Double getCostWithFilters(SemiJoinRel rel, RexNode filter)
           
 Double getCostWithFilters(UnionRel rel, RexNode filter)
           
 RelOptCost getCumulativeCost(RelNode rel)
           
 Double getDistinctRowCount(LcsRowScanRel rel, BitSet groupKey, RexNode predicate)
           
 Double getDistinctRowCount(LhxJoinRel rel, BitSet groupKey, RexNode predicate)
           
 Double getPopulationSize(LcsRowScanRel rel, BitSet groupKey)
           
 Double getPopulationSize(LhxJoinRel rel, BitSet groupKey)
           
 Double getRowCount(JoinRel rel)
           
 Double getRowCount(LcsIndexSearchRel rel)
           
 Double getRowCount(LcsRowScanRel rel)
           
 Double getRowCount(LhxJoinRel rel)
           
 Double getSelectivity(JoinRel rel, RexNode predicate)
           
 Double getSelectivity(LcsRowScanRel rel, RexNode predicate)
           
static RelColumnOrigin getSimpleColumnOrigin(RelNode rel, int colOffset)
          Determines the origin of a column, provided the column maps to a single column that isn't derived.
 Set<RelColumnOrigin> getSimpleColumnOrigins(FilterRelBase rel, int iOutputColumn)
           
 Set<RelColumnOrigin> getSimpleColumnOrigins(LcsRowScanRel rel, int iOutputColumn)
           
 Set<RelColumnOrigin> getSimpleColumnOrigins(ProjectRelBase rel, int iOutputColumn)
           
 Set<RelColumnOrigin> getSimpleColumnOrigins(RelNode rel, int iOutputColumn)
           
static RelOptTable getSimpleTableOrigin(RelNode rel)
          Determines the origin of a RelNode, provided it maps to a single table, optionally with filtering and projection.
 Set<BitSet> getUniqueKeys(LcsRowScanRel rel, boolean ignoreNulls)
           
private  boolean hashJoinable(JoinRel joinRel)
          Determines whether the join condition in a join can be fully processed using a hash join.
 Boolean isVisibleInExplain(FennelValuesRel rel, SqlExplainLevel level)
           
 Boolean isVisibleInExplain(LcsIndexMinusRel rel, SqlExplainLevel level)
           
 Boolean isVisibleInExplain(LcsIndexSearchRel rel, SqlExplainLevel level)
           
 
Methods inherited from class org.eigenbase.rel.metadata.ReflectiveRelMetadataProvider
getRelMetadata, mapParameterTypes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

repos

private FarragoRepos repos

columnMd

private final LcsColumnMetadata columnMd

columnOrigins

private final LoptMetadataProvider.SimpleColumnOrigins columnOrigins
Constructor Detail

LoptMetadataProvider

public LoptMetadataProvider(FarragoRepos repos)
Method Detail

getCumulativeCost

public RelOptCost getCumulativeCost(RelNode rel)

getCostWithFilters

public Double getCostWithFilters(RelNode rel,
                                 RexNode filter)

computeDefaultCostWithFilters

private Double computeDefaultCostWithFilters(RelNode rel,
                                             RexNode filter,
                                             boolean includeRel)

getCostWithFilters

public Double getCostWithFilters(LcsRowScanRel rel,
                                 RexNode filter)

getCostWithFilters

public Double getCostWithFilters(UnionRel rel,
                                 RexNode filter)

getCostWithFilters

public Double getCostWithFilters(FilterRel rel,
                                 RexNode filter)

getCostWithFilters

public Double getCostWithFilters(SemiJoinRel rel,
                                 RexNode filter)

getCostWithFilters

public Double getCostWithFilters(ProjectRel rel,
                                 RexNode filter)

getCostWithFilters

public Double getCostWithFilters(JoinRel rel,
                                 RexNode filter)

hashJoinable

private boolean hashJoinable(JoinRel joinRel)
Determines whether the join condition in a join can be fully processed using a hash join.

Parameters:
joinRel - the join
Returns:
true if the join can be fully processed using a hash join

getCostWithFilters

public Double getCostWithFilters(AggregateRel rel,
                                 RexNode filter)

getDistinctRowCount

public Double getDistinctRowCount(LhxJoinRel rel,
                                  BitSet groupKey,
                                  RexNode predicate)

getDistinctRowCount

public Double getDistinctRowCount(LcsRowScanRel rel,
                                  BitSet groupKey,
                                  RexNode predicate)

getSelectivity

public Double getSelectivity(JoinRel rel,
                             RexNode predicate)

getSelectivity

public Double getSelectivity(LcsRowScanRel rel,
                             RexNode predicate)

estimateRowScanSelectivity

private double estimateRowScanSelectivity(LcsRowScanRel rel,
                                          RexNode predicate,
                                          boolean excludeCalc)

getRowCount

public Double getRowCount(LcsRowScanRel rel)

getRowCount

public Double getRowCount(LcsIndexSearchRel rel)

getRowCount

public Double getRowCount(JoinRel rel)

getRowCount

public Double getRowCount(LhxJoinRel rel)

computeRowCountGivenConds

private Double computeRowCountGivenConds(RelNode leftChild,
                                         RelNode rightChild,
                                         JoinRelType joinType,
                                         RexNode predicate)
Computes the rowcount from a join, given a join condition and the join inputs

Parameters:
leftChild - left input into the join
rightChild - right input into the join
joinType - join type
predicate - the join condition
Returns:
computed join rowcount

dimOnLeft

private Boolean dimOnLeft(RelNode left,
                          RelNode right,
                          BitSet leftJoinCols,
                          BitSet rightJoinCols)
Returns true if the dimension table is on the LHS of a join

Parameters:
left - left input into the join
right - right input into the join
leftJoinCols - equijoin columns from the left hand side of the join
rightJoinCols - equijoin columns from the right hand side of the join
Returns:
true if dimension table is on the left; null if cannot determine

getPopulationSize

public Double getPopulationSize(LhxJoinRel rel,
                                BitSet groupKey)

getPopulationSize

public Double getPopulationSize(LcsRowScanRel rel,
                                BitSet groupKey)

getUniqueKeys

public Set<BitSet> getUniqueKeys(LcsRowScanRel rel,
                                 boolean ignoreNulls)

areColumnsUnique

public Boolean areColumnsUnique(ProjectRel rel,
                                BitSet columns,
                                boolean ignoreNulls)

areColumnsUnique

public Boolean areColumnsUnique(LcsRowScanRel rel,
                                BitSet columns,
                                boolean ignoreNulls)

getSimpleColumnOrigins

public Set<RelColumnOrigin> getSimpleColumnOrigins(ProjectRelBase rel,
                                                   int iOutputColumn)

getSimpleColumnOrigins

public Set<RelColumnOrigin> getSimpleColumnOrigins(FilterRelBase rel,
                                                   int iOutputColumn)

getSimpleColumnOrigins

public Set<RelColumnOrigin> getSimpleColumnOrigins(LcsRowScanRel rel,
                                                   int iOutputColumn)

getSimpleColumnOrigins

public Set<RelColumnOrigin> getSimpleColumnOrigins(RelNode rel,
                                                   int iOutputColumn)

getSimpleColumnOrigin

public static RelColumnOrigin getSimpleColumnOrigin(RelNode rel,
                                                    int colOffset)
Determines the origin of a column, provided the column maps to a single column that isn't derived.

Parameters:
rel - the RelNode of the column
colOffset - the offset of the column whose origin we are trying to determine
Returns:
the origin of a column provided it's a simple column; otherwise, returns null

getSimpleTableOrigin

public static RelOptTable getSimpleTableOrigin(RelNode rel)
Determines the origin of a RelNode, provided it maps to a single table, optionally with filtering and projection.

Parameters:
rel - the RelNode
Returns:
true if the RelNode is a simple table; otherwise, returns null

isVisibleInExplain

public Boolean isVisibleInExplain(LcsIndexSearchRel rel,
                                  SqlExplainLevel level)

isVisibleInExplain

public Boolean isVisibleInExplain(LcsIndexMinusRel rel,
                                  SqlExplainLevel level)

isVisibleInExplain

public Boolean isVisibleInExplain(FennelValuesRel rel,
                                  SqlExplainLevel level)