Java Code Examples for org.apache.flink.api.common.Plan#accept()

The following examples show how to use org.apache.flink.api.common.Plan#accept() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OperatorResolver.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public OperatorResolver(Plan p) {
	this.map = new HashMap<String, List<Operator<?>>>();
	this.seen = new HashSet<Operator<?>>();
	
	p.accept(this);
	this.seen = null;
}
 
Example 2
Source File: CachedMatchStrategyCompilerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * This test simulates a join of a big left side with a small right side inside of an iteration, where the small side is on a static path.
 * Currently the best execution plan is a HYBRIDHASH_BUILD_SECOND_CACHED, where the small side is hashed and cached.
 * This test also makes sure that all relevant plans are correctly enumerated by the optimizer.
 */
@Test
public void testCorrectChoosing() {
	try {
		
		Plan plan = getTestPlanRightStatic("");
		
		SourceCollectorVisitor sourceCollector = new SourceCollectorVisitor();
		plan.accept(sourceCollector);
		
		for(GenericDataSourceBase<?, ?> s : sourceCollector.getSources()) {
			if(s.getName().equals("bigFile")) {
				this.setSourceStatistics(s, 10000000, 1000);
			}
			else if(s.getName().equals("smallFile")) {
				this.setSourceStatistics(s, 100, 100);
			}
		}
		
		
		OptimizedPlan oPlan = compileNoStats(plan);

		OptimizerPlanNodeResolver resolver = getOptimizerPlanNodeResolver(oPlan);
		DualInputPlanNode innerJoin = resolver.getNode("DummyJoiner");
		
		// verify correct join strategy
		assertEquals(DriverStrategy.HYBRIDHASH_BUILD_SECOND_CACHED, innerJoin.getDriverStrategy());
		assertEquals(TempMode.NONE, innerJoin.getInput1().getTempMode());
		assertEquals(TempMode.NONE, innerJoin.getInput2().getTempMode());
	
		new JobGraphGenerator().compileJobGraph(oPlan);
	}
	catch (Exception e) {
		System.err.println(e.getMessage());
		e.printStackTrace();
		fail("Test errored: " + e.getMessage());
	}
}
 
Example 3
Source File: OperatorResolver.java    From flink with Apache License 2.0 5 votes vote down vote up
public OperatorResolver(Plan p) {
	this.map = new HashMap<String, List<Operator<?>>>();
	this.seen = new HashSet<Operator<?>>();
	
	p.accept(this);
	this.seen = null;
}
 
Example 4
Source File: CachedMatchStrategyCompilerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test simulates a join of a big left side with a small right side inside of an iteration, where the small side is on a static path.
 * Currently the best execution plan is a HYBRIDHASH_BUILD_SECOND_CACHED, where the small side is hashed and cached.
 * This test also makes sure that all relevant plans are correctly enumerated by the optimizer.
 */
@Test
public void testCorrectChoosing() {
	try {
		
		Plan plan = getTestPlanRightStatic("");
		
		SourceCollectorVisitor sourceCollector = new SourceCollectorVisitor();
		plan.accept(sourceCollector);
		
		for(GenericDataSourceBase<?, ?> s : sourceCollector.getSources()) {
			if(s.getName().equals("bigFile")) {
				this.setSourceStatistics(s, 10000000, 1000);
			}
			else if(s.getName().equals("smallFile")) {
				this.setSourceStatistics(s, 100, 100);
			}
		}
		
		
		OptimizedPlan oPlan = compileNoStats(plan);

		OptimizerPlanNodeResolver resolver = getOptimizerPlanNodeResolver(oPlan);
		DualInputPlanNode innerJoin = resolver.getNode("DummyJoiner");
		
		// verify correct join strategy
		assertEquals(DriverStrategy.HYBRIDHASH_BUILD_SECOND_CACHED, innerJoin.getDriverStrategy());
		assertEquals(TempMode.NONE, innerJoin.getInput1().getTempMode());
		assertEquals(TempMode.NONE, innerJoin.getInput2().getTempMode());
	
		new JobGraphGenerator().compileJobGraph(oPlan);
	}
	catch (Exception e) {
		System.err.println(e.getMessage());
		e.printStackTrace();
		fail("Test errored: " + e.getMessage());
	}
}
 
