com.espertech.esper.util
Class DependencyGraph

java.lang.Object
  extended by com.espertech.esper.util.DependencyGraph

public class DependencyGraph
extends java.lang.Object

Model of dependency of lookup, in which one stream supplies values for lookup in another stream.


Constructor Summary
DependencyGraph(int numStreams, boolean allowDependencySame)
          Ctor.
 
Method Summary
 void addDependency(int target, int from)
          Adds a single dependency of target on a required streams.
 void addDependency(int target, java.util.SortedSet<java.lang.Integer> requiredStreams)
          Adds dependencies that a target may have on required streams.
 java.util.Map<java.lang.Integer,java.util.SortedSet<java.lang.Integer>> getDependencies()
          Returns a map of stream number and the streams dependencies.
 java.util.Set<java.lang.Integer> getDependenciesForStream(int stream)
          Returns the set of dependent streams for a given stream.
 java.util.Stack<java.lang.Integer> getFirstCircularDependency()
          Returns any circular dependency as a stack of stream numbers, or null if none exist.
 int getNumStreams()
          Returns the number of streams.
 java.util.Set<java.lang.Integer> getRootNodes()
          Returns a set of stream numbers that are the root dependencies, i.e.
 java.util.Set<java.lang.Integer> getRootNodes(java.util.Set<java.lang.Integer> ignoreList)
          Return the root nodes ignoring the nodes provided.
 boolean hasDependency(int stream)
          Returns true if the stream asked for has a dependency.
 boolean hasUnsatisfiedDependency(int navigableStream, java.util.Set<java.lang.Integer> ignoreList)
          Check if the given stream has any dependencies, direct or indirect, to any of the streams that are not in the ignore list.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DependencyGraph

public DependencyGraph(int numStreams,
                       boolean allowDependencySame)
Ctor.

Parameters:
numStreams - - number of streams
Method Detail

getNumStreams

public int getNumStreams()
Returns the number of streams.

Returns:
number of streams

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addDependency

public void addDependency(int target,
                          java.util.SortedSet<java.lang.Integer> requiredStreams)
Adds dependencies that a target may have on required streams.

Parameters:
target - the stream having dependencies on one or more other streams
requiredStreams - the streams that the target stream has a dependency on

addDependency

public void addDependency(int target,
                          int from)
Adds a single dependency of target on a required streams.

Parameters:
target - the stream having dependencies on one or more other streams
from - a single required streams that the target stream has a dependency on

hasDependency

public boolean hasDependency(int stream)
Returns true if the stream asked for has a dependency.

Parameters:
stream - to check dependency for
Returns:
true if a dependency exist, false if not

getDependenciesForStream

public java.util.Set<java.lang.Integer> getDependenciesForStream(int stream)
Returns the set of dependent streams for a given stream.

Parameters:
stream - to return dependent streams for
Returns:
set of stream numbers of stream providing properties

getDependencies

public java.util.Map<java.lang.Integer,java.util.SortedSet<java.lang.Integer>> getDependencies()
Returns a map of stream number and the streams dependencies.

Returns:
map of dependencies

getRootNodes

public java.util.Set<java.lang.Integer> getRootNodes()
Returns a set of stream numbers that are the root dependencies, i.e. the dependencies with the deepest graph.

Returns:
set of stream number of streams

getRootNodes

public java.util.Set<java.lang.Integer> getRootNodes(java.util.Set<java.lang.Integer> ignoreList)
Return the root nodes ignoring the nodes provided.

Parameters:
ignoreList - nodes to be ignored
Returns:
root nodes

getFirstCircularDependency

public java.util.Stack<java.lang.Integer> getFirstCircularDependency()
Returns any circular dependency as a stack of stream numbers, or null if none exist.

Returns:
circular dependency stack

hasUnsatisfiedDependency

public boolean hasUnsatisfiedDependency(int navigableStream,
                                        java.util.Set<java.lang.Integer> ignoreList)
Check if the given stream has any dependencies, direct or indirect, to any of the streams that are not in the ignore list.


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