com.espertech.esper.view
Class ViewServiceHelper

java.lang.Object
  extended by com.espertech.esper.view.ViewServiceHelper

public class ViewServiceHelper
extends java.lang.Object

Utility methods to deal with chains of views, and for merge/group-by views.


Constructor Summary
ViewServiceHelper()
           
 
Method Summary
protected static void addMergeViews(java.util.List<ViewSpec> specifications)
          Add merge views for any views in the chain requiring a merge (group view).
static IStreamRandomAccess getOptPreviousExprRandomAccess(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext)
           
static IStreamRelativeAccess getOptPreviousExprRelativeAccess(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext)
           
static IStreamSortRankRandomAccess getOptPreviousExprSortedRankedAccess(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext)
           
static java.util.Set<java.lang.String> getUniqueCandidateProperties(java.util.List<ViewFactory> viewFactory, java.lang.annotation.Annotation[] annotations)
           
protected static java.util.List<View> instantiateChain(Viewable parentViewable, java.util.List<ViewFactory> viewFactories, AgentInstanceViewFactoryChainContext viewFactoryChainContext)
          Instantiate a chain of views.
static java.util.List<ViewFactory> instantiateFactories(int streamNum, java.util.List<ViewSpec> viewSpecList, StatementContext statementContext)
          Given a list of view specifications obtained from by parsing this method instantiates a list of view factories.
protected static Pair<Viewable,java.util.List<View>> matchExistingViews(Viewable rootViewable, java.util.List<ViewFactory> viewFactories)
          Match the views under the stream to the list of view specications passed in.
protected static java.util.List<View> removeChainLeafView(Viewable parentViewable, Viewable viewToRemove)
          Removes a view from a parent view returning the orphaned parent views in a list.
static void removeFirstUnsharedView(java.util.List<View> childViews)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewServiceHelper

public ViewServiceHelper()
Method Detail

getUniqueCandidateProperties

public static java.util.Set<java.lang.String> getUniqueCandidateProperties(java.util.List<ViewFactory> viewFactory,
                                                                           java.lang.annotation.Annotation[] annotations)

getOptPreviousExprRandomAccess

public static IStreamRandomAccess getOptPreviousExprRandomAccess(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext)

getOptPreviousExprRelativeAccess

public static IStreamRelativeAccess getOptPreviousExprRelativeAccess(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext)

getOptPreviousExprSortedRankedAccess

public static IStreamSortRankRandomAccess getOptPreviousExprSortedRankedAccess(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext)

addMergeViews

protected static void addMergeViews(java.util.List<ViewSpec> specifications)
                             throws ViewProcessingException
Add merge views for any views in the chain requiring a merge (group view). Appends to the list of view specifications passed in one ore more new view specifications that represent merge views. Merge views have the same parameter list as the (group) view they merge data for.

Parameters:
specifications - is a list of view definitions defining the chain of views.
Throws:
ViewProcessingException - indicating that the view chain configuration is invalid

instantiateChain

protected static java.util.List<View> instantiateChain(Viewable parentViewable,
                                                       java.util.List<ViewFactory> viewFactories,
                                                       AgentInstanceViewFactoryChainContext viewFactoryChainContext)
Instantiate a chain of views.

Parameters:
parentViewable - - parent view to add the chain to
viewFactories - - is the view factories to use to make each view, or reuse and existing view
Returns:
chain of views instantiated

removeFirstUnsharedView

public static void removeFirstUnsharedView(java.util.List<View> childViews)

removeChainLeafView

protected static java.util.List<View> removeChainLeafView(Viewable parentViewable,
                                                          Viewable viewToRemove)
Removes a view from a parent view returning the orphaned parent views in a list.

Parameters:
parentViewable - - parent to remove view from
viewToRemove - - view to remove
Returns:
chain of orphaned views

matchExistingViews

protected static Pair<Viewable,java.util.List<View>> matchExistingViews(Viewable rootViewable,
                                                                        java.util.List<ViewFactory> viewFactories)
Match the views under the stream to the list of view specications passed in. The method changes the view specifications list passed in and removes those specifications for which matcing views have been found. If none of the views under the stream matches the first view specification passed in, the method returns the stream itself and leaves the view specification list unchanged. If one view under the stream matches, the view's specification is removed from the list. The method will then attempt to determine if any child views of that view also match specifications.

Parameters:
rootViewable - is the top rootViewable event stream to which all views are attached as child views This parameter is changed by this method, ie. specifications are removed if they match existing views.
viewFactories - is the view specifications for making views
Returns:
a pair of (A) the stream if no views matched, or the last child view that matched (B) the full list of parent views

instantiateFactories

public static java.util.List<ViewFactory> instantiateFactories(int streamNum,
                                                               java.util.List<ViewSpec> viewSpecList,
                                                               StatementContext statementContext)
                                                        throws ViewProcessingException
Given a list of view specifications obtained from by parsing this method instantiates a list of view factories. The view factories are not yet aware of each other after leaving this method (so not yet chained logically). They are simply instantiated and assigned view parameters.

Parameters:
streamNum - is the stream number
viewSpecList - is the view definition
statementContext - is statement service context and statement info
Returns:
list of view factories
Throws:
ViewProcessingException - if the factory cannot be creates such as for invalid view spec

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