org.eigenbase.relopt
Class RelOptQuery

java.lang.Object
  extended by org.eigenbase.relopt.RelOptQuery

public class RelOptQuery
extends Object

A RelOptQuery represents a set of relational expressions which derive from the same select statement.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/relopt/RelOptQuery.java#13 $

Nested Class Summary
static interface RelOptQuery.DeferredLookup
          Contains the information necessary to repeat a call to SqlToRelConverter.Blackboard.lookup(int, org.eigenbase.sql2rel.SqlToRelConverter.LookupContext).
 
Field Summary
static String correlPrefix
          Prefix to the name of correlating variables.
(package private)  Map<String,RelNode> mapCorrelToRel
          Maps name of correlating variable (e.g.
private  Map<RelOptQuery.DeferredLookup,String> mapDeferredToCorrel
          Maps a from-list expression to the name of the correlating variable which references it.
private  int nextCorrel
           
private  RelOptPlanner planner
           
 
Constructor Summary
RelOptQuery(RelOptPlanner planner)
          Creates a query.
 
Method Summary
 RelOptCluster createCluster(Environment env, RelDataTypeFactory typeFactory, RexBuilder rexBuilder)
          Creates a cluster.
 String createCorrel()
          Constructs a new name for a correlating variable.
 String createCorrelUnresolved(RelOptQuery.DeferredLookup deferredLookup)
          Creates a name for a correlating variable for which no RelNode has been created yet.
static int getCorrelOrdinal(String correlName)
          Converts a correlating variable name into an ordinal, unqiue within the query.
 Map<RelOptQuery.DeferredLookup,String> getMapDeferredToCorrel()
          Returns the map which identifies which correlating variable each RelOptQuery.DeferredLookup will set.
 RelNode lookupCorrel(String name)
          Returns the relational expression which populates a correlating variable.
 void mapCorrel(String name, RelNode rel)
          Maps a correlating variable to a RelNode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

correlPrefix

public static final String correlPrefix
Prefix to the name of correlating variables.

See Also:
Constant Field Values

mapDeferredToCorrel

private final Map<RelOptQuery.DeferredLookup,String> mapDeferredToCorrel
Maps a from-list expression to the name of the correlating variable which references it. This is for forward-references, caused when from items have correlating variables. We will later resolve to a RelNode.


mapCorrelToRel

final Map<String,RelNode> mapCorrelToRel
Maps name of correlating variable (e.g. "$cor3") to the RelNode which implements it.


planner

private final RelOptPlanner planner

nextCorrel

private int nextCorrel
Constructor Detail

RelOptQuery

public RelOptQuery(RelOptPlanner planner)
Creates a query.

Parameters:
planner - Planner
Method Detail

getCorrelOrdinal

public static int getCorrelOrdinal(String correlName)
Converts a correlating variable name into an ordinal, unqiue within the query.

Parameters:
correlName - Name of correlating variable
Returns:
Correlating variable ordinal

getMapDeferredToCorrel

public Map<RelOptQuery.DeferredLookup,String> getMapDeferredToCorrel()
Returns the map which identifies which correlating variable each RelOptQuery.DeferredLookup will set.

Returns:
Map of deferred lookups

createCluster

public RelOptCluster createCluster(Environment env,
                                   RelDataTypeFactory typeFactory,
                                   RexBuilder rexBuilder)
Creates a cluster.

Parameters:
env - OpenJava environment
typeFactory - Type factory
rexBuilder - Expression builder
Returns:
New cluster

createCorrel

public String createCorrel()
Constructs a new name for a correlating variable. It is unique within the whole query.


createCorrelUnresolved

public String createCorrelUnresolved(RelOptQuery.DeferredLookup deferredLookup)
Creates a name for a correlating variable for which no RelNode has been created yet.

Parameters:
deferredLookup - contains the information required to resolve the variable later

lookupCorrel

public RelNode lookupCorrel(String name)
Returns the relational expression which populates a correlating variable.


mapCorrel

public void mapCorrel(String name,
                      RelNode rel)
Maps a correlating variable to a RelNode.