Java Code Examples for org.apache.flink.api.java.DataSet#project()

The following examples show how to use org.apache.flink.api.java.DataSet#project() . 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: JoinDeadlockITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Long> longs = env.generateSequence(0, 100000);

	DataSet<Tuple1<Long>> longT1 = longs.map(new TupleWrapper());
	DataSet<Tuple1<Long>> longT2 = longT1.project(0);
	DataSet<Tuple1<Long>> longT3 = longs.map(new TupleWrapper());

	longT2.join(longT3).where(0).equalTo(0).projectFirst(0)
			.join(longT1).where(0).equalTo(0).projectFirst(0)
			.writeAsText(resultPath);

	env.execute();
}
 
Example 2
Source File: JoinDeadlockITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Long> longs = env.generateSequence(0, 100000);

	DataSet<Tuple1<Long>> longT1 = longs.map(new TupleWrapper());
	DataSet<Tuple1<Long>> longT2 = longT1.project(0);
	DataSet<Tuple1<Long>> longT3 = longs.map(new TupleWrapper());

	longT2.join(longT3).where(0).equalTo(0).projectFirst(0)
			.join(longT1).where(0).equalTo(0).projectFirst(0)
			.writeAsText(resultPath);

	env.execute();
}
 
Example 3
Source File: JoinDeadlockITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Long> longs = env.generateSequence(0, 100000);

	DataSet<Tuple1<Long>> longT1 = longs.map(new TupleWrapper());
	DataSet<Tuple1<Long>> longT2 = longT1.project(0);
	DataSet<Tuple1<Long>> longT3 = longs.map(new TupleWrapper());

	longT2.join(longT3).where(0).equalTo(0).projectFirst(0)
			.join(longT1).where(0).equalTo(0).projectFirst(0)
			.writeAsText(resultPath);

	env.execute();
}
 
Example 4
Source File: ProjectITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	/*
	 * Projection with tuple fields indexes
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds = CollectionDataSets.get5TupleDataSet(env);
	DataSet<Tuple3<String, Long, Integer>> projDs = ds.
			project(3, 4, 2);
	List<Tuple3<String, Long, Integer>> result = projDs.collect();

	String expectedResult = "Hallo,1,0\n" +
			"Hallo Welt,2,1\n" +
			"Hallo Welt wie,1,2\n" +
			"Hallo Welt wie gehts?,2,3\n" +
			"ABC,2,4\n" +
			"BCD,3,5\n" +
			"CDE,2,6\n" +
			"DEF,1,7\n" +
			"EFG,1,8\n" +
			"FGH,2,9\n" +
			"GHI,1,10\n" +
			"HIJ,3,11\n" +
			"IJK,3,12\n" +
			"JKL,2,13\n" +
			"KLM,2,14\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 5
Source File: ProjectITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	/*
	 * Projection with tuple fields indexes
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds = CollectionDataSets.get5TupleDataSet(env);
	DataSet<Tuple3<String, Long, Integer>> projDs = ds.
			project(3, 4, 2);
	List<Tuple3<String, Long, Integer>> result = projDs.collect();

	String expectedResult = "Hallo,1,0\n" +
			"Hallo Welt,2,1\n" +
			"Hallo Welt wie,1,2\n" +
			"Hallo Welt wie gehts?,2,3\n" +
			"ABC,2,4\n" +
			"BCD,3,5\n" +
			"CDE,2,6\n" +
			"DEF,1,7\n" +
			"EFG,1,8\n" +
			"FGH,2,9\n" +
			"GHI,1,10\n" +
			"HIJ,3,11\n" +
			"IJK,3,12\n" +
			"JKL,2,13\n" +
			"KLM,2,14\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 6
Source File: ProjectITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	/*
	 * Projection with tuple fields indexes
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds = CollectionDataSets.get5TupleDataSet(env);
	DataSet<Tuple3<String, Long, Integer>> projDs = ds.
			project(3, 4, 2);
	List<Tuple3<String, Long, Integer>> result = projDs.collect();

	String expectedResult = "Hallo,1,0\n" +
			"Hallo Welt,2,1\n" +
			"Hallo Welt wie,1,2\n" +
			"Hallo Welt wie gehts?,2,3\n" +
			"ABC,2,4\n" +
			"BCD,3,5\n" +
			"CDE,2,6\n" +
			"DEF,1,7\n" +
			"EFG,1,8\n" +
			"FGH,2,9\n" +
			"GHI,1,10\n" +
			"HIJ,3,11\n" +
			"IJK,3,12\n" +
			"JKL,2,13\n" +
			"KLM,2,14\n";

	compareResultAsTuples(result, expectedResult);
}