Java Code Examples for org.apache.flink.optimizer.plan.DualInputPlanNode#getInput1()

The following examples show how to use org.apache.flink.optimizer.plan.DualInputPlanNode#getInput1() . 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: AdditionalOperatorsTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testCrossWithSmall() {
	// construct the plan
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(DEFAULT_PARALLELISM);
	DataSet<Long> set1 = env.generateSequence(0,1);
	DataSet<Long> set2 = env.generateSequence(0,1);

	set1.crossWithTiny(set2).name("Cross")
			.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());

	try {
		Plan plan = env.createProgramPlan();
		OptimizedPlan oPlan = compileWithStats(plan);
		OptimizerPlanNodeResolver resolver = new OptimizerPlanNodeResolver(oPlan);
		
		DualInputPlanNode crossPlanNode = resolver.getNode("Cross");
		Channel in1 = crossPlanNode.getInput1();
		Channel in2 = crossPlanNode.getInput2();
		
		assertEquals(ShipStrategyType.FORWARD, in1.getShipStrategy());
		assertEquals(ShipStrategyType.BROADCAST, in2.getShipStrategy());
	} catch(CompilerException ce) {
		ce.printStackTrace();
		fail("The Flink optimizer is unable to compile this plan correctly.");
	}
}
 
Example 2
Source File: AdditionalOperatorsTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testCrossWithLarge() {
	// construct the plan
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(DEFAULT_PARALLELISM);
	DataSet<Long> set1 = env.generateSequence(0,1);
	DataSet<Long> set2 = env.generateSequence(0,1);

	set1.crossWithHuge(set2).name("Cross")
			.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());

	try {
		Plan plan = env.createProgramPlan();
		OptimizedPlan oPlan = compileNoStats(plan);
		OptimizerPlanNodeResolver resolver = new OptimizerPlanNodeResolver(oPlan);
		
		DualInputPlanNode crossPlanNode = resolver.getNode("Cross");
		Channel in1 = crossPlanNode.getInput1();
		Channel in2 = crossPlanNode.getInput2();
		
		assertEquals(ShipStrategyType.BROADCAST, in1.getShipStrategy());
		assertEquals(ShipStrategyType.FORWARD, in2.getShipStrategy());
	} catch(CompilerException ce) {
		ce.printStackTrace();
		fail("The pact compiler is unable to compile this plan correctly.");
	}
}
 
Example 3
Source File: AdditionalOperatorsTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCrossWithSmall() {
	// construct the plan
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(DEFAULT_PARALLELISM);
	DataSet<Long> set1 = env.generateSequence(0,1);
	DataSet<Long> set2 = env.generateSequence(0,1);

	set1.crossWithTiny(set2).name("Cross")
			.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());

	try {
		Plan plan = env.createProgramPlan();
		OptimizedPlan oPlan = compileWithStats(plan);
		OptimizerPlanNodeResolver resolver = new OptimizerPlanNodeResolver(oPlan);
		
		DualInputPlanNode crossPlanNode = resolver.getNode("Cross");
		Channel in1 = crossPlanNode.getInput1();
		Channel in2 = crossPlanNode.getInput2();
		
		assertEquals(ShipStrategyType.FORWARD, in1.getShipStrategy());
		assertEquals(ShipStrategyType.BROADCAST, in2.getShipStrategy());
	} catch(CompilerException ce) {
		ce.printStackTrace();
		fail("The Flink optimizer is unable to compile this plan correctly.");
	}
}
 
Example 4
Source File: AdditionalOperatorsTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCrossWithLarge() {
	// construct the plan
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(DEFAULT_PARALLELISM);
	DataSet<Long> set1 = env.generateSequence(0,1);
	DataSet<Long> set2 = env.generateSequence(0,1);

	set1.crossWithHuge(set2).name("Cross")
			.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());

	try {
		Plan plan = env.createProgramPlan();
		OptimizedPlan oPlan = compileNoStats(plan);
		OptimizerPlanNodeResolver resolver = new OptimizerPlanNodeResolver(oPlan);
		
		DualInputPlanNode crossPlanNode = resolver.getNode("Cross");
		Channel in1 = crossPlanNode.getInput1();
		Channel in2 = crossPlanNode.getInput2();
		
		assertEquals(ShipStrategyType.BROADCAST, in1.getShipStrategy());
		assertEquals(ShipStrategyType.FORWARD, in2.getShipStrategy());
	} catch(CompilerException ce) {
		ce.printStackTrace();
		fail("The pact compiler is unable to compile this plan correctly.");
	}
}
 
