net.sf.farrago.query
Class FarragoRelMetadataProvider

java.lang.Object
  extended by org.eigenbase.rel.metadata.ReflectiveRelMetadataProvider
      extended by net.sf.farrago.query.FarragoRelMetadataProvider
All Implemented Interfaces:
RelMetadataProvider, ReflectiveVisitor

public class FarragoRelMetadataProvider
extends ReflectiveRelMetadataProvider

FarragoRelMetadataProvider implements Farrago specific metadata. Initially, it provides costing information available through statistics. Other potential uses of this class are:

  1. Provide cost information for Farrago rels
  2. Provides a uniform cost model for all rels of concern to Farrago

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/query/FarragoRelMetadataProvider.java#18 $
Author:
John Pham

Field Summary
private  FarragoColumnMetadata columnMd
           
private  FarragoRepos repos
           
 
Constructor Summary
FarragoRelMetadataProvider(FarragoRepos repos)
          Initializes a provider with access to the Farrago catalog.
 
Method Summary
 Boolean areColumnsUnique(RelNode rel, BitSet columns, boolean ignoreNulls)
           
 Boolean canRestart(RelNode rel)
           
 Double getDistinctRowCount(RelNode rel, BitSet groupKey, RexNode predicate)
           
 Double getPopulationSize(RelNode rel, BitSet groupKey)
           
 Double getRowCount(RelNode rel)
          Retrieves the row count of a Farrago expression or null
static Double getRowCountStat(RelNode rel, FarragoRepos repos)
          Retrieves the row count of a Farrago expression or null, using statistics stored in the catalog
static Double getRowCountStat(RelOptTable table, FarragoRepos repos)
          Retrieves the row count of a relational table using statistics stored in the catalog
static Double getRowCountStat(RelOptTable table, FarragoRepos repos, Timestamp labelTimestamp)
          Retrieves the row count of a relational table for a specific label, using statistics stored in the catalog.
 RelStatSource getStatistics(RelNode rel)
          Retrieves statistics for a relational expression, if they exist in the catalog.
private static RelStatSource getStatistics(RelNode rel, FarragoRepos repos)
           
private static RelStatSource getStatistics(RelOptTable table, FarragoRepos repos, Timestamp labelTimestamp)
           
 Set<BitSet> getUniqueKeys(RelNode rel, boolean ignoreNulls)
           
 
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 FarragoColumnMetadata columnMd
Constructor Detail

FarragoRelMetadataProvider

public FarragoRelMetadataProvider(FarragoRepos repos)
Initializes a provider with access to the Farrago catalog. The provider reads statistics stored in the catalog.

Parameters:
repos - the Farrago catalog
Method Detail

getStatistics

public RelStatSource getStatistics(RelNode rel)
Retrieves statistics for a relational expression, if they exist in the catalog.

Parameters:
rel - the relational expression
Returns:
the statistics object, or null

getStatistics

private static RelStatSource getStatistics(RelNode rel,
                                           FarragoRepos repos)

getStatistics

private static RelStatSource getStatistics(RelOptTable table,
                                           FarragoRepos repos,
                                           Timestamp labelTimestamp)

getRowCountStat

public static Double getRowCountStat(RelNode rel,
                                     FarragoRepos repos)
Retrieves the row count of a Farrago expression or null, using statistics stored in the catalog

Parameters:
rel - the relational expression
repos - repository
Returns:
the row count, or null if stats aren't available

getRowCountStat

public static Double getRowCountStat(RelOptTable table,
                                     FarragoRepos repos)
Retrieves the row count of a relational table using statistics stored in the catalog

Parameters:
table - the relational table
repos - repository
Returns:
the row count, or null if stats aren't available

getRowCountStat

public static Double getRowCountStat(RelOptTable table,
                                     FarragoRepos repos,
                                     Timestamp labelTimestamp)
Retrieves the row count of a relational table for a specific label, using statistics stored in the catalog.

Parameters:
table - the relational table
repos - repository
labelTimestamp - creation timestamp of the label that determines which stats to retrieve; null if there is no label setting
Returns:
the row count, or null if stats aren't available

getRowCount

public Double getRowCount(RelNode rel)
Retrieves the row count of a Farrago expression or null

Parameters:
rel - the relational expression
Returns:
the row count, or null if the row count was not available

getUniqueKeys

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

areColumnsUnique

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

getPopulationSize

public Double getPopulationSize(RelNode rel,
                                BitSet groupKey)

getDistinctRowCount

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

canRestart

public Boolean canRestart(RelNode rel)