org.eigenbase.lurql
Class LurqlReflectiveExecutor

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

public class LurqlReflectiveExecutor
extends Object

LurqlReflectiveExecutor executes a LurqlPlan via calls to the JMI reflective interface.

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

Field Summary
private  Map<String,?> args
           
private static RefObject[] EMPTY_REFOBJ_ARRAY
           
private  Map<LurqlFilter,Set<Object>> filterMap
           
private  Set<RefObject> finalResult
           
private  LurqlPlan plan
           
private  MDRepository repos
           
private  Connection sqlConnection
           
private  Map<LurqlPlanVertex,Set<RefObject>> vertexToResultMap
           
private  Map<LurqlPlanVertex,Set<RefObject>> vertexToStashMap
           
 
Constructor Summary
LurqlReflectiveExecutor(MDRepository repos, LurqlPlan plan, Connection sqlConnection, Map<String,?> args)
          Creates a new executor for a plan.
 
Method Summary
 Set<RefObject> execute()
          Executes the plan specified by the constructor.
private  void executeFilters(Collection<RefObject> input, Set<RefObject> output, LurqlFilter[] filters, LurqlPlanExistsEdge[] existsEdges, JmiClassVertex typeFilter)
           
private  void executeGraph(org.jgrapht.DirectedGraph<LurqlPlanVertex,LurqlPlanEdge> graph)
           
private  void executeOutgoingEdges(org.jgrapht.DirectedGraph<LurqlPlanVertex,LurqlPlanEdge> graph, LurqlPlanVertex planVertex, Set<RefObject> input, boolean executeRecursive)
           
private  void executeRecursion(LurqlPlanVertex rootVertex)
           
private  void executeRoot(LurqlPlanVertex planVertex, Set<RefObject> output)
           
private  Set findResultSet(LurqlPlanVertex planVertex)
           
private  Set<RefObject> findResultSet(Map<LurqlPlanVertex,Set<RefObject>> map, LurqlPlanVertex planVertex)
           
private  LurqlPlanExistsEdge[] getExistsEdges(org.jgrapht.DirectedGraph graph, LurqlPlanVertex planVertex)
           
private  LurqlFilter[] getFilters(LurqlPlanVertex planVertex)
           
private  Set getFilterValues(LurqlFilter filter)
           
private  Set<RefObject> getResultSet(LurqlPlanVertex planVertex)
           
private  Set<RefObject> getResultSet(Map<LurqlPlanVertex,Set<RefObject>> map, LurqlPlanVertex planVertex)
           
private  boolean testExists(RefObject refObj, LurqlPlanExistsEdge existsEdge)
           
private  void transferResults(List<LurqlPlanVertex> vertexList, Map<LurqlPlanVertex,Set<RefObject>> dstMap, Map<LurqlPlanVertex,Set<RefObject>> srcMap, LurqlPlanVertex rootVertex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_REFOBJ_ARRAY

private static final RefObject[] EMPTY_REFOBJ_ARRAY

repos

private final MDRepository repos

plan

private final LurqlPlan plan

sqlConnection

private final Connection sqlConnection

vertexToResultMap

private Map<LurqlPlanVertex,Set<RefObject>> vertexToResultMap

vertexToStashMap

private Map<LurqlPlanVertex,Set<RefObject>> vertexToStashMap

filterMap

private Map<LurqlFilter,Set<Object>> filterMap

args

private Map<String,?> args

finalResult

private Set<RefObject> finalResult
Constructor Detail

LurqlReflectiveExecutor

public LurqlReflectiveExecutor(MDRepository repos,
                               LurqlPlan plan,
                               Connection sqlConnection,
                               Map<String,?> args)
Creates a new executor for a plan.

Parameters:
repos - the repository to be accessed
plan - the plan to be executed
sqlConnection - JDBC connection for evaluation of SQL queries, or null if no SQL context is available
args - argument values for parameters
Method Detail

execute

public Set<RefObject> execute()
                       throws JmiQueryException
Executes the plan specified by the constructor.

Returns:
objects found (as a modifiable set of RefObjects)
Throws:
JmiQueryException

executeGraph

private void executeGraph(org.jgrapht.DirectedGraph<LurqlPlanVertex,LurqlPlanEdge> graph)
                   throws JmiQueryException
Throws:
JmiQueryException

executeRecursion

private void executeRecursion(LurqlPlanVertex rootVertex)
                       throws JmiQueryException
Throws:
JmiQueryException

transferResults

private void transferResults(List<LurqlPlanVertex> vertexList,
                             Map<LurqlPlanVertex,Set<RefObject>> dstMap,
                             Map<LurqlPlanVertex,Set<RefObject>> srcMap,
                             LurqlPlanVertex rootVertex)
                      throws JmiQueryException
Throws:
JmiQueryException

executeRoot

private void executeRoot(LurqlPlanVertex planVertex,
                         Set<RefObject> output)
                  throws JmiQueryException
Throws:
JmiQueryException

getFilters

private LurqlFilter[] getFilters(LurqlPlanVertex planVertex)

getExistsEdges

private LurqlPlanExistsEdge[] getExistsEdges(org.jgrapht.DirectedGraph graph,
                                             LurqlPlanVertex planVertex)

executeOutgoingEdges

private void executeOutgoingEdges(org.jgrapht.DirectedGraph<LurqlPlanVertex,LurqlPlanEdge> graph,
                                  LurqlPlanVertex planVertex,
                                  Set<RefObject> input,
                                  boolean executeRecursive)
                           throws JmiQueryException
Throws:
JmiQueryException

executeFilters

private void executeFilters(Collection<RefObject> input,
                            Set<RefObject> output,
                            LurqlFilter[] filters,
                            LurqlPlanExistsEdge[] existsEdges,
                            JmiClassVertex typeFilter)
                     throws JmiQueryException
Throws:
JmiQueryException

testExists

private boolean testExists(RefObject refObj,
                           LurqlPlanExistsEdge existsEdge)
                    throws JmiQueryException
Throws:
JmiQueryException

getFilterValues

private Set getFilterValues(LurqlFilter filter)
                     throws JmiQueryException
Throws:
JmiQueryException

findResultSet

private Set<RefObject> findResultSet(Map<LurqlPlanVertex,Set<RefObject>> map,
                                     LurqlPlanVertex planVertex)

getResultSet

private Set<RefObject> getResultSet(Map<LurqlPlanVertex,Set<RefObject>> map,
                                    LurqlPlanVertex planVertex)

findResultSet

private Set findResultSet(LurqlPlanVertex planVertex)

getResultSet

private Set<RefObject> getResultSet(LurqlPlanVertex planVertex)