Example 5
Source File: AdditionalOperatorsTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCrossWithSmall() {
	// construct the plan
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(DEFAULT_PARALLELISM);
	DataSet<Long> set1 = env.generateSequence(0,1);
	DataSet<Long> set2 = env.generateSequence(0,1);

	set1.crossWithTiny(set2).name("Cross")
			.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());

	try {
		Plan plan = env.createProgramPlan();
		OptimizedPlan oPlan = compileWithStats(plan);
		OptimizerPlanNodeResolver resolver = new OptimizerPlanNodeResolver(oPlan);
		
		DualInputPlanNode crossPlanNode = resolver.getNode("Cross");
		Channel in1 = crossPlanNode.getInput1();
		Channel in2 = crossPlanNode.getInput2();
		
		assertEquals(ShipStrategyType.FORWARD, in1.getShipStrategy());
		assertEquals(ShipStrategyType.BROADCAST, in2.getShipStrategy());
	} catch(CompilerException ce) {
		ce.printStackTrace();
		fail("The Flink optimizer is unable to compile this plan correctly.");
	}
}
 
Example 6
Source File: AdditionalOperatorsTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCrossWithLarge() {
	// construct the plan
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(DEFAULT_PARALLELISM);
	DataSet<Long> set1 = env.generateSequence(0,1);
	DataSet<Long> set2 = env.generateSequence(0,1);

	set1.crossWithHuge(set2).name("Cross")
			.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());

	try {
		Plan plan = env.createProgramPlan();
		OptimizedPlan oPlan = compileNoStats(plan);
		OptimizerPlanNodeResolver resolver = new OptimizerPlanNodeResolver(oPlan);
		
		DualInputPlanNode crossPlanNode = resolver.getNode("Cross");
		Channel in1 = crossPlanNode.getInput1();
		Channel in2 = crossPlanNode.getInput2();
		
		assertEquals(ShipStrategyType.BROADCAST, in1.getShipStrategy());
		assertEquals(ShipStrategyType.FORWARD, in2.getShipStrategy());
	} catch(CompilerException ce) {
		ce.printStackTrace();
		fail("The pact compiler is unable to compile this plan correctly.");
	}
}
 
Example 7
Source File: GroupOrderTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testCoGroupWithGroupOrder() {
	// construct the plan
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(DEFAULT_PARALLELISM);
	DataSet<Tuple7<Long, Long, Long, Long, Long, Long, Long>> set1 = env.readCsvFile("/tmp/fake1.csv")
			.types(Long.class, Long.class, Long.class, Long.class, Long.class, Long.class, Long.class);
	DataSet<Tuple7<Long, Long, Long, Long, Long, Long, Long>> set2 = env.readCsvFile("/tmp/fake2.csv")
			.types(Long.class, Long.class, Long.class, Long.class, Long.class, Long.class, Long.class);

	set1.coGroup(set2).where(3,0).equalTo(6,0)
			.sortFirstGroup(5, Order.DESCENDING)
			.sortSecondGroup(1, Order.DESCENDING).sortSecondGroup(4, Order.ASCENDING)
			.with(new IdentityCoGrouper<Tuple7<Long, Long, Long, Long, Long, Long, Long>>()).name("CoGroup")
			.output(new DiscardingOutputFormat<Tuple7<Long, Long, Long, Long, Long, Long, Long>>()).name("Sink");

	Plan plan = env.createProgramPlan();
	OptimizedPlan oPlan;

	try {
		oPlan = compileNoStats(plan);
	} catch(CompilerException ce) {
		ce.printStackTrace();
		fail("The pact compiler is unable to compile this plan correctly.");
		return; // silence the compiler
	}
	
	OptimizerPlanNodeResolver resolver = getOptimizerPlanNodeResolver(oPlan);
	SinkPlanNode sinkNode = resolver.getNode("Sink");
	DualInputPlanNode coGroupNode = resolver.getNode("CoGroup");
	
	// verify the strategies
	Assert.assertEquals(ShipStrategyType.FORWARD, sinkNode.getInput().getShipStrategy());
	Assert.assertEquals(ShipStrategyType.PARTITION_HASH, coGroupNode.getInput1().getShipStrategy());
	Assert.assertEquals(ShipStrategyType.PARTITION_HASH, coGroupNode.getInput2().getShipStrategy());
	
	Channel c1 = coGroupNode.getInput1();
	Channel c2 = coGroupNode.getInput2();
	
	Assert.assertEquals(LocalStrategy.SORT, c1.getLocalStrategy());
	Assert.assertEquals(LocalStrategy.SORT, c2.getLocalStrategy());
	
	FieldList ship1 = new FieldList(3, 0);
	FieldList ship2 = new FieldList(6, 0);
	
	FieldList local1 = new FieldList(3, 0, 5);
	FieldList local2 = new FieldList(6, 0, 1, 4);
	
	Assert.assertEquals(ship1, c1.getShipStrategyKeys());
	Assert.assertEquals(ship2, c2.getShipStrategyKeys());
	Assert.assertEquals(local1, c1.getLocalStrategyKeys());
	Assert.assertEquals(local2, c2.getLocalStrategyKeys());
	
	Assert.assertTrue(c1.getLocalStrategySortOrder()[0] == coGroupNode.getSortOrders()[0]);
	Assert.assertTrue(c1.getLocalStrategySortOrder()[1] == coGroupNode.getSortOrders()[1]);
	Assert.assertTrue(c2.getLocalStrategySortOrder()[0] == coGroupNode.getSortOrders()[0]);
	Assert.assertTrue(c2.getLocalStrategySortOrder()[1] == coGroupNode.getSortOrders()[1]);
	
	// check that the local group orderings are correct
	Assert.assertEquals(false, c1.getLocalStrategySortOrder()[2]);
	Assert.assertEquals(false, c2.getLocalStrategySortOrder()[2]);
	Assert.assertEquals(true, c2.getLocalStrategySortOrder()[3]);
}
 
