Class NStreamQueryPlanBuilder
java.lang.Object
com.espertech.esper.common.internal.epl.join.queryplanbuild.NStreamQueryPlanBuilder
Builds a query plan for 3 or more streams in a join.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Encapsulates the chain information. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static QueryPlanForgeDesc
build
(QueryGraphForge queryGraph, EventType[] typesPerStream, HistoricalViewableDesc historicalViewableDesc, DependencyGraph dependencyGraph, HistoricalStreamIndexListForge[] historicalStreamIndexLists, boolean hasForceNestedIter, String[][][] indexedStreamsUniqueProps, TableMetaData[] tablesPerStream, StreamJoinAnalysisResultCompileTime streamJoinAnalysisResult, StatementRawInfo raw, SerdeCompileTimeResolver serdeResolver) protected static int[]
buildDefaultNestingOrder
(int numStreams, int forStream) Returns default nesting order for a given number of streams for a certain stream.protected static NStreamQueryPlanBuilder.BestChainResult
computeBestPath
(int lookupStream, QueryGraphForge queryGraph, DependencyGraph dependencyGraph) Compute a best chain or path for lookups to take for the lookup stream passed in and the query property relationships.protected static int
computeNavigableDepth
(int lookupStream, int[] nextStreams, QueryGraphForge queryGraph) Given a chain of streams to look up and indexing information, compute the index within the chain of the first non-index lookup.static TableLookupPlanDesc
createLookupPlan
(QueryGraphForge queryGraph, int currentLookupStream, int indexedStream, boolean indexedStreamIsVDW, QueryPlanIndexForge indexSpecs, EventType[] typesPerStream, TableMetaData indexedStreamTableMeta, StatementRawInfo raw, SerdeCompileTimeResolver serdeResolver) Create the table lookup plan for a from-stream to look up in an indexed stream using the columns supplied in the query graph and looking at the actual indexes available and their index number.protected static QueryPlanNodeForgeDesc
createStreamPlan
(int lookupStream, int[] bestChain, QueryGraphForge queryGraph, QueryPlanIndexForge[] indexSpecsPerStream, EventType[] typesPerStream, boolean[] isHistorical, HistoricalStreamIndexListForge[] historicalStreamIndexLists, TableMetaData[] tablesPerStream, StreamJoinAnalysisResultCompileTime streamJoinAnalysisResult, StatementRawInfo raw, SerdeCompileTimeResolver serdeResolver) Walks the chain of lookups and constructs lookup strategy and plan specification based on the index specifications.protected static boolean
isDependencySatisfied
(int lookupStream, int[] permutation, DependencyGraph dependencyGraph) Determine if the proposed permutation of lookups passes dependencies
-
Constructor Details
-
NStreamQueryPlanBuilder
public NStreamQueryPlanBuilder()
-
-
Method Details
-
build
protected static QueryPlanForgeDesc build(QueryGraphForge queryGraph, EventType[] typesPerStream, HistoricalViewableDesc historicalViewableDesc, DependencyGraph dependencyGraph, HistoricalStreamIndexListForge[] historicalStreamIndexLists, boolean hasForceNestedIter, String[][][] indexedStreamsUniqueProps, TableMetaData[] tablesPerStream, StreamJoinAnalysisResultCompileTime streamJoinAnalysisResult, StatementRawInfo raw, SerdeCompileTimeResolver serdeResolver) -
createStreamPlan
protected static QueryPlanNodeForgeDesc createStreamPlan(int lookupStream, int[] bestChain, QueryGraphForge queryGraph, QueryPlanIndexForge[] indexSpecsPerStream, EventType[] typesPerStream, boolean[] isHistorical, HistoricalStreamIndexListForge[] historicalStreamIndexLists, TableMetaData[] tablesPerStream, StreamJoinAnalysisResultCompileTime streamJoinAnalysisResult, StatementRawInfo raw, SerdeCompileTimeResolver serdeResolver) Walks the chain of lookups and constructs lookup strategy and plan specification based on the index specifications.- Parameters:
lookupStream
- - the stream to construct the query plan forbestChain
- - the chain that the lookup follows to make best use of indexesqueryGraph
- - the repository for key properties to indexesindexSpecsPerStream
- - specifications of indexestypesPerStream
- - event types for each streamisHistorical
- - indicator for each stream if it is a historical streams or nothistoricalStreamIndexLists
- - index management, populated for the query plantablesPerStream
- tablesstreamJoinAnalysisResult
- stream join analysisraw
- raw infoserdeResolver
- serde resolver- Returns:
- NestedIterationNode with lookups attached underneath
-
createLookupPlan
public static TableLookupPlanDesc createLookupPlan(QueryGraphForge queryGraph, int currentLookupStream, int indexedStream, boolean indexedStreamIsVDW, QueryPlanIndexForge indexSpecs, EventType[] typesPerStream, TableMetaData indexedStreamTableMeta, StatementRawInfo raw, SerdeCompileTimeResolver serdeResolver) Create the table lookup plan for a from-stream to look up in an indexed stream using the columns supplied in the query graph and looking at the actual indexes available and their index number.- Parameters:
queryGraph
- - contains properties joining the 2 streamscurrentLookupStream
- - stream to use key values fromindexedStream
- - stream to look up inindexSpecs
- - index specification defining indexes to be created for streamtypesPerStream
- - event types for each streamindexedStreamTableMeta
- table infoindexedStreamIsVDW
- vdw indicatorsraw
- raw infoserdeResolver
- serde resolver- Returns:
- plan for performing a lookup in a given table using one of the indexes supplied
-
computeBestPath
protected static NStreamQueryPlanBuilder.BestChainResult computeBestPath(int lookupStream, QueryGraphForge queryGraph, DependencyGraph dependencyGraph) Compute a best chain or path for lookups to take for the lookup stream passed in and the query property relationships. The method runs through all possible permutations of lookup pathNumberSetPermutationEnumeration
until a path is found in which all streams can be accessed via an index. If not such path is found, the method returns the path with the greatest depth, ie. where the first one or more streams are index accesses. If no depth other then zero is found, returns the default nesting order.- Parameters:
lookupStream
- - stream to start look upqueryGraph
- - navigability between streamsdependencyGraph
- - dependencies between historical streams- Returns:
- chain and chain depth
-
isDependencySatisfied
protected static boolean isDependencySatisfied(int lookupStream, int[] permutation, DependencyGraph dependencyGraph) Determine if the proposed permutation of lookups passes dependencies- Parameters:
lookupStream
- stream to initiatepermutation
- permutation of lookupsdependencyGraph
- dependencies- Returns:
- pass or fail indication
-
buildDefaultNestingOrder
protected static int[] buildDefaultNestingOrder(int numStreams, int forStream) Returns default nesting order for a given number of streams for a certain stream. Example: numStreams = 5, forStream = 2, result = {0, 1, 3, 4} The resulting array has all streams except the forStream, in ascdending order.- Parameters:
numStreams
- - number of streamsforStream
- - stream to generate a nesting order for- Returns:
- int array with all stream numbers starting at 0 to (numStreams - 1) leaving the forStream out
-