@Test public void testRuleEngine() { RuleRegistry ruleRegistry = new RuleRegistry(); ruleRegistry.addElementFactory( NonTapFactory.TEMP_TAP, new NonTapFactory() ); PlannerContext plannerContext = new PlannerContext( ruleRegistry, null, null, null, true ); ruleRegistry.addRule( new RuleAssert( PlanPhase.PreResolveAssembly, new LoneGroupExpression(), "lone group assertion" ) ); ruleRegistry.addRule( new RuleInsertionTransformer( PlanPhase.PreResolveAssembly, new TestGroupGroupExpression(), IntermediateTapElementFactory.TEMP_TAP ) ); try { new RuleExec( new TraceWriter(), ruleRegistry ).executeRulePhase( PlanPhase.PreResolveAssembly, plannerContext, new RuleResult( new LoneGroupAssertionGraph() ) ); fail(); } catch( PlannerException exception ) { // do nothing } new RuleExec( new TraceWriter(), ruleRegistry ).executeRulePhase( PlanPhase.PreResolveAssembly, plannerContext, new RuleResult( new HashJoinSameSourceGraph() ) ); }
@Test public void testSubGraphIterator() { RuleRegistry ruleRegistry = new RuleRegistry(); ruleRegistry.addElementFactory( NonTapFactory.TEMP_TAP, new NonTapFactory() ); PlannerContext plannerContext = new PlannerContext( ruleRegistry, null, null, null, true ); ruleRegistry.addRule( new RuleInsertionTransformer( PlanPhase.PreResolveAssembly, new TestCheckpointExpression(), IntermediateTapElementFactory.TEMP_TAP ) ); // ruleRegistry.addRule( new RuleContractedTransform( PlanPhase.PreResolve, new NoOpPipeExpression() ) ); RuleResult ruleResult = new RuleExec( new TraceWriter(), ruleRegistry ).executeRulePhase( PlanPhase.PreResolveAssembly, plannerContext, new RuleResult( new StandardElementGraph() ) ); FlowElementGraph flowElementGraph = ruleResult.getAssemblyGraph(); SubGraphIterator iterator = new ExpressionSubGraphIterator( new PlannerContext(), new NoGroupTapExpressionGraph(), new TapGroupTapExpressionGraph(), flowElementGraph ); while( iterator.hasNext() ) assertNotNull( iterator.next() ); }
private void runSubGraphIteratorRotate( FlowElementGraph elementGraph, int numSubGraphs ) { RuleRegistry ruleRegistry = new RuleRegistry(); PlannerContext plannerContext = new PlannerContext( ruleRegistry ); ruleRegistry.addRule( new RemoveNoOpPipeTransformer() ); RuleResult ruleResult = new RuleExec( new TraceWriter(), ruleRegistry ).executeRulePhase( PlanPhase.PreResolveAssembly, plannerContext, new RuleResult( elementGraph ) ); FlowElementGraph flowElementGraph = ruleResult.getAssemblyGraph(); flowElementGraph.writeDOT( getPlanPath() + "/node.dot" ); ExpressionSubGraphIterator iterator = new ExpressionSubGraphIterator( new PlannerContext(), new TestNoGroupTapExpressionGraph(), new TestConsecutiveTapsExpressionGraph(), false, flowElementGraph ); iterator.getContractedGraph().writeDOT( getPlanPath() + "/node-contracted.dot" ); int count = 0; while( iterator.hasNext() && count < 10 ) { ElementGraph next = iterator.next(); assertNotNull( next ); next.writeDOT( getPlanPath() + "/pipeline/" + count + "-graph.dot" ); count++; } assertEquals( "wrong number of sub-graphs", numSubGraphs, count ); }
TraceWriter traceWriter = new TraceWriter( flow ); RuleSetExec ruleSetExec = new RuleSetExec( traceWriter, this, flow, ruleRegistrySet, flowDef, flowElementGraph );
RuleExec ruleExec = new RuleExec( new TraceWriter( null ), ruleRegistry );
RuleResult ruleResult = new RuleExec( new TraceWriter(), ruleRegistry ).executeRulePhase( PlanPhase.PreResolveAssembly, plannerContext, new RuleResult( elementGraph ) ); FlowElementGraph flowElementGraph = ruleResult.getAssemblyGraph();