Example 8
Source File: GroupOrderTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testCoGroupWithGroupOrder() {
	// construct the plan
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(DEFAULT_PARALLELISM);
	DataSet<Tuple7<Long, Long, Long, Long, Long, Long, Long>> set1 = env.readCsvFile("/tmp/fake1.csv")
			.types(Long.class, Long.class, Long.class, Long.class, Long.class, Long.class, Long.class);
	DataSet<Tuple7<Long, Long, Long, Long, Long, Long, Long>> set2 = env.readCsvFile("/tmp/fake2.csv")
			.types(Long.class, Long.class, Long.class, Long.class, Long.class, Long.class, Long.class);

	set1.coGroup(set2).where(3,0).equalTo(6,0)
			.sortFirstGroup(5, Order.DESCENDING)
			.sortSecondGroup(1, Order.DESCENDING).sortSecondGroup(4, Order.ASCENDING)
			.with(new IdentityCoGrouper<Tuple7<Long, Long, Long, Long, Long, Long, Long>>()).name("CoGroup")
			.output(new DiscardingOutputFormat<Tuple7<Long, Long, Long, Long, Long, Long, Long>>()).name("Sink");

	Plan plan = env.createProgramPlan();
	OptimizedPlan oPlan;

	try {
		oPlan = compileNoStats(plan);
	} catch(CompilerException ce) {
		ce.printStackTrace();
		fail("The pact compiler is unable to compile this plan correctly.");
		return; // silence the compiler
	}
	
	OptimizerPlanNodeResolver resolver = getOptimizerPlanNodeResolver(oPlan);
	SinkPlanNode sinkNode = resolver.getNode("Sink");
	DualInputPlanNode coGroupNode = resolver.getNode("CoGroup");
	
	// verify the strategies
	Assert.assertEquals(ShipStrategyType.FORWARD, sinkNode.getInput().getShipStrategy());
	Assert.assertEquals(ShipStrategyType.PARTITION_HASH, coGroupNode.getInput1().getShipStrategy());
	Assert.assertEquals(ShipStrategyType.PARTITION_HASH, coGroupNode.getInput2().getShipStrategy());
	
	Channel c1 = coGroupNode.getInput1();
	Channel c2 = coGroupNode.getInput2();
	
	Assert.assertEquals(LocalStrategy.SORT, c1.getLocalStrategy());
	Assert.assertEquals(LocalStrategy.SORT, c2.getLocalStrategy());
	
	FieldList ship1 = new FieldList(3, 0);
	FieldList ship2 = new FieldList(6, 0);
	
	FieldList local1 = new FieldList(3, 0, 5);
	FieldList local2 = new FieldList(6, 0, 1, 4);
	
	Assert.assertEquals(ship1, c1.getShipStrategyKeys());
	Assert.assertEquals(ship2, c2.getShipStrategyKeys());
	Assert.assertEquals(local1, c1.getLocalStrategyKeys());
	Assert.assertEquals(local2, c2.getLocalStrategyKeys());
	
	Assert.assertTrue(c1.getLocalStrategySortOrder()[0] == coGroupNode.getSortOrders()[0]);
	Assert.assertTrue(c1.getLocalStrategySortOrder()[1] == coGroupNode.getSortOrders()[1]);
	Assert.assertTrue(c2.getLocalStrategySortOrder()[0] == coGroupNode.getSortOrders()[0]);
	Assert.assertTrue(c2.getLocalStrategySortOrder()[1] == coGroupNode.getSortOrders()[1]);
	
	// check that the local group orderings are correct
	Assert.assertEquals(false, c1.getLocalStrategySortOrder()[2]);
	Assert.assertEquals(false, c2.getLocalStrategySortOrder()[2]);
	Assert.assertEquals(true, c2.getLocalStrategySortOrder()[3]);
}
 
