org.apache.flink.api.common.functions.RichJoinFunction Java Examples

The following examples show how to use org.apache.flink.api.common.functions.RichJoinFunction. 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: BranchingPlansCompilerTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testBranchingBroadcastVariable() {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(100);

	DataSet<String> input1 = env.readTextFile(IN_FILE).name("source1");
	DataSet<String> input2 = env.readTextFile(IN_FILE).name("source2");
	DataSet<String> input3 = env.readTextFile(IN_FILE).name("source3");
	
	DataSet<String> result1 = input1
			.map(new IdentityMapper<String>())
			.reduceGroup(new Top1GroupReducer<String>())
				.withBroadcastSet(input3, "bc");
	
	DataSet<String> result2 = input2
			.map(new IdentityMapper<String>())
			.reduceGroup(new Top1GroupReducer<String>())
				.withBroadcastSet(input3, "bc");
	
	result1.join(result2)
			.where(new IdentityKeyExtractor<String>())
			.equalTo(new IdentityKeyExtractor<String>())
			.with(new RichJoinFunction<String, String, String>() {
				@Override
				public String join(String first, String second) {
					return null;
				}
			})
			.withBroadcastSet(input3, "bc1")
			.withBroadcastSet(input1, "bc2")
			.withBroadcastSet(result1, "bc3")
			.output(new DiscardingOutputFormat<String>());
	
	Plan plan = env.createProgramPlan();
	
	try{
		compileNoStats(plan);
	}catch(Exception e){
		e.printStackTrace();
		Assert.fail(e.getMessage());
	}
}
 
Example #2
Source File: BranchingPlansCompilerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testBranchingBroadcastVariable() {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(100);

	DataSet<String> input1 = env.readTextFile(IN_FILE).name("source1");
	DataSet<String> input2 = env.readTextFile(IN_FILE).name("source2");
	DataSet<String> input3 = env.readTextFile(IN_FILE).name("source3");
	
	DataSet<String> result1 = input1
			.map(new IdentityMapper<String>())
			.reduceGroup(new Top1GroupReducer<String>())
				.withBroadcastSet(input3, "bc");
	
	DataSet<String> result2 = input2
			.map(new IdentityMapper<String>())
			.reduceGroup(new Top1GroupReducer<String>())
				.withBroadcastSet(input3, "bc");
	
	result1.join(result2)
			.where(new IdentityKeyExtractor<String>())
			.equalTo(new IdentityKeyExtractor<String>())
			.with(new RichJoinFunction<String, String, String>() {
				@Override
				public String join(String first, String second) {
					return null;
				}
			})
			.withBroadcastSet(input3, "bc1")
			.withBroadcastSet(input1, "bc2")
			.withBroadcastSet(result1, "bc3")
			.output(new DiscardingOutputFormat<String>());
	
	Plan plan = env.createProgramPlan();
	
	try{
		compileNoStats(plan);
	}catch(Exception e){
		e.printStackTrace();
		Assert.fail(e.getMessage());
	}
}
 
Example #3
Source File: BranchingPlansCompilerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testBranchingBroadcastVariable() {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(100);

	DataSet<String> input1 = env.readTextFile(IN_FILE).name("source1");
	DataSet<String> input2 = env.readTextFile(IN_FILE).name("source2");
	DataSet<String> input3 = env.readTextFile(IN_FILE).name("source3");
	
	DataSet<String> result1 = input1
			.map(new IdentityMapper<String>())
			.reduceGroup(new Top1GroupReducer<String>())
				.withBroadcastSet(input3, "bc");
	
	DataSet<String> result2 = input2
			.map(new IdentityMapper<String>())
			.reduceGroup(new Top1GroupReducer<String>())
				.withBroadcastSet(input3, "bc");
	
	result1.join(result2)
			.where(new IdentityKeyExtractor<String>())
			.equalTo(new IdentityKeyExtractor<String>())
			.with(new RichJoinFunction<String, String, String>() {
				@Override
				public String join(String first, String second) {
					return null;
				}
			})
			.withBroadcastSet(input3, "bc1")
			.withBroadcastSet(input1, "bc2")
			.withBroadcastSet(result1, "bc3")
			.output(new DiscardingOutputFormat<String>());
	
	Plan plan = env.createProgramPlan();
	
	try{
		compileNoStats(plan);
	}catch(Exception e){
		e.printStackTrace();
		Assert.fail(e.getMessage());
	}
}