public ElementExpression getMatcherNode( int vertex ) { return matchGraph.getVertex( vertex ); }
for( int other1 : matchGraph.getSuccessors( node1 ) ) for( int other1 : matchGraph.getPredecessors( node1 ) ) if( !matchGraph.containsEdge( node1, other1 ) ) LOG.trace( "no matcher edge between nodes: {}:{} -> {}:{}", node1, matchGraph.getVertex( node1 ), other1, matchGraph.getVertex( other1 ) ); if( !matchGraph.containsEdge( other1, node1 ) ) LOG.trace( "no matcher edge between nodes: {}:{} -> {}:{}", other1, matchGraph.getVertex( other1 ), node1, matchGraph.getVertex( node1 ) );
in1[ addedNode1 ] = 0; for( int other : matchGraph.getPredecessors( addedNode1 ) ) out1[ addedNode1 ] = 0; for( int other : matchGraph.getSuccessors( addedNode1 ) )
State( FinderContext finderContext, PlannerContext plannerContext, SearchOrder searchOrder, DirectedGraph<ElementExpression, ScopeExpression> matchGraph, ElementGraph elementGraph ) { this.finderContext = finderContext; this.plannerContext = plannerContext; this.matchGraph = new IndexedMatchGraph( matchGraph ); this.elementGraph = new IndexedElementGraph( searchOrder, elementGraph ); n1 = matchGraph.vertexSet().size(); n2 = elementGraph.vertexSet().size(); order = null; coreLen = 0; origCoreLen = 0; t1bothLen = 0; t1inLen = 0; t1outLen = 0; t2bothLen = 0; t2inLen = 0; t2outLen = 0; addedNode1 = NULL_NODE; core1 = new int[ n1 ]; core2 = new int[ n2 ]; in1 = new int[ n1 ]; in2 = new int[ n2 ]; out1 = new int[ n1 ]; out2 = new int[ n2 ]; Arrays.fill( core1, NULL_NODE ); Arrays.fill( core2, NULL_NODE ); }
protected boolean areCompatibleEdges( int v1, int v2, int v3, int v4 ) { List<ScopeExpression> matchers = matchGraph.getAllEdgesList( v1, v2 ); // if there is any edge between the nodes, capture all and return true if( matchers.size() == 1 && matchers.get( 0 ).acceptsAll() ) { if( LOG.isDebugEnabled() ) debugCompatibleEdges( elementGraph.getAllEdgesList( v3, v4 ), v1, v2, matchers ); return true; } List<Scope> scopes = elementGraph.getAllEdgesList( v3, v4 ); Collection<Scope> results = areCompatibleEdges( plannerContext, elementGraph.getElementGraph(), matchers, scopes ); if( LOG.isDebugEnabled() && results != null ) debugCompatibleEdges( results, v1, v2, matchers ); return results != null; }
core2[ node2 ] = node1; for( int other : matchGraph.getPredecessors( node1 ) ) for( int other : matchGraph.getSuccessors( node1 ) )
private boolean areCompatibleNodes( int node1, int node2 ) { Expression expression = matchGraph.getVertex( node1 ); FlowElement flowElement = elementGraph.getVertex( node2 ); boolean result; if( ( (ElementExpression) expression ).getCapture() == ElementCapture.Primary && !finderContext.getRequiredElements().isEmpty() ) result = finderContext.isRequired( flowElement ); else if( finderContext.isExcluded( flowElement ) || finderContext.isIgnored( flowElement ) ) result = false; else result = expression.applies( plannerContext, elementGraph.getElementGraph(), flowElement ); if( LOG.isDebugEnabled() && result ) LOG.debug( "compatible nodes: {}:{} matched {}:{}", node1, expression, node2, flowElement ); return result; }