net.xqhs.graphs.matchingPlatform
Class GMPImplementation

java.lang.Object
  extended by net.xqhs.util.config.Config
      extended by net.xqhs.util.logging.Unit
          extended by net.xqhs.graphs.matchingPlatform.GMPImplementation
All Implemented Interfaces:
GraphMatchingPlatform, net.xqhs.util.config.Configurable

public class GMPImplementation
extends net.xqhs.util.logging.Unit
implements GraphMatchingPlatform

An implementation of GraphMatchingPlatform using TrackingGraph instances for the principal graph and its shadows.

For each pattern in the platform, a GraphMatcherPersistent process is kept and updated with changes to the principal graph.

Author:
Andrei Olaru

Nested Class Summary
static class GMPImplementation.PrincipalGraph
          An implementation of GraphMatchingPlatform.PlatformPrincipalGraph and GraphMatchingPlatform.PlatformShadowGraph that extends TrackingGraph.
 
Nested classes/interfaces inherited from class net.xqhs.util.config.Config
net.xqhs.util.config.Config.ConfigLockedException
 
Nested classes/interfaces inherited from interface net.xqhs.graphs.matchingPlatform.GraphMatchingPlatform
GraphMatchingPlatform.PlatformPrincipalGraph, GraphMatchingPlatform.PlatformShadowGraph
 
Field Summary
(package private)  GraphMatchingPlatform.PlatformShadowGraph matchingGraph
          The graph against which the matching is done.
(package private)  MonitorPack monitor
          The MonitorPack instance to use for performance measuring.
(package private)  java.util.Map<GraphPattern,GraphMatcherPersistent> patterns
          The patterns in the platform, as a map between the patterns and the corresponding persistent matching processes.
(package private)  GraphMatchingPlatform.PlatformPrincipalGraph principalGraph
          The principal graph of the platform.
 
Fields inherited from class net.xqhs.util.logging.Unit
DEFAULT_LEVEL, DEFAULT_UNIT_NAME
 
Constructor Summary
GMPImplementation()
           
 
Method Summary
 GMPImplementation addPattern(GraphPattern pattern)
          Adds a new pattern to the platform.
 int getGraphSequence()
          Retrieves the sequence of the last change to the principal graph.
 GraphMatchingProcess getMatcherAgainstGraph(GraphPattern pattern)
          Retrieves a GraphMatchingPlatform for the specified pattern and the current sequence of the principal graph (not the matching sequence).
 java.util.Set<Match> getMatches(GraphPattern pattern, int maxK)
          Builds and returns the matches between the specified pattern and the principal graph (as it is in the current matching sequence).
 int getMathingSequence()
          Retrieves the current 'matching sequence', which is incremented by GraphMatchingPlatform.incrementSequence().
 java.util.Collection<GraphPattern> getPatterns()
           
 GraphMatchingPlatform.PlatformPrincipalGraph getPrincipalGraph()
          Retrieves the principal graph of the platform.
 java.util.Set<Match> incrementSequence()
          Builds and returns the full matches between the patterns and the principal graph with the next set of operations (transaction) applied, moving the matching sequence one step closer to the graph sequence.
 java.util.List<java.util.Map.Entry<java.lang.Integer,java.util.Set<Match>>> incrementSequence(int targetSequence)
          Applies GraphMatchingPlatform.incrementSequence() until the matching process (matching sequence) reaches desired sequence of the principal graph.
 java.util.List<java.util.Map.Entry<java.lang.Integer,java.util.Set<Match>>> incrementSequenceFastForward()
          Applies GraphMatchingPlatform.incrementSequence() until the matching process is synchronized with the principal graph.
 GMPImplementation removePattern(GraphPattern pattern)
          Removes a pattern from the platform.
 GMPImplementation setMonitor(MonitorPack monitorLink)
          Sets the MonitorPack instance to use for monitoring.
 GMPImplementation setPrincipalGraph(GraphMatchingPlatform.PlatformPrincipalGraph graph)
          Sets the principal graph of the platform.
 
Methods inherited from class net.xqhs.util.logging.Unit
compose, dbg, doExit, getDefaultUnitName, getUnitName, l, le, lf, li, lock, lockedR, lr, lr, lw, setLink, setLink, setLogDisplay, setLogEnsureNew, setLoggerClass, setLoggerType, setLoggerTypeClass, setLogLevel, setLogReporter, setUnitName, setUnitName
 
Methods inherited from class net.xqhs.util.config.Config
build, ensureLocked, locked, lockedEx, makeDefaults
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

monitor

MonitorPack monitor
The MonitorPack instance to use for performance measuring.


principalGraph

GraphMatchingPlatform.PlatformPrincipalGraph principalGraph
The principal graph of the platform.


patterns

java.util.Map<GraphPattern,GraphMatcherPersistent> patterns
The patterns in the platform, as a map between the patterns and the corresponding persistent matching processes.


matchingGraph

GraphMatchingPlatform.PlatformShadowGraph matchingGraph
The graph against which the matching is done. This is updated to get closer to the current state of the principal graph with every sequence increment.

Constructor Detail

GMPImplementation

public GMPImplementation()
Method Detail

setMonitor

public GMPImplementation setMonitor(MonitorPack monitorLink)
Sets the MonitorPack instance to use for monitoring.

Parameters:
monitorLink - - the monitor.
Returns:
the platform itself.

