/// <summary>
 /// This method is called when a remote partial match has returned but
 /// there was no full match.
 /// </summary>
 /// <returns>true of there is a full match</returns>
 protected abstract bool FollowupOnRemoteNode(INode node, PatternNode patternNode, MatcherFunc next);
Beispiel #2
0
 protected override bool FollowupOnRemoteNode(INode node, PatternNode patternNode, MatcherFunc next)
 {
     throw new NotSupportedException();
 }
        private bool TryMatchNodeWithNext <T>(INode node, PatternNode patternNode, Predicate <T> predicate, MatcherFunc next, IMatchEdge incomingEdge) where T : class, INode
        {
            var res = TryMatchNode(new MatchNodeArg <T>(node, patternNode, predicate, incomingEdge));

            if (!res.IsMatched)
            {
                return(false);
            }

            // when already matched the whole subpattern, no need to look further
            // this can happen if returning from a remote match
            if (res.IsMatched && res.IsFullSubpatternMatched)
            {
                return(true);
            }

            bool isSubpatternMatch = false;

            // patternNode.RemoteEdges is only populated when a
            // remote node returns
            foreach (var edge in node.Edges.Cast <IMatchEdge>())
            {
                INode neighbour = edge.GetOtherNode(node);
                if (next(neighbour, edge))
                {
                    isSubpatternMatch = true;
                    break;
                }
            }

            // no match found in local partition -> check remotes as well
            // but only if this is the initially started matching (not a remote one)
            if (!isSubpatternMatch && !this.IsRemote)
            {
                isSubpatternMatch = FollowupOnRemoteNode(node, patternNode, next);

                // when no match found clear the pattern node
                if (!isSubpatternMatch)
                {
                    patternNode.Reset();
                }
            }

            return(isSubpatternMatch);
        }
Beispiel #4
0
        protected override bool FollowupOnRemoteNode(INode node, PatternNode patternNode, MatcherFunc next)
        {
            System.Diagnostics.Debug.Assert(node.Id.Equals(patternNode.MatchedNode.Id));
            foreach (var edge in patternNode.RemoteEdges)
            {
                INode n = edge.GetOtherNode(patternNode.MatchedNode);
                // do not double check nodes!
                if (!model.HasNode(n) && next(n, edge))
                {
                    logger.Trace("Matched node/subpattern in a third partition!");
                    return(true);
                }
            }

            return(false);
        }