Java Code Examples for org.apache.flink.test.operators.util.CollectionDataSets#PojoWithCollection
The following examples show how to use
org.apache.flink.test.operators.util.CollectionDataSets#PojoWithCollection .
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 |
@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 |
@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 |
@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 |
@Override public void reduce(Iterable<CollectionDataSets.PojoWithCollection> values, Collector<String> out) { StringBuilder concat = new StringBuilder(); concat.append("call"); for (CollectionDataSets.PojoWithCollection value : values) { concat.append("For key ").append(value.key).append(" we got: "); for (CollectionDataSets.Pojo1 p :value.pojos) { concat.append("pojo.a=").append(p.a); } } out.collect(concat.toString()); }
Example 5
Source File: GroupReduceITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@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-CEPplus with Apache License 2.0 | 5 votes |
@Override public void reduce(Iterable<CollectionDataSets.PojoWithCollection> values, Collector<String> out) { StringBuilder concat = new StringBuilder(); concat.append("call"); for (CollectionDataSets.PojoWithCollection value : values) { concat.append("\nFor key ").append(value.bigInt).append(" we got:\n").append(value); } out.collect(concat.toString()); }
Example 7
Source File: GroupReduceITCase.java From flink with Apache License 2.0 | 5 votes |
@Override public void reduce(Iterable<CollectionDataSets.PojoWithCollection> values, Collector<String> out) { StringBuilder concat = new StringBuilder(); concat.append("call"); for (CollectionDataSets.PojoWithCollection value : values) { concat.append("For key ").append(value.key).append(" we got: "); for (CollectionDataSets.Pojo1 p :value.pojos) { concat.append("pojo.a=").append(p.a); } } out.collect(concat.toString()); }
Example 8
Source File: GroupReduceITCase.java From flink with Apache License 2.0 | 5 votes |
@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 9
Source File: GroupReduceITCase.java From flink with Apache License 2.0 | 5 votes |
@Override public void reduce(Iterable<CollectionDataSets.PojoWithCollection> values, Collector<String> out) { StringBuilder concat = new StringBuilder(); concat.append("call"); for (CollectionDataSets.PojoWithCollection value : values) { concat.append("\nFor key ").append(value.bigInt).append(" we got:\n").append(value); } out.collect(concat.toString()); }
Example 10
Source File: GroupReduceITCase.java From flink with Apache License 2.0 | 5 votes |
@Override public void reduce(Iterable<CollectionDataSets.PojoWithCollection> values, Collector<String> out) { StringBuilder concat = new StringBuilder(); concat.append("call"); for (CollectionDataSets.PojoWithCollection value : values) { concat.append("For key ").append(value.key).append(" we got: "); for (CollectionDataSets.Pojo1 p :value.pojos) { concat.append("pojo.a=").append(p.a); } } out.collect(concat.toString()); }
Example 11
Source File: GroupReduceITCase.java From flink with Apache License 2.0 | 5 votes |
@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 12
Source File: GroupReduceITCase.java From flink with Apache License 2.0 | 5 votes |
@Override public void reduce(Iterable<CollectionDataSets.PojoWithCollection> values, Collector<String> out) { StringBuilder concat = new StringBuilder(); concat.append("call"); for (CollectionDataSets.PojoWithCollection value : values) { concat.append("\nFor key ").append(value.bigInt).append(" we got:\n").append(value); } out.collect(concat.toString()); }