com.espertech.esper.epl.join.plan
Class NStreamOuterQueryPlanBuilder

java.lang.Object
  extended by com.espertech.esper.epl.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, OuterJoinDesc[] outerJoinDescList, java.lang.String[] streamNames, EventType[] typesPerStream, HistoricalViewableDesc historicalViewableDesc, DependencyGraph dependencyGraph, HistoricalStreamIndexList[] historicalStreamIndexLists, ExprEvaluatorContext exprEvaluatorContext, java.lang.String[][][] indexedStreamsUniqueProps, TableMetadata[] tablesPerStream)
          Build a query plan based on the stream property relationships indicated in queryGraph.
protected static OuterInnerDirectionalGraph graphOuterJoins(int numStreams, 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, java.util.Stack<java.lang.Integer> streamCallStack, QueryGraph queryGraph, OuterInnerDirectionalGraph outerInnerGraph, InnerJoinGraph innerJoinGraph, java.util.Set<java.lang.Integer> completedStreams, java.util.LinkedHashMap<java.lang.Integer,int[]> substreamsPerStream, boolean[] requiredPerStream, DependencyGraph dependencyGraph)
          Recusivly builds a substream-per-stream ordered tree graph using the join information supplied for outer joins and from the query graph (where clause).
protected static void recursiveBuildInnerJoin(int streamNum, java.util.Stack<java.lang.Integer> streamCallStack, QueryGraph queryGraph, java.util.Set<java.lang.Integer> completedStreams, java.util.LinkedHashMap<java.lang.Integer,int[]> substreamsPerStream, DependencyGraph dependencyGraph)
          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,
                                 OuterJoinDesc[] outerJoinDescList,
                                 java.lang.String[] streamNames,
                                 EventType[] typesPerStream,
                                 HistoricalViewableDesc historicalViewableDesc,
                                 DependencyGraph dependencyGraph,
                                 HistoricalStreamIndexList[] historicalStreamIndexLists,
                                 ExprEvaluatorContext exprEvaluatorContext,
                                 java.lang.String[][][] indexedStreamsUniqueProps,
                                 TableMetadata[] tablesPerStream)
                          throws ExprValidationException
Build a query plan based on the stream property relationships indicated in queryGraph.

Parameters:
queryGraph - - navigation info between streams
streamNames - - stream names
outerJoinDescList - - descriptors for all outer joins
typesPerStream - - event types for each stream
dependencyGraph - - dependencies between historical streams
historicalStreamIndexLists - - index management, populated for the query plan
exprEvaluatorContext - context for expression evalauation
Returns:
query plan
Throws:
ExprValidationException - if the query planning failed

recursiveBuild

protected static void recursiveBuild(int streamNum,
                                     java.util.Stack<java.lang.Integer> streamCallStack,
                                     QueryGraph queryGraph,
                                     OuterInnerDirectionalGraph outerInnerGraph,
                                     InnerJoinGraph innerJoinGraph,
                                     java.util.Set<java.lang.Integer> completedStreams,
                                     java.util.LinkedHashMap<java.lang.Integer,int[]> substreamsPerStream,
                                     boolean[] requiredPerStream,
                                     DependencyGraph dependencyGraph)
                              throws ExprValidationException
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
streamCallStack - the query plan call stack of streams available via cursor
dependencyGraph - - dependencies between historical streams
Throws:
ExprValidationException - if the query planning failed

recursiveBuildInnerJoin

protected static void recursiveBuildInnerJoin(int streamNum,
                                              java.util.Stack<java.lang.Integer> streamCallStack,
                                              QueryGraph queryGraph,
                                              java.util.Set<java.lang.Integer> completedStreams,
                                              java.util.LinkedHashMap<java.lang.Integer,int[]> substreamsPerStream,
                                              DependencyGraph dependencyGraph)
                                       throws ExprValidationException
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
completedStreams - is a temporary holder for streams already considered
substreamsPerStream - is the ordered, tree-like structure to be filled
streamCallStack - the query plan call stack of streams available via cursor
dependencyGraph - - dependencies between historical streams
Throws:
ExprValidationException - if the query planning failed

graphOuterJoins

protected static OuterInnerDirectionalGraph graphOuterJoins(int numStreams,
                                                            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

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com