net.esper.eql.join.plan
Class NStreamOuterQueryPlanBuilder

java.lang.Object
  extended by net.esper.eql.join.plan.NStreamOuterQueryPlanBuilder

public class NStreamOuterQueryPlanBuilder
extends java.lang.Object

Builds a query plan for 3 or more streams in a outer join.


Constructor Summary
NStreamOuterQueryPlanBuilder()
           
 
Method Summary
protected static QueryPlan build(QueryGraph queryGraph, java.util.List<OuterJoinDesc> outerJoinDescList, java.lang.String[] streamNames)
          Build a query plan based on the stream property relationships indicated in queryGraph.
protected static OuterInnerDirectionalGraph graphOuterJoins(int numStreams, java.util.List<OuterJoinDesc> outerJoinDescList)
          Builds a graph of outer joins given the outer join information from the statement.
static java.lang.String print(java.util.Map<java.lang.Integer,int[]> streamsJoinedPerStream)
          Returns textual presentation of stream-substream relationships.
protected static void recursiveBuild(int streamNum, QueryGraph queryGraph, OuterInnerDirectionalGraph outerInnerGraph, java.util.Set<java.lang.Integer> completedStreams, java.util.LinkedHashMap<java.lang.Integer,int[]> substreamsPerStream, boolean[] requiredPerStream)
          Recusivly builds a substream-per-stream ordered tree graph using the join information supplied for outer joins and from the query graph (where clause).
static void verifyJoinedPerStream(int rootStream, java.util.Map<java.lang.Integer,int[]> streamsJoinedPerStream)
          Verifies that the tree-like structure representing which streams join (lookup) into which sub-streams is correct, ie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NStreamOuterQueryPlanBuilder

public NStreamOuterQueryPlanBuilder()
Method Detail

build

protected static QueryPlan build(QueryGraph queryGraph,
                                 java.util.List<OuterJoinDesc> outerJoinDescList,
                                 java.lang.String[] streamNames)
Build a query plan based on the stream property relationships indicated in queryGraph.

Parameters:
queryGraph - - navigation info between streams
streamNames - - stream names or aliases
outerJoinDescList - - descriptors for all outer joins
Returns:
query plan

recursiveBuild

protected static void recursiveBuild(int streamNum,
                                     QueryGraph queryGraph,
                                     OuterInnerDirectionalGraph outerInnerGraph,
                                     java.util.Set<java.lang.Integer> completedStreams,
                                     java.util.LinkedHashMap<java.lang.Integer,int[]> substreamsPerStream,
                                     boolean[] requiredPerStream)
Recusivly builds a substream-per-stream ordered tree graph using the join information supplied for outer joins and from the query graph (where clause).

Required streams are considered first and their lookup is placed first in the list to gain performance.

Parameters:
streamNum - is the root stream number that supplies the incoming event to build the tree for
queryGraph - contains where-clause stream relationship info
outerInnerGraph - contains the outer join stream relationship info
completedStreams - is a temporary holder for streams already considered
substreamsPerStream - is the ordered, tree-like structure to be filled
requiredPerStream - indicates which streams are required and which are optional

graphOuterJoins

protected static OuterInnerDirectionalGraph graphOuterJoins(int numStreams,
                                                            java.util.List<OuterJoinDesc> outerJoinDescList)
Builds a graph of outer joins given the outer join information from the statement. Eliminates right and left joins and full joins by placing the information in a graph object.

Parameters:
numStreams - - is the number of streams
outerJoinDescList - - list of outer join stream numbers and property names
Returns:
graph object

verifyJoinedPerStream

public static void verifyJoinedPerStream(int rootStream,
                                         java.util.Map<java.lang.Integer,int[]> streamsJoinedPerStream)
Verifies that the tree-like structure representing which streams join (lookup) into which sub-streams is correct, ie. all streams are included and none are listed twice.

Parameters:
rootStream - is the stream supplying the incoming event
streamsJoinedPerStream - is keyed by the from-stream number and contains as values all stream numbers of lookup into to-streams.

print

public static java.lang.String print(java.util.Map<java.lang.Integer,int[]> streamsJoinedPerStream)
Returns textual presentation of stream-substream relationships.

Parameters:
streamsJoinedPerStream - is the tree-like structure of stream-substream
Returns:
textual presentation