Example 9
Source File: GroupOrderTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testCoGroupWithGroupOrder() {
	// construct the plan
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(DEFAULT_PARALLELISM);
	DataSet<Tuple7<Long, Long, Long, Long, Long, Long, Long>> set1 = env.readCsvFile("/tmp/fake1.csv")
			.types(Long.class, Long.class, Long.class, Long.class, Long.class, Long.class, Long.class);
	DataSet<Tuple7<Long, Long, Long, Long, Long, Long, Long>> set2 = env.readCsvFile("/tmp/fake2.csv")
			.types(Long.class, Long.class, Long.class, Long.class, Long.class, Long.class, Long.class);

	set1.coGroup(set2).where(3,0).equalTo(6,0)
			.sortFirstGroup(5, Order.DESCENDING)
			.sortSecondGroup(1, Order.DESCENDING).sortSecondGroup(4, Order.ASCENDING)
			.with(new IdentityCoGrouper<Tuple7<Long, Long, Long, Long, Long, Long, Long>>()).name("CoGroup")
			.output(new DiscardingOutputFormat<Tuple7<Long, Long, Long, Long, Long, Long, Long>>()).name("Sink");

	Plan plan = env.createProgramPlan();
	OptimizedPlan oPlan;

	try {
		oPlan = compileNoStats(plan);
	} catch(CompilerException ce) {
		ce.printStackTrace();
		fail("The pact compiler is unable to compile this plan correctly.");
		return; // silence the compiler
	}
	
	OptimizerPlanNodeResolver resolver = getOptimizerPlanNodeResolver(oPlan);
	SinkPlanNode sinkNode = resolver.getNode("Sink");
	DualInputPlanNode coGroupNode = resolver.getNode("CoGroup");
	
	// verify the strategies
	Assert.assertEquals(ShipStrategyType.FORWARD, sinkNode.getInput().getShipStrategy());
	Assert.assertEquals(ShipStrategyType.PARTITION_HASH, coGroupNode.getInput1().getShipStrategy());
	Assert.assertEquals(ShipStrategyType.PARTITION_HASH, coGroupNode.getInput2().getShipStrategy());
	
	Channel c1 = coGroupNode.getInput1();
	Channel c2 = coGroupNode.getInput2();
	
	Assert.assertEquals(LocalStrategy.SORT, c1.getLocalStrategy());
	Assert.assertEquals(LocalStrategy.SORT, c2.getLocalStrategy());
	
	FieldList ship1 = new FieldList(3, 0);
	FieldList ship2 = new FieldList(6, 0);
	
	FieldList local1 = new FieldList(3, 0, 5);
	FieldList local2 = new FieldList(6, 0, 1, 4);
	
	Assert.assertEquals(ship1, c1.getShipStrategyKeys());
	Assert.assertEquals(ship2, c2.getShipStrategyKeys());
	Assert.assertEquals(local1, c1.getLocalStrategyKeys());
	Assert.assertEquals(local2, c2.getLocalStrategyKeys());
	
	Assert.assertTrue(c1.getLocalStrategySortOrder()[0] == coGroupNode.getSortOrders()[0]);
	Assert.assertTrue(c1.getLocalStrategySortOrder()[1] == coGroupNode.getSortOrders()[1]);
	Assert.assertTrue(c2.getLocalStrategySortOrder()[0] == coGroupNode.getSortOrders()[0]);
	Assert.assertTrue(c2.getLocalStrategySortOrder()[1] == coGroupNode.getSortOrders()[1]);
	
	// check that the local group orderings are correct
	Assert.assertEquals(false, c1.getLocalStrategySortOrder()[2]);
	Assert.assertEquals(false, c2.getLocalStrategySortOrder()[2]);
	Assert.assertEquals(true, c2.getLocalStrategySortOrder()[3]);
}