/// <summary> /// Creates a Match object. /// </summary> /// <param name="graph"> A graph to conduct a query on. </param> /// <param name="variableMap"> An empty map of variables. </param> /// <param name="executionHelper"> A match execution helper. </param> /// <param name="matchNode"> A parse tree of match expression. </param> /// <param name="exprInfo"> A query expression information. </param> public MatchObject(Graph graph, VariableMap variableMap, IMatchExecutionHelper executionHelper, MatchNode matchNode, QueryExpressionInfo exprInfo) { if (executionHelper == null || matchNode == null || variableMap == null || graph == null) { throw new ArgumentNullException($"{this.GetType()}, passing null arguments to the constructor."); } this.helper = executionHelper; MatchVisitor matchVisitor = new MatchVisitor(graph.nodeTables, graph.edgeTables); matchNode.Accept(matchVisitor); // Create real pattern and variableMap. var result = matchVisitor.GetResult(); this.CheckParsedPatternCorrectness(result); // Create matcher and pattern based on the name of matcher and pattern. // Change if necessary . this.pattern = MatchFactory.CreatePattern(helper.ParallelPatternMatcherName, helper.PatternName, variableMap, result); // Now we have got enough information about results. // After creating pattern the variable map is filled and we know extend of the results. this.queryResults = new MatchFixedResults(this.helper.FixedArraySize, variableMap.GetCount(), executionHelper.ThreadCount); this.matcher = MatchFactory.CreateMatcher(helper.ParallelPatternMatcherName, pattern, graph, this.queryResults, executionHelper); }
/// <summary> /// Creates a parallel matchers. /// Inits arrays of threads and matchers based on thread count. /// </summary> /// <param name="pattern"> Pattern to match. </param> /// <param name="graph"> Graph to search on.</param> /// <param name="executionHelper"> Query execution helper. </param> public DFSParallelPatternMatcherStreamed(DFSPattern pattern, Graph graph, IMatchExecutionHelper executionHelper) : base(graph, executionHelper) { this.matchers = new ISingleThreadPatternMatcherStreamed[this.helper.ThreadCount]; for (int i = 0; i < this.helper.ThreadCount; i++) { this.matchers[i] = (ISingleThreadPatternMatcherStreamed)MatchFactory .CreateMatcher(this.helper.SingleThreadPatternMatcherName, // Type of Matcher i == 0 ? pattern : pattern.Clone(), // Cloning of pattern (one was already created) graph, i); // Matcher ID } }
/// <summary> /// Creates a parallel matchers. /// Inits arrays of threads and matchers based on thread count. /// </summary> /// <param name="pattern"> A pattern to match. </param> /// <param name="graph"> A graph to search on.</param> /// <param name="results"> Where to store results. </param> /// <param name="executionHelper"> A query execution helper. </param> public DFSParallelPatternMatcher(DFSPattern pattern, Graph graph, MatchFixedResults results, IMatchExecutionHelper executionHelper) : base(graph, executionHelper) { if (pattern == null || results == null) { throw new ArgumentNullException($"{this.GetType()}, passed a null to a construtor."); } this.matchers = new ISingleThreadPatternMatcher[this.helper.ThreadCount]; this.results = results; for (int i = 0; i < this.helper.ThreadCount; i++) { this.matchers[i] = (ISingleThreadPatternMatcher)MatchFactory .CreateMatcher(this.helper.SingleThreadPatternMatcherName, // Type of Matcher i == 0 ? pattern : pattern.Clone(), // Cloning of pattern (one was already created) graph, results.GetMatcherResultsStorage(i)); // Result storage } }
/// <summary> /// Creates Streamed Match object. /// </summary> /// <param name="graph"> Graph to conduct a query on. </param> /// <param name="variableMap"> Empty map of variables. </param> /// <param name="executionHelper"> Match execution helper. </param> /// <param name="matchNode"> Parse tree of match expression. </param> /// <param name="exprInfo"> A query expression information. </param> public MatchObjectStreamed(Graph graph, VariableMap variableMap, IMatchExecutionHelper executionHelper, MatchNode matchNode, QueryExpressionInfo exprInfo) { if (executionHelper == null || matchNode == null || variableMap == null || graph == null) { throw new ArgumentNullException($"{this.GetType()}, passing null arguments to the constructor."); } this.helper = executionHelper; MatchVisitor matchVisitor = new MatchVisitor(graph.nodeTables, graph.edgeTables); matchNode.Accept(matchVisitor); //Create real pattern and variableMap var result = matchVisitor.GetResult(); this.CheckParsedPatternCorrectness(result); // Create matcher and pattern based on the name of matcher and pattern // Change if necessary this.pattern = MatchFactory.CreatePattern(helper.ParallelPatternMatcherName, helper.PatternName, variableMap, result); this.matcher = (IPatternMatcherStreamed)MatchFactory.CreateMatcher(helper.ParallelPatternMatcherName, pattern, graph, executionHelper); }