Java Code Examples for org.apache.flink.test.operators.util.CollectionDataSets#getMixedPojoDataSet()

The following examples show how to use org.apache.flink.test.operators.util.CollectionDataSets#getMixedPojoDataSet() . 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: SortPartitionITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortPartitionPojoByNestedFieldExpression() throws Exception {
	/*
	 * Test sort partition on field expression
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(3);

	DataSet<POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	List<Tuple1<Boolean>> result = ds
			.map(new IdMapper<POJO>()).setParallelism(1) // parallelize input
			.sortPartition("nestedTupleWithCustom.f1.myString", Order.ASCENDING)
			.sortPartition("number", Order.DESCENDING)
			.mapPartition(new OrderCheckMapper<>(new PojoChecker()))
			.distinct().collect();

	String expected = "(true)\n";

	compareResultAsText(result, expected);
}
 
Example 2
Source File: DataSinkITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testPojoSortingSingleParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CollectionDataSets.POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	ds.writeAsText(resultPath).sortLocalOutput("number", Order.ASCENDING).setParallelism(1);

	env.execute();

	String expected = "1 First (10,100,1000,One) 10100\n" +
			"2 First_ (10,105,1000,One) 10200\n" +
			"3 First (11,102,3000,One) 10200\n" +
			"4 First_ (11,106,1000,One) 10300\n" +
			"5 First (11,102,2000,One) 10100\n" +
			"6 Second_ (20,200,2000,Two) 10100\n" +
			"7 Third (31,301,2000,Three) 10200\n" +
			"8 Third_ (30,300,1000,Three) 10100\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);
}
 
Example 3
Source File: DataSinkITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testPojoSortingDualParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CollectionDataSets.POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	ds.writeAsText(resultPath)
		.sortLocalOutput("str", Order.ASCENDING)
		.sortLocalOutput("number", Order.DESCENDING)
		.setParallelism(1);

	env.execute();

	String expected =
			"5 First (11,102,2000,One) 10100\n" +
			"3 First (11,102,3000,One) 10200\n" +
			"1 First (10,100,1000,One) 10100\n" +
			"4 First_ (11,106,1000,One) 10300\n" +
			"2 First_ (10,105,1000,One) 10200\n" +
			"6 Second_ (20,200,2000,Two) 10100\n" +
			"7 Third (31,301,2000,Three) 10200\n" +
			"8 Third_ (30,300,1000,Three) 10100\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);

}
 
Example 4
Source File: DataSinkITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testPojoSortingNestedParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CollectionDataSets.POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	ds.writeAsText(resultPath)
		.sortLocalOutput("nestedTupleWithCustom.f0", Order.ASCENDING)
		.sortLocalOutput("nestedTupleWithCustom.f1.myInt", Order.DESCENDING)
		.sortLocalOutput("nestedPojo.longNumber", Order.ASCENDING)
		.setParallelism(1);

	env.execute();

	String expected =
			"2 First_ (10,105,1000,One) 10200\n" +
			"1 First (10,100,1000,One) 10100\n" +
			"4 First_ (11,106,1000,One) 10300\n" +
			"5 First (11,102,2000,One) 10100\n" +
			"3 First (11,102,3000,One) 10200\n" +
			"6 Second_ (20,200,2000,Two) 10100\n" +
			"8 Third_ (30,300,1000,Three) 10100\n" +
			"7 Third (31,301,2000,Three) 10200\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);
}
 
Example 5
Source File: SortPartitionITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortPartitionPojoByNestedFieldExpression() throws Exception {
	/*
	 * Test sort partition on field expression
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(3);

	DataSet<POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	List<Tuple1<Boolean>> result = ds
			.map(new IdMapper<POJO>()).setParallelism(1) // parallelize input
			.sortPartition("nestedTupleWithCustom.f1.myString", Order.ASCENDING)
			.sortPartition("number", Order.DESCENDING)
			.mapPartition(new OrderCheckMapper<>(new PojoChecker()))
			.distinct().collect();

	String expected = "(true)\n";

	compareResultAsText(result, expected);
}
 
Example 6
Source File: DataSinkITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPojoSortingSingleParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CollectionDataSets.POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	ds.writeAsText(resultPath).sortLocalOutput("number", Order.ASCENDING).setParallelism(1);

	env.execute();

	String expected = "1 First (10,100,1000,One) 10100\n" +
			"2 First_ (10,105,1000,One) 10200\n" +
			"3 First (11,102,3000,One) 10200\n" +
			"4 First_ (11,106,1000,One) 10300\n" +
			"5 First (11,102,2000,One) 10100\n" +
			"6 Second_ (20,200,2000,Two) 10100\n" +
			"7 Third (31,301,2000,Three) 10200\n" +
			"8 Third_ (30,300,1000,Three) 10100\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);
}
 
Example 7
Source File: DataSinkITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPojoSortingDualParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CollectionDataSets.POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	ds.writeAsText(resultPath)
		.sortLocalOutput("str", Order.ASCENDING)
		.sortLocalOutput("number", Order.DESCENDING)
		.setParallelism(1);

	env.execute();

	String expected =
			"5 First (11,102,2000,One) 10100\n" +
			"3 First (11,102,3000,One) 10200\n" +
			"1 First (10,100,1000,One) 10100\n" +
			"4 First_ (11,106,1000,One) 10300\n" +
			"2 First_ (10,105,1000,One) 10200\n" +
			"6 Second_ (20,200,2000,Two) 10100\n" +
			"7 Third (31,301,2000,Three) 10200\n" +
			"8 Third_ (30,300,1000,Three) 10100\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);

}
 
Example 8
Source File: DataSinkITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPojoSortingNestedParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CollectionDataSets.POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	ds.writeAsText(resultPath)
		.sortLocalOutput("nestedTupleWithCustom.f0", Order.ASCENDING)
		.sortLocalOutput("nestedTupleWithCustom.f1.myInt", Order.DESCENDING)
		.sortLocalOutput("nestedPojo.longNumber", Order.ASCENDING)
		.setParallelism(1);

	env.execute();

	String expected =
			"2 First_ (10,105,1000,One) 10200\n" +
			"1 First (10,100,1000,One) 10100\n" +
			"4 First_ (11,106,1000,One) 10300\n" +
			"5 First (11,102,2000,One) 10100\n" +
			"3 First (11,102,3000,One) 10200\n" +
			"6 Second_ (20,200,2000,Two) 10100\n" +
			"8 Third_ (30,300,1000,Three) 10100\n" +
			"7 Third (31,301,2000,Three) 10200\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);
}
 
Example 9
Source File: SortPartitionITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortPartitionPojoByNestedFieldExpression() throws Exception {
	/*
	 * Test sort partition on field expression
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(3);

	DataSet<POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	List<Tuple1<Boolean>> result = ds
			.map(new IdMapper<POJO>()).setParallelism(1) // parallelize input
			.sortPartition("nestedTupleWithCustom.f1.myString", Order.ASCENDING)
			.sortPartition("number", Order.DESCENDING)
			.mapPartition(new OrderCheckMapper<>(new PojoChecker()))
			.distinct().collect();

	String expected = "(true)\n";

	compareResultAsText(result, expected);
}
 
Example 10
Source File: DataSinkITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPojoSortingSingleParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CollectionDataSets.POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	ds.writeAsText(resultPath).sortLocalOutput("number", Order.ASCENDING).setParallelism(1);

	env.execute();

	String expected = "1 First (10,100,1000,One) 10100\n" +
			"2 First_ (10,105,1000,One) 10200\n" +
			"3 First (11,102,3000,One) 10200\n" +
			"4 First_ (11,106,1000,One) 10300\n" +
			"5 First (11,102,2000,One) 10100\n" +
			"6 Second_ (20,200,2000,Two) 10100\n" +
			"7 Third (31,301,2000,Three) 10200\n" +
			"8 Third_ (30,300,1000,Three) 10100\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);
}
 
Example 11
Source File: DataSinkITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPojoSortingDualParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CollectionDataSets.POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	ds.writeAsText(resultPath)
		.sortLocalOutput("str", Order.ASCENDING)
		.sortLocalOutput("number", Order.DESCENDING)
		.setParallelism(1);

	env.execute();

	String expected =
			"5 First (11,102,2000,One) 10100\n" +
			"3 First (11,102,3000,One) 10200\n" +
			"1 First (10,100,1000,One) 10100\n" +
			"4 First_ (11,106,1000,One) 10300\n" +
			"2 First_ (10,105,1000,One) 10200\n" +
			"6 Second_ (20,200,2000,Two) 10100\n" +
			"7 Third (31,301,2000,Three) 10200\n" +
			"8 Third_ (30,300,1000,Three) 10100\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);

}
 
Example 12
Source File: DataSinkITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPojoSortingNestedParallelism1() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<CollectionDataSets.POJO> ds = CollectionDataSets.getMixedPojoDataSet(env);
	ds.writeAsText(resultPath)
		.sortLocalOutput("nestedTupleWithCustom.f0", Order.ASCENDING)
		.sortLocalOutput("nestedTupleWithCustom.f1.myInt", Order.DESCENDING)
		.sortLocalOutput("nestedPojo.longNumber", Order.ASCENDING)
		.setParallelism(1);

	env.execute();

	String expected =
			"2 First_ (10,105,1000,One) 10200\n" +
			"1 First (10,100,1000,One) 10100\n" +
			"4 First_ (11,106,1000,One) 10300\n" +
			"5 First (11,102,2000,One) 10100\n" +
			"3 First (11,102,3000,One) 10200\n" +
			"6 Second_ (20,200,2000,Two) 10100\n" +
			"8 Third_ (30,300,1000,Three) 10100\n" +
			"7 Third (31,301,2000,Three) 10200\n";

	compareResultsByLinesInMemoryWithStrictOrder(expected, resultPath);
}