org.eigenbase.lurql
Class LurqlPlan

java.lang.Object
  extended by org.eigenbase.lurql.LurqlPlan

public class LurqlPlan
extends Object

LurqlPlan represents a prepared plan for executing a LURQL query.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/lurql/LurqlPlan.java#1 $
Author:
John V. Sichi

Field Summary
private  Map<String,LurqlPathBranch> aliasToBranchMap
          Map from alias name to corresponding LurqlPathBranch
private  int existsDepth
           
private  Set<LurqlPlanVertex> existsSet
          For select *, all vertices which are defined inside of exists (meaning they should not contribute to the final result).
private  org.jgrapht.DirectedGraph<LurqlPlanVertex,LurqlPlanEdge> graph
          Directed acyclic graph of LurqlPlanVertexes.
private  int idGen
           
private  JmiModelView modelView
          The model view we are querying
private  Map<String,Class> paramMap
           
private  Set<String> projectSet
          All project elements, keyed by alias
private  LurqlQuery query
          Query we've planned to execute
private  Set recVars
          All variables part of a recursion
 
Constructor Summary
LurqlPlan(JmiModelView modelView, LurqlQuery query)
           
 
Method Summary
private  void addFilters(LurqlPlanVertex planVertex, List<LurqlFilter> filters)
           
private  void addParam(LurqlDynamicParam param, Class paramType)
           
private  void addTraversals(LurqlPlanVertex sourceVertex, LurqlPlanVertex targetVertex, LurqlFollow follow, Collection<JmiAssocEdge> assocEdges, JmiClassVertex destinationClassVertex, int iOriginEnd)
           
 void explain(PrintWriter pw)
           
private  Collection<JmiAssocEdge> filterEdgeSet(Collection<JmiAssocEdge> edgeSet, Collection<JmiAssocEdge> filterEdgeSet)
           
private  JmiClassVertex findClassVertex(String className)
           
 org.jgrapht.DirectedGraph<LurqlPlanVertex,LurqlPlanEdge> getGraph()
           
 JmiModelView getModelView()
           
 Map<String,Class> getParamMap()
           
 boolean isSelectAll()
           
 boolean isSelected(LurqlPlanVertex vertex)
           
private  boolean isStar(List<String> selectList)
           
(package private)  JmiQueryException newException(String err)
           
(package private)  JmiQueryException newException(String err, Throwable cause)
           
private  LurqlPlanVertex newPlanVertex(LurqlPathBranch branch, Set<String> rootObjectIds)
           
private  void prepareExists(LurqlPlanVertex planVertex, LurqlExists exists, boolean isNegated)
           
private  void prepareFollow(LurqlFollow follow, List<LurqlPlanVertex> parentVertexList, List<LurqlPlanVertex> leafVertexList)
           
private  void prepareFollowEdges(LurqlPlanVertex sourceVertex, LurqlPlanVertex targetVertex, LurqlFollow follow)
           
private  void preparePathSpec(List<LurqlPlanVertex> parentVertexList, LurqlPathSpec pathSpec, List<LurqlPlanVertex> leafVertexList)
           
(package private)  void prepareQuery()
           
private  void prepareRecurse(LurqlRecurse recurse, List<LurqlPlanVertex> parentVertexList, List<LurqlPlanVertex> leafVertexList)
           
private  void prepareRoot(LurqlRoot root, List<LurqlPlanVertex> leafVertexList)
           
private  boolean testAssocEnd(AssociationEnd end, String endFilterValue)
           
private  boolean testAssocFilter(String filterValue, String actualValue)
           
private  String validateAlias(LurqlPathBranch branch)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aliasToBranchMap

private final Map<String,LurqlPathBranch> aliasToBranchMap
Map from alias name to corresponding LurqlPathBranch


recVars

private final Set recVars
All variables part of a recursion


modelView

private final JmiModelView modelView
The model view we are querying


query

private final LurqlQuery query
Query we've planned to execute


graph

private final org.jgrapht.DirectedGraph<LurqlPlanVertex,LurqlPlanEdge> graph
Directed acyclic graph of LurqlPlanVertexes.


