Esempio n. 1
0
        /// <summary>
        /// Generates scheduled search plans needed for matcher code generation for action compilation
        /// out of static schedule information given by rulePattern elements, 
        /// or out of statistics stemming from loading previously serialized statistics 
        /// utilizing code of the lgsp matcher generator.
        /// The scheduled search plans are added to the main and the nested pattern graphs.
        /// </summary>
        internal static void GenerateScheduledSearchPlans(PatternGraph patternGraph, LGSPGraphStatistics graphStatistics, 
            LGSPMatcherGenerator matcherGen,
            bool isSubpatternLike, bool isNegativeOrIndependent,
            ScheduledSearchPlan nestingScheduledSearchPlan)
        {
            for(int i=0; i<patternGraph.schedules.Length; ++i)
            {
                patternGraph.AdaptToMaybeNull(i);
                if(matcherGen.Profile)
                    LGSPMatcherGenerator.SetNeedForProfiling(patternGraph);
                PlanGraph planGraph;
                if(graphStatistics != null)
                    planGraph = matcherGen.GeneratePlanGraph(graphStatistics, patternGraph, 
                        isNegativeOrIndependent, isSubpatternLike,
                        LGSPMatcherGenerator.ExtractOwnElements(nestingScheduledSearchPlan, patternGraph));
                else
                    planGraph = GenerateStaticPlanGraph(patternGraph,
                        isNegativeOrIndependent, isSubpatternLike, matcherGen.InlineIndependents,
                        LGSPMatcherGenerator.ExtractOwnElements(nestingScheduledSearchPlan, patternGraph));
                matcherGen.MarkMinimumSpanningArborescence(planGraph, patternGraph.name);
                SearchPlanGraph searchPlanGraph = matcherGen.GenerateSearchPlanGraph(planGraph);
                ScheduledSearchPlan scheduledSearchPlan = matcherGen.ScheduleSearchPlan(
                    searchPlanGraph, patternGraph, isNegativeOrIndependent);
                matcherGen.AppendHomomorphyInformation(scheduledSearchPlan);
                patternGraph.schedules[i] = scheduledSearchPlan;
                patternGraph.RevertMaybeNullAdaption(i);

                foreach(PatternGraph neg in patternGraph.negativePatternGraphsPlusInlined)
                {
                    GenerateScheduledSearchPlans(neg, graphStatistics, matcherGen, 
                        isSubpatternLike, true, null);
                }

                foreach(PatternGraph idpt in patternGraph.independentPatternGraphsPlusInlined)
                {
                    GenerateScheduledSearchPlans(idpt, graphStatistics, matcherGen,
                        isSubpatternLike, true, patternGraph.schedules[i]);
                }

                foreach(Alternative alt in patternGraph.alternativesPlusInlined)
                {
                    foreach(PatternGraph altCase in alt.alternativeCases)
                    {
                        GenerateScheduledSearchPlans(altCase, graphStatistics, matcherGen, 
                            true, false, null);
                    }
                }

                foreach(Iterated iter in patternGraph.iteratedsPlusInlined)
                {
                    GenerateScheduledSearchPlans(iter.iteratedPattern, graphStatistics, matcherGen, 
                        true, false, null);
                }
            }
        }
Esempio n. 2
0
        private static void BuildInterpretationPlan(LGSPGraph graph)
        {
            LGSPMatcherGenerator matcherGen = new LGSPMatcherGenerator(graph.Model);
            graph.matchingState.patternGraph = matcherGen.BuildPatternGraph(graph);
            PlanGraph planGraph = matcherGen.GeneratePlanGraph(graph.statistics, graph.matchingState.patternGraph, 
                false, false, new Dictionary<PatternElement, SetValueType>());
            matcherGen.MarkMinimumSpanningArborescence(planGraph, graph.matchingState.patternGraph.name);
            SearchPlanGraph searchPlanGraph = matcherGen.GenerateSearchPlanGraph(planGraph);
            ScheduledSearchPlan scheduledSearchPlan = matcherGen.ScheduleSearchPlan(
                searchPlanGraph, graph.matchingState.patternGraph, false);
            InterpretationPlanBuilder builder = new InterpretationPlanBuilder(scheduledSearchPlan, searchPlanGraph, graph.Model);
            graph.matchingState.interpretationPlan = builder.BuildInterpretationPlan("ComparisonMatcher_" + graph.graphID);
            ++GraphMatchingState.numInterpretationPlans;
            graph.matchingState.changesCounterAtInterpretationPlanBuilding = graph.changesCounterAtLastAnalyze;
            Debug.Assert(graph.changesCounterAtLastAnalyze == graph.ChangesCounter);

#if LOG_ISOMORPHY_CHECKING
            SourceBuilder sb = new SourceBuilder();
            graph.matchingState.interpretationPlan.Dump(sb);
            writer.WriteLine();
            writer.WriteLine(sb.ToString());
            writer.WriteLine();
            writer.Flush();
#endif
        }