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

The following examples show how to use org.apache.flink.test.operators.util.CollectionDataSets#getPojoWithCollection() . 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: GroupReduceITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testJavaCollectionsWithinPojos() throws Exception {
	/*
	 * Test Java collections within pojos ( == test kryo)
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);

	DataSet<CollectionDataSets.PojoWithCollection> ds = CollectionDataSets.getPojoWithCollection(env);
	// f0.f0 is first integer
	DataSet<String> reduceDs = ds.groupBy("key")
			.reduceGroup(new GroupReducer7());
	List<String> result = reduceDs.collect();

	String expected = "callFor key 0 we got: pojo.a=apojo.a=bFor key 0 we got: pojo.a=a2pojo.a=b2\n";

	compareResultAsText(result, expected);
}
 
Example 2
Source File: GroupReduceITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testJavaCollectionsWithinPojos() throws Exception {
	/*
	 * Test Java collections within pojos ( == test kryo)
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);

	DataSet<CollectionDataSets.PojoWithCollection> ds = CollectionDataSets.getPojoWithCollection(env);
	// f0.f0 is first integer
	DataSet<String> reduceDs = ds.groupBy("key")
			.reduceGroup(new GroupReducer7());
	List<String> result = reduceDs.collect();

	String expected = "callFor key 0 we got: pojo.a=apojo.a=bFor key 0 we got: pojo.a=a2pojo.a=b2\n";

	compareResultAsText(result, expected);
}
 
Example 3
Source File: GroupReduceITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testJavaCollectionsWithinPojos() throws Exception {
	/*
	 * Test Java collections within pojos ( == test kryo)
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);

	DataSet<CollectionDataSets.PojoWithCollection> ds = CollectionDataSets.getPojoWithCollection(env);
	// f0.f0 is first integer
	DataSet<String> reduceDs = ds.groupBy("key")
			.reduceGroup(new GroupReducer7());
	List<String> result = reduceDs.collect();

	String expected = "callFor key 0 we got: pojo.a=apojo.a=bFor key 0 we got: pojo.a=a2pojo.a=b2\n";

	compareResultAsText(result, expected);
}
 
Example 4
Source File: GroupReduceITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testGroupByGenericType() throws Exception {
	/*
	 * Group by generic type
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);

	DataSet<CollectionDataSets.PojoWithCollection> ds = CollectionDataSets.getPojoWithCollection(env);

	// f0.f0 is first integer
	DataSet<String> reduceDs = ds.groupBy("bigInt")
			.reduceGroup(new GroupReducer8());
	List<String> result = reduceDs.collect();
	ExecutionConfig ec = env.getConfig();

	// check if automatic type registration with Kryo worked
	Assert.assertTrue(ec.getRegisteredKryoTypes().contains(BigInt.class));
	Assert.assertFalse(ec.getRegisteredKryoTypes().contains(java.sql.Date.class));

	String expected = null;

	String localExpected = "[call\n" +
			"For key 92233720368547758070 we got:\n" +
			"PojoWithCollection{pojos.size()=2, key=0, sqlDate=2033-05-18, bigInt=92233720368547758070, bigDecimalKeepItNull=null, scalaBigInt=10, mixed=[{someKey=1}, /this/is/wrong, uhlala]}\n" +
			"For key 92233720368547758070 we got:\n" +
			"PojoWithCollection{pojos.size()=2, key=0, sqlDate=1976-05-03, bigInt=92233720368547758070, bigDecimalKeepItNull=null, scalaBigInt=31104000, mixed=null}]";

	Assert.assertEquals(localExpected, result.toString());
}
 
Example 5
Source File: GroupReduceITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGroupByGenericType() throws Exception {
	/*
	 * Group by generic type
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);

	DataSet<CollectionDataSets.PojoWithCollection> ds = CollectionDataSets.getPojoWithCollection(env);

	// f0.f0 is first integer
	DataSet<String> reduceDs = ds.groupBy("bigInt")
			.reduceGroup(new GroupReducer8());
	List<String> result = reduceDs.collect();
	ExecutionConfig ec = env.getConfig();

	// check if automatic type registration with Kryo worked
	Assert.assertTrue(ec.getRegisteredKryoTypes().contains(BigInt.class));
	Assert.assertFalse(ec.getRegisteredKryoTypes().contains(java.sql.Date.class));

	String expected = null;

	String localExpected = "[call\n" +
			"For key 92233720368547758070 we got:\n" +
			"PojoWithCollection{pojos.size()=2, key=0, sqlDate=2033-05-18, bigInt=92233720368547758070, bigDecimalKeepItNull=null, scalaBigInt=10, mixed=[{someKey=1}, /this/is/wrong, uhlala]}\n" +
			"For key 92233720368547758070 we got:\n" +
			"PojoWithCollection{pojos.size()=2, key=0, sqlDate=1976-05-03, bigInt=92233720368547758070, bigDecimalKeepItNull=null, scalaBigInt=31104000, mixed=null}]";

	Assert.assertEquals(localExpected, result.toString());
}
 
Example 6
Source File: GroupReduceITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGroupByGenericType() throws Exception {
	/*
	 * Group by generic type
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);

	DataSet<CollectionDataSets.PojoWithCollection> ds = CollectionDataSets.getPojoWithCollection(env);

	// f0.f0 is first integer
	DataSet<String> reduceDs = ds.groupBy("bigInt")
			.reduceGroup(new GroupReducer8());
	List<String> result = reduceDs.collect();
	ExecutionConfig ec = env.getConfig();

	// check if automatic type registration with Kryo worked
	Assert.assertTrue(ec.getRegisteredKryoTypes().contains(BigInt.class));
	Assert.assertFalse(ec.getRegisteredKryoTypes().contains(java.sql.Date.class));

	String expected = null;

	String localExpected = "[call\n" +
			"For key 92233720368547758070 we got:\n" +
			"PojoWithCollection{pojos.size()=2, key=0, sqlDate=2033-05-18, bigInt=92233720368547758070, bigDecimalKeepItNull=null, scalaBigInt=10, mixed=[{someKey=1}, /this/is/wrong, uhlala]}\n" +
			"For key 92233720368547758070 we got:\n" +
			"PojoWithCollection{pojos.size()=2, key=0, sqlDate=1976-05-03, bigInt=92233720368547758070, bigDecimalKeepItNull=null, scalaBigInt=31104000, mixed=null}]";

	Assert.assertEquals(localExpected, result.toString());
}