projectSet

private Set<String> projectSet
All project elements, keyed by alias


existsSet

private Set<LurqlPlanVertex> existsSet
For select *, all vertices which are defined inside of exists (meaning they should not contribute to the final result).


idGen

private int idGen

paramMap

private Map<String,Class> paramMap

existsDepth

private int existsDepth
Constructor Detail

LurqlPlan

public LurqlPlan(JmiModelView modelView,
                 LurqlQuery query)
          throws JmiQueryException
Throws:
JmiQueryException
Method Detail

getModelView

public JmiModelView getModelView()

isSelectAll

public boolean isSelectAll()

isSelected

public boolean isSelected(LurqlPlanVertex vertex)

explain

public void explain(PrintWriter pw)

prepareQuery

void prepareQuery()
            throws JmiQueryException
Throws:
JmiQueryException

isStar

private boolean isStar(List<String> selectList)

getGraph

public org.jgrapht.DirectedGraph<LurqlPlanVertex,LurqlPlanEdge> getGraph()

getParamMap

public Map<String,Class> getParamMap()

prepareRoot

private void prepareRoot(LurqlRoot root,
                         List<LurqlPlanVertex> leafVertexList)
                  throws JmiQueryException
Throws:
JmiQueryException

newPlanVertex

private LurqlPlanVertex newPlanVertex(LurqlPathBranch branch,
                                      Set<String> rootObjectIds)
                               throws JmiQueryException
Throws:
JmiQueryException

preparePathSpec

private void preparePathSpec(List<LurqlPlanVertex> parentVertexList,
                             LurqlPathSpec pathSpec,
                             List<LurqlPlanVertex> leafVertexList)
                      throws JmiQueryException
Throws:
JmiQueryException

prepareRecurse

private void prepareRecurse(LurqlRecurse recurse,
                            List<LurqlPlanVertex> parentVertexList,
                            List<LurqlPlanVertex> leafVertexList)
                     throws JmiQueryException
Throws:
JmiQueryException

prepareFollow

private void prepareFollow(LurqlFollow follow,
                           List<LurqlPlanVertex> parentVertexList,
                           List<LurqlPlanVertex> leafVertexList)
                    throws JmiQueryException
Throws:
JmiQueryException

prepareFollowEdges

private void prepareFollowEdges(LurqlPlanVertex sourceVertex,
                                LurqlPlanVertex targetVertex,
                                LurqlFollow follow)
                         throws JmiQueryException
Throws:
JmiQueryException

filterEdgeSet

private Collection<JmiAssocEdge> filterEdgeSet(Collection<JmiAssocEdge> edgeSet,
                                               Collection<JmiAssocEdge> filterEdgeSet)

addTraversals

private void addTraversals(LurqlPlanVertex sourceVertex,
                           LurqlPlanVertex targetVertex,
                           LurqlFollow follow,
                           Collection<JmiAssocEdge> assocEdges,
                           JmiClassVertex destinationClassVertex,
                           int iOriginEnd)
                    throws JmiQueryException
Throws:
JmiQueryException

findClassVertex

private JmiClassVertex findClassVertex(String className)
                                throws JmiQueryException
Throws:
JmiQueryException

testAssocEnd

private boolean testAssocEnd(AssociationEnd end,
                             String endFilterValue)

testAssocFilter

private boolean testAssocFilter(String filterValue,
                                String actualValue)

newException

JmiQueryException newException(String err)

newException

JmiQueryException newException(String err,
                               Throwable cause)

addFilters

private void addFilters(LurqlPlanVertex planVertex,
                        List<LurqlFilter> filters)
                 throws JmiQueryException
Throws:
JmiQueryException

prepareExists

private void prepareExists(LurqlPlanVertex planVertex,
                           LurqlExists exists,
                           boolean isNegated)
                    throws JmiQueryException
Throws:
JmiQueryException

addParam

private void addParam(LurqlDynamicParam param,
                      Class paramType)
               throws JmiQueryException
Throws:
JmiQueryException

validateAlias

private String validateAlias(LurqlPathBranch branch)
                      throws JmiQueryException
Throws:
JmiQueryException