Example 5
Source File: OperatorResolver.java    From flink with Apache License 2.0 5 votes vote down vote up
public OperatorResolver(Plan p) {
	this.map = new HashMap<String, List<Operator<?>>>();
	this.seen = new HashSet<Operator<?>>();
	
	p.accept(this);
	this.seen = null;
}
 
Example 6
Source File: CachedMatchStrategyCompilerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test simulates a join of a big left side with a small right side inside of an iteration, where the small side is on a static path.
 * Currently the best execution plan is a HYBRIDHASH_BUILD_SECOND_CACHED, where the small side is hashed and cached.
 * This test also makes sure that all relevant plans are correctly enumerated by the optimizer.
 */
@Test
public void testCorrectChoosing() {
	try {
		
		Plan plan = getTestPlanRightStatic("");
		
		SourceCollectorVisitor sourceCollector = new SourceCollectorVisitor();
		plan.accept(sourceCollector);
		
		for(GenericDataSourceBase<?, ?> s : sourceCollector.getSources()) {
			if(s.getName().equals("bigFile")) {
				this.setSourceStatistics(s, 10000000, 1000);
			}
			else if(s.getName().equals("smallFile")) {
				this.setSourceStatistics(s, 100, 100);
			}
		}
		
		
		OptimizedPlan oPlan = compileNoStats(plan);

		OptimizerPlanNodeResolver resolver = getOptimizerPlanNodeResolver(oPlan);
		DualInputPlanNode innerJoin = resolver.getNode("DummyJoiner");
		
		// verify correct join strategy
		assertEquals(DriverStrategy.HYBRIDHASH_BUILD_SECOND_CACHED, innerJoin.getDriverStrategy());
		assertEquals(TempMode.NONE, innerJoin.getInput1().getTempMode());
		assertEquals(TempMode.NONE, innerJoin.getInput2().getTempMode());
	
		new JobGraphGenerator().compileJobGraph(oPlan);
	}
	catch (Exception e) {
		System.err.println(e.getMessage());
		e.printStackTrace();
		fail("Test errored: " + e.getMessage());
	}
}
 
Example 7
Source File: Optimizer.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * This function performs only the first step to the compilation process - the creation of the optimizer
 * representation of the plan. No estimations or enumerations of alternatives are done here.
 * 
 * @param program The plan to generate the optimizer representation for.
 * @return The optimizer representation of the plan, as a collection of all data sinks
 *         from the plan can be traversed.
 */
public static List<DataSinkNode> createPreOptimizedPlan(Plan program) {
	GraphCreatingVisitor graphCreator = new GraphCreatingVisitor(1, null);
	program.accept(graphCreator);
	return graphCreator.getSinks();
}
 
Example 8
Source File: Optimizer.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * This function performs only the first step to the compilation process - the creation of the optimizer
 * representation of the plan. No estimations or enumerations of alternatives are done here.
 * 
 * @param program The plan to generate the optimizer representation for.
 * @return The optimizer representation of the plan, as a collection of all data sinks
 *         from the plan can be traversed.
 */
public static List<DataSinkNode> createPreOptimizedPlan(Plan program) {
	GraphCreatingVisitor graphCreator = new GraphCreatingVisitor(1, null);
	program.accept(graphCreator);
	return graphCreator.getSinks();
}
 
Example 9
Source File: Optimizer.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * This function performs only the first step to the compilation process - the creation of the optimizer
 * representation of the plan. No estimations or enumerations of alternatives are done here.
 * 
 * @param program The plan to generate the optimizer representation for.
 * @return The optimizer representation of the plan, as a collection of all data sinks
 *         from the plan can be traversed.
 */
public static List<DataSinkNode> createPreOptimizedPlan(Plan program) {
	GraphCreatingVisitor graphCreator = new GraphCreatingVisitor(1, null);
	program.accept(graphCreator);
	return graphCreator.getSinks();
}