setPrincipalGraph

public GMPImplementation setPrincipalGraph(GraphMatchingPlatform.PlatformPrincipalGraph graph)
Description copied from interface: GraphMatchingPlatform
Sets the principal graph of the platform.

If another graph was previously set, all old data is cleared and patterns are re-added to match the new graph.

Specified by:
setPrincipalGraph in interface GraphMatchingPlatform
Parameters:
graph - - the graph, as a GraphMatchingPlatform.PlatformPrincipalGraph.
Returns:
the platform itself.

getPrincipalGraph

public GraphMatchingPlatform.PlatformPrincipalGraph getPrincipalGraph()
Description copied from interface: GraphMatchingPlatform
Retrieves the principal graph of the platform.

Specified by:
getPrincipalGraph in interface GraphMatchingPlatform
Returns:
the graph.

addPattern

public GMPImplementation addPattern(GraphPattern pattern)
Description copied from interface: GraphMatchingPlatform
Adds a new pattern to the platform. Further match retrievals will also contain matches between this new pattern and the principal graph.

Specified by:
addPattern in interface GraphMatchingPlatform
Parameters:
pattern - - the GraphPattern to add.
Returns:
the platform itself.

removePattern

public GMPImplementation removePattern(GraphPattern pattern)
Description copied from interface: GraphMatchingPlatform
Removes a pattern from the platform. All data related to the pattern is removed.

Specified by:
removePattern in interface GraphMatchingPlatform
Parameters:
pattern - - the GraphPattern to remove.
Returns:
the platform itself.

getPatterns

public java.util.Collection<GraphPattern> getPatterns()
Specified by:
getPatterns in interface GraphMatchingPlatform
Returns:
a Collection of existing patterns in the platform. May be an unmodifiable or immutable list.

incrementSequence

public java.util.Set<Match> incrementSequence()
Description copied from interface: GraphMatchingPlatform
Builds and returns the full matches between the patterns and the principal graph with the next set of operations (transaction) applied, moving the matching sequence one step closer to the graph sequence.

If the matching process was already synchronized with the principal graph, null is returned.

Specified by:
incrementSequence in interface GraphMatchingPlatform
Returns:
full matches for the newly incremented sequence, or null if the sequence cannot be incremented.

incrementSequence

public java.util.List<java.util.Map.Entry<java.lang.Integer,java.util.Set<Match>>> incrementSequence(int targetSequence)
Description copied from interface: GraphMatchingPlatform
Applies GraphMatchingPlatform.incrementSequence() until the matching process (matching sequence) reaches desired sequence of the principal graph. For each incremented sequence, the corresponding complete list of full matches is returned.

If the matching process was already synchronized with the principal graph, an empty list is returned.

Specified by:
incrementSequence in interface GraphMatchingPlatform
Parameters:
targetSequence - - the desired sequence to reach.
Returns:
a list of pairs with the sequence as key and the list of full matches existing in that sequence, as value; the empty list if there is nowhere to increment.

incrementSequenceFastForward

public java.util.List<java.util.Map.Entry<java.lang.Integer,java.util.Set<Match>>> incrementSequenceFastForward()
Description copied from interface: GraphMatchingPlatform
Applies GraphMatchingPlatform.incrementSequence() until the matching process is synchronized with the principal graph.

If the matching process was already synchronized with the principal graph, an empty list is returned.

Specified by:
incrementSequenceFastForward in interface GraphMatchingPlatform
Returns:
a list of pairs with the sequence as key and the list of full matches existing in that sequence, as value; the empty list if there is nowhere to increment.

getMatches

public java.util.Set<Match> getMatches(GraphPattern pattern,
                                       int maxK)
Description copied from interface: GraphMatchingPlatform
Builds and returns the matches between the specified pattern and the principal graph (as it is in the current matching sequence). Only the matches with k between 0 and maxK (inclusive) are returned.

Specified by:
getMatches in interface GraphMatchingPlatform
Parameters:
pattern - - the pattern for which to get the matches.
maxK - - the maximum k for retrieved matches.
Returns:
the set of matches between the pattern and the current matching sequence of the graph.

getMathingSequence

public int getMathingSequence()
Description copied from interface: GraphMatchingPlatform
Retrieves the current 'matching sequence', which is incremented by GraphMatchingPlatform.incrementSequence().

Specified by:
getMathingSequence in interface GraphMatchingPlatform
Returns:
the matching sequence.

getGraphSequence

public int getGraphSequence()
Description copied from interface: GraphMatchingPlatform
Retrieves the sequence of the last change to the principal graph.

Specified by:
getGraphSequence in interface GraphMatchingPlatform
Returns:
the graph sequence.

getMatcherAgainstGraph

public GraphMatchingProcess getMatcherAgainstGraph(GraphPattern pattern)
Description copied from interface: GraphMatchingPlatform
Retrieves a GraphMatchingPlatform for the specified pattern and the current sequence of the principal graph (not the matching sequence). Matching is done against a shadow of the principal graph. Any subsequent changes to the principal graph will not be visible in the matching process.

Except for the snapshot of the principal graph, this method uses no resources of the platform. The return matching process is independent of the platform's patterns and matching processes.

Specified by:
getMatcherAgainstGraph in interface GraphMatchingPlatform
Parameters:
pattern - - the pattern to match (can also be a normal graph).
Returns:
the matching process.