private void debugCompatibleEdges( Collection<Scope> results, int v1, int v2, List<ScopeExpression> matchers ) { for( Scope result : results ) { FlowElement lhs = elementGraph.getDelegate().getEdgeSource( result ); int lhsIndex = elementGraph.getIndex( lhs ); FlowElement rhs = elementGraph.getDelegate().getEdgeTarget( result ); int rhsIndex = elementGraph.getIndex( rhs ); LOG.debug( "compatible edge: {}:{} -> {}:{}, having: {}", lhsIndex, lhs, rhsIndex, rhs, result.printSimple() ); } for( ScopeExpression matcher : matchers ) LOG.debug( " - {} -> {} matcher: {}", v1, v2, matcher ); }
public FlowElement getElementNode( int vertex ) { return elementGraph.getVertex( vertex ); }
if( !elementGraph.containsEdge( node2, other2 ) || !areCompatibleEdges( node1, other1, node2, other2 ) ) return false; if( !elementGraph.containsEdge( other2, node2 ) || !areCompatibleEdges( other1, node1, other2, node2 ) ) return false; for( int other2 : elementGraph.getSuccessors( node2 ) ) for( int other2 : elementGraph.getPredecessors( node2 ) )
in2[ node2 ] = 0; for( int other : elementGraph.getPredecessors( node2 ) ) out2[ node2 ] = 0; for( int other : elementGraph.getSuccessors( node2 ) )
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; }
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; }
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 ); }
for( int other : elementGraph.getPredecessors( node2 ) ) for( int other : elementGraph.getSuccessors( node2 ) )