Пример #1
0
        private NodeMatchResult TryMatchNode <T>(MatchNodeArg <T> args) where T : class, INode
        {
            // handling remote edge
            if (args.IsRemote && args.NodeToMatch is IRemoteNode)
            {
                return(HandleRemoteNode(args));
            }

            T typedNode = args.NodeToMatch as T;

            if (typedNode != null &&
                !args.PatternNode.IsMatched &&
                args.Predicate(typedNode) &&
                !this.pattern.GetMatchedNodes().Contains(typedNode) &&
                CheckNeighbours(args.NodeToMatch, args.PatternNode))
            {
                args.MarkMatch();

                if (this.IsRemote)
                {
                    // when searching in a remote partition
                    // on match set up pattern node's remote edges
                    args.PatternNode.CopyRemoteEdgesFrom(typedNode);
                }

                return(new NodeMatchResult(true));
            }

            return(new NodeMatchResult(false));
        }
Пример #2
0
        protected override NodeMatchResult HandleRemoteNode <T>(MatchNodeArg <T> args)
        {
            // prepare pattern for remote partial search
            Pattern pattern = this.pattern.Copy();

            pattern.CurrentNode            = args.NodeToMatch.Id;
            pattern.CurrentPatternNodeName = args.PatternNode.Name;
            this.State = PartialMatchState.Pending;

            IPartialMatchResult result = null;

            using (MatcherMetric.RegisterWaitTime("partial remote match"))
            {
                result = Framework.BeginFindPartialMatch(args.RemotePartitionId, pattern);
                result.Wait();
            }

            bool matched = result.MatchedPattern.GetMatchedNodes().Count() > pattern.GetMatchedNodes().Count;

            Pattern remotePattern = (Pattern)result.MatchedPattern;

            this.pattern.Merge(remotePattern);

            this.State = PartialMatchState.Running;
            return(new NodeMatchResult(matched, remotePattern.MatchedFullSubpattern));
        }
Пример #3
0
 protected abstract NodeMatchResult HandleRemoteNode <T>(MatchNodeArg <T> args) where T : class, INode;
Пример #4
0
 protected override NodeMatchResult HandleRemoteNode <T>(MatchNodeArg <T> args)
 {
     // always return false for remote node partial match
     return(new NodeMatchResult